blob: e66dc3a160406265cf5d811ccf8bf8fbe291b60e [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
Anssi Mannilad13ba632022-01-04 14:22:26 +02002748 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
Anssi Mannila92c38552021-12-29 09:59:24 +02002749 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
Anssi Mannilad13ba632022-01-04 14:22:26 +02002836 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
Anssi Mannila92c38552021-12-29 09:59:24 +02002837 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//-----------------------------------------------------------------------------
Anssi Mannila56233b02022-01-24 13:26:42 +02004619// TestRESTSubReqPartialResp
4620//
4621// stub stub
4622// +-------+ +---------+ +---------+
4623// | xapp | | submgr | | e2term |
4624// +-------+ +---------+ +---------+
4625// | | |
4626// | RESTSubReq | |
4627// |---------------->| |
4628// | RESTSubResp | |
4629// |<----------------| |
4630// | | SubReq |
4631// | |------------->|
4632// | | SubResp | Partially accepted
4633// | |<-------------|
4634// | | |
4635// | RESTNotif | |
4636// |<----------------| |
4637// | | |
4638// | [SUBS DELETE] |
4639// | | |
4640//
4641//-----------------------------------------------------------------------------
4642
4643func TestRESTSubReqPartialResp(t *testing.T) {
4644
4645 // Init counter check
4646 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4647 Counter{cRestSubReqFromXapp, 1},
4648 Counter{cRestSubRespToXapp, 1},
4649 Counter{cSubReqToE2, 1},
4650 Counter{cSubRespFromE2, 1},
4651 Counter{cPartialSubRespFromE2, 1},
4652 Counter{cRestSubNotifToXapp, 1},
4653 Counter{cRestSubDelReqFromXapp, 1},
4654 Counter{cSubDelReqToE2, 1},
4655 Counter{cSubDelRespFromE2, 1},
4656 Counter{cRestSubDelRespToXapp, 1},
4657 })
4658
4659 // Req
4660 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4661
4662 actionId := int64(2)
4663 actionType := "report"
4664 actionDefinition := []int64{5678, 1}
4665 subsequestActionType := "continue"
4666 timeToWait := "w10ms"
4667 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4668
4669 restSubId := xappConn1.SendRESTSubsReq(t, params)
4670 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4671 xappConn1.ExpectRESTNotification(t, restSubId)
4672
4673 actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{}
4674 actionNotAdmittedItem.ActionId = 1
4675 actionNotAdmittedItem.Cause.Content = 1
4676 actionNotAdmittedItem.Cause.Value = 8
4677 actionNotAdmittedList := e2ap.ActionNotAdmittedList{}
4678 actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem)
4679 e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList)
4680 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4681
4682 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4683
4684 // Del
4685 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4686
4687 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4688 //Wait that subs is cleaned
4689 waitSubsCleanup(t, e2SubsId, 10)
4690
4691 mainCtrl.VerifyCounterValues(t)
4692 mainCtrl.VerifyAllClean(t)
4693}
4694
4695//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004696// TestRESTSubDelReqRetryInSubmgr
4697//
4698// stub stub
4699// +-------+ +---------+ +---------+
4700// | xapp | | submgr | | e2term |
4701// +-------+ +---------+ +---------+
4702// | | |
4703// | [SUBS CREATE] |
4704// | | |
4705// | | |
4706// | RESTSubDelReq | |
4707// |---------------->| |
4708// | | |
4709// | RESTSubDelResp | |
4710// |<----------------| |
4711// | | SubDelReq |
4712// | |------------->|
4713// | | |
4714// | | SubDelReq |
4715// | |------------->|
4716// | | |
4717// | | SubDelResp |
4718// | |<-------------|
4719// | | |
4720//
4721//-----------------------------------------------------------------------------
4722func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004723
4724 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004725 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004726 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004727 Counter{cSubReqToE2, 1},
4728 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004729 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004730 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004731 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004732 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004733 Counter{cSubDelReReqToE2, 1},
4734 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004735 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004736 })
4737 // Req
4738 var params *teststube2ap.RESTSubsReqParams = nil
4739 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4740
4741 // Del
4742 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4743
4744 // E2t: Receive 1st SubsDelReq
4745 e2termConn1.RecvSubsDelReq(t)
4746
4747 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4748 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4749 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4750
4751 //Wait that subs is cleaned
4752 waitSubsCleanup(t, e2SubsId, 10)
4753
4754 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004755 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004756}
4757
4758//-----------------------------------------------------------------------------
4759// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4760//
4761// stub stub
4762// +-------+ +---------+ +---------+
4763// | xapp | | submgr | | e2term |
4764// +-------+ +---------+ +---------+
4765// | | |
4766// | [SUBS CREATE] |
4767// | | |
4768// | | |
4769// | RESTSubDelReq | |
4770// |---------------->| |
4771// | | |
4772// | RESTSubDelResp | |
4773// |<----------------| |
4774// | | SubDelReq |
4775// | |------------->|
4776// | | |
4777// | | SubDelReq |
4778// | |------------->|
4779// | | |
4780// | | |
4781//
4782//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004783
archaggeafbf95f2021-04-14 08:54:05 +03004784func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004785
4786 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004787 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004788 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004789 Counter{cSubReqToE2, 1},
4790 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004791 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004792 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004793 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004794 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004795 Counter{cSubDelReReqToE2, 1},
4796 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004797 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004798 })
4799
4800 // Req
4801 var params *teststube2ap.RESTSubsReqParams = nil
4802 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4803
4804 // Del
4805 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4806
4807 // E2t: Receive 1st SubsDelReq
4808 e2termConn1.RecvSubsDelReq(t)
4809
4810 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4811 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4812 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4813
4814 //Wait that subs is cleaned
4815 waitSubsCleanup(t, e2SubsId, 10)
4816
4817 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004818 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004819}
4820
4821//-----------------------------------------------------------------------------
4822// TestRESTSubDelReqSubDelFailRespInSubmgr
4823//
4824// stub stub
4825// +-------+ +---------+ +---------+
4826// | xapp | | submgr | | e2term |
4827// +-------+ +---------+ +---------+
4828// | | |
4829// | [SUBS CREATE] |
4830// | | |
4831// | | |
4832// | RESTSubDelReq | |
4833// |---------------->| |
4834// | | |
4835// | RESTSubDelResp | |
4836// |<----------------| |
4837// | | SubDelReq |
4838// | |------------->|
4839// | | |
4840// | | SubDelFail |
4841// | |<-------------|
4842// | | |
4843//
4844//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004845
archaggeafbf95f2021-04-14 08:54:05 +03004846func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004847
4848 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004849 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004850 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004851 Counter{cSubReqToE2, 1},
4852 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004853 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004854 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004855 Counter{cSubDelReqToE2, 1},
4856 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004857 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004858 })
4859
4860 // Req
4861 var params *teststube2ap.RESTSubsReqParams = nil
4862 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4863
4864 // Del
4865 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4866
4867 // E2t: Send receive SubsDelReq and send SubsDelFail
4868 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4869 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4870
4871 //Wait that subs is cleaned
4872 waitSubsCleanup(t, e2SubsId, 10)
4873
4874 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004875 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004876}
4877
4878//-----------------------------------------------------------------------------
4879// TestRESTSubReqAndSubDelOkSameAction
4880//
4881// stub stub
4882// +-------+ +-------+ +---------+ +---------+
4883// | xapp2 | | xapp1 | | submgr | | e2term |
4884// +-------+ +-------+ +---------+ +---------+
4885// | | | |
4886// | | RESTSubReq1 | |
4887// | |---------------->| |
4888// | | | |
4889// | | RESTSubResp1 | |
4890// | |<----------------| |
4891// | | | |
4892// | | | SubReq1 |
4893// | | |------------->|
4894// | | | SubResp1 |
4895// | | |<-------------|
4896// | | RESTNotif1 | |
4897// | |<----------------| |
4898// | | | |
4899// | RESTSubReq2 | |
4900// |------------------------------>| |
4901// | | | |
4902// | RESTSubResp2 | |
4903// |<------------------------------| |
4904// | | | |
4905// | | RESTNotif2 | |
4906// |<------------------------------| |
4907// | | | |
4908// | | RESTSubDelReq1 | |
4909// | |---------------->| |
4910// | | | |
4911// | | RESTSubDelResp1 | |
4912// | |<----------------| |
4913// | | | |
4914// | RESTSubDelReq2 | |
4915// |------------------------------>| |
4916// | | | |
4917// | RESTSubDelResp2 | |
4918// |<------------------------------| |
4919// | | | |
4920// | | | SubDelReq2 |
4921// | | |------------->|
4922// | | | |
4923// | | | SubDelResp2 |
4924// | | |<-------------|
4925// | | | |
4926//
4927//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004928
archaggeafbf95f2021-04-14 08:54:05 +03004929func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004930
4931 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004932 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004933 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004934 Counter{cSubReqToE2, 1},
4935 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004936 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004937 Counter{cMergedSubscriptions, 1},
4938 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004939 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004940 Counter{cSubDelReqToE2, 1},
4941 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004942 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004943 })
4944
4945 // Req1
4946 var params *teststube2ap.RESTSubsReqParams = nil
4947
4948 //Subs Create
4949 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4950 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4951
4952 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004953 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004954 params.SetMeid("RAN_NAME_1")
4955
4956 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004957 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004958 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004959 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004960 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004961 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004962 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004963 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004964
4965 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4966
4967 // Del1
4968 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4969
4970 // Del2
4971 deleteXapp2Subscription(t, &restSubId2)
4972
4973 //Wait that subs is cleaned
4974 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004975 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004976 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004977}
4978
4979//-----------------------------------------------------------------------------
4980// TestSubReqAndSubDelOkSameActionParallel
4981//
4982// stub stub stub
4983// +-------+ +-------+ +---------+ +---------+
4984// | xapp2 | | xapp1 | | submgr | | e2term |
4985// +-------+ +-------+ +---------+ +---------+
4986// | | | |
4987// | | | |
4988// | | | |
4989// | | SubReq1 | |
4990// | |------------->| |
4991// | | | |
4992// | | | SubReq1 |
4993// | | |------------->|
4994// | SubReq2 | |
4995// |--------------------------->| |
4996// | | | SubResp1 |
4997// | | |<-------------|
4998// | | SubResp1 | |
4999// | |<-------------| |
5000// | | | SubReq2 |
5001// | | |------------->|
5002// | | | |
5003// | | | SubResp2 |
5004// | | |<-------------|
5005// | SubResp2 | |
5006// |<---------------------------| |
5007// | | | |
5008// | | SubDelReq 1 | |
5009// | |------------->| |
5010// | | | |
5011// | | SubDelResp 1 | |
5012// | |<-------------| |
5013// | | | |
5014// | SubDelReq 2 | |
5015// |--------------------------->| |
5016// | | | |
5017// | | | SubDelReq 2 |
5018// | | |------------->|
5019// | | | |
5020// | | | SubDelReq 2 |
5021// | | |------------->|
5022// | | | |
5023// | SubDelResp 2 | |
5024// |<---------------------------| |
5025//
5026func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005027
5028 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005029 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005030 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005031 Counter{cSubReqToE2, 2},
5032 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005033 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005034 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005035 Counter{cSubDelReqToE2, 2},
5036 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005037 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005038 })
5039
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005040 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005041 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5042 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5043
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005044 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005045 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5046
5047 xappConn1.ExpectRESTNotification(t, restSubId1)
5048 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5049 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
5050
5051 xappConn2.ExpectRESTNotification(t, restSubId2)
5052 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
5053 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
5054 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5055
5056 // Del1
5057 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5058 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5059 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5060 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5061
5062 // Del2
5063 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5064 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
5065 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
5066
5067 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005068 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005069 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005070}
5071
5072//-----------------------------------------------------------------------------
5073// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
5074//
5075// stub stub stub
5076// +-------+ +-------+ +---------+ +---------+
5077// | xapp2 | | xapp1 | | submgr | | e2term |
5078// +-------+ +-------+ +---------+ +---------+
5079// | | | |
5080// | | | |
5081// | | | |
5082// | | RESTSubReq1 | |
5083// | |---------------->| |
5084// | | | |
5085// | | RESTSubResp1 | |
5086// | |<----------------| |
5087// | | | SubReq1 |
5088// | | |------------->|
5089// | RESTSubReq2 | |
5090// |------------------------------>| |
5091// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005092// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005093// |<------------------------------| |
5094// | | | SubReq1 |
5095// | | |------------->|
5096// | | | |
5097// | | | |
5098// | | | SubDelReq |
5099// | | |------------->|
5100// | | | |
5101// | | | SubDelResp |
5102// | | |<-------------|
5103// | | RESTNotif1 | |
5104// | | unsuccess | |
5105// | |<----------------| |
5106// | RESTNotif2 | |
5107// | | unsuccess | |
5108// |<------------------------------| |
5109// | | | |
5110// | | RESTSubDelReq1 | |
5111// | |---------------->| |
5112// | | | |
5113// | | RESTSubDelResp1 | |
5114// | |<----------------| |
5115// | | | |
5116// | RESTSubDelReq2 | |
5117// |------------------------------>| |
5118// | | | |
5119// | RESTSubDelResp2 | |
5120// |<------------------------------| |
5121//
5122//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005123
archaggeafbf95f2021-04-14 08:54:05 +03005124func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005125
5126 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005127 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005128 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005129 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005130 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005131 Counter{cSubReqTimerExpiry, 2},
5132 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005133 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005134 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005135 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005136 Counter{cSubDelReqToE2, 1},
5137 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005138 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005139 })
archaggeafbf95f2021-04-14 08:54:05 +03005140 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005141
5142 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005143 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005144 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5145 crereq1, _ := e2termConn1.RecvSubsReq(t)
5146
5147 // Req2
5148 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005149 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005150 params2.SetMeid("RAN_NAME_1")
5151 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5152 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5153
5154 //Req1 (retransmitted)
5155 e2termConn1.RecvSubsReq(t)
5156
5157 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005158
5159 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005160 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5161
Markku Virtanenda34eec2021-05-20 08:22:04 +00005162 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005163 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005164 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005165 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005166
5167 // Del1
5168 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5169
5170 // Del2
5171 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5172
Markku Virtanenda34eec2021-05-20 08:22:04 +00005173 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5174
archaggeafbf95f2021-04-14 08:54:05 +03005175 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005176 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005177 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005178 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005179}
5180
5181//-----------------------------------------------------------------------------
5182// TestRESTSubReqAndSubDelNokSameActionParallel
5183//
5184// stub stub stub
5185// +-------+ +-------+ +---------+ +---------+
5186// | xapp2 | | xapp1 | | submgr | | e2term |
5187// +-------+ +-------+ +---------+ +---------+
5188// | | | |
5189// | | | |
5190// | | | |
5191// | | RESTSubReq1 | |
5192// | |---------------->| |
5193// | | | |
5194// | | RESTSubResp1 | |
5195// | |<----------------| |
5196// | | | SubReq1 |
5197// | | |------------->|
5198// | RESTSubReq2 | |
5199// |------------------------------>| |
5200// | | | |
5201// | RESTSubDelResp2 | |
5202// |<------------------------------| |
5203// | | | SubFail1 |
5204// | | |<-------------|
5205// | | | |
5206// | | RESTNotif1 | |
5207// | | unsuccess | |
5208// | |<----------------| |
5209// | RESTNotif2 | |
5210// | | unsuccess | |
5211// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005212// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005213// | | 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 +03005214// | |---------------->| |
5215// | | | |
5216// | | RESTSubDelResp1 | |
5217// | |<----------------| |
5218// | | | |
5219// | RESTSubDelReq2 | |
5220// |------------------------------>| |
5221// | | | |
5222// | RESTSubDelResp2 | |
5223// |<------------------------------| |
5224//
5225//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005226
archaggeafbf95f2021-04-14 08:54:05 +03005227func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005228
5229 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005230 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005231 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005232 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005233 Counter{cSubReqToE2, 1},
5234 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005235 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005236 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005237 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005238 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005239 })
5240
5241 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005242
5243 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005244 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005245 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5246 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5247
5248 // Req2
5249 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005250 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005251 params2.SetMeid("RAN_NAME_1")
5252 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5253 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5254
5255 // E2t: send SubsFail (first)
5256 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5257 fparams1.Set(crereq1)
5258 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5259
archaggeafbf95f2021-04-14 08:54:05 +03005260 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005261 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005262 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005263 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005264 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005265
5266 // Del1
5267 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5268
5269 // Del2
5270 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5271
5272 //Wait that subs is cleaned
5273 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5274 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005275 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005276 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005277}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005278
Anssi Mannila27385172021-12-22 09:41:54 +02005279//-----------------------------------------------------------------------------
5280// TestRESTSubReqPolicyAndSubDelOk
5281//
5282// stub stub
5283// +-------+ +---------+ +---------+
5284// | xapp | | submgr | | e2term |
5285// +-------+ +---------+ +---------+
5286// | | |
5287// | RESTSubReq | |
5288// |--------------->| |
5289// | RESTSubResp | |
5290// |<---------------| |
5291// | | |
5292// | | SubReq |
5293// | |------------->|
5294// | | |
5295// | | SubResp |
5296// | |<-------------|
5297// | | |
5298// | RESTNotif | |
5299// |<---------------| |
5300// | | |
5301// | | |
5302// | RESTSubDelReq | |
5303// |--------------->| |
5304// | RESTSubDelResp | |
5305// |<---------------| |
5306// | | |
5307// | | SubDelReq |
5308// | |------------->|
5309// | | |
5310// | | SubDelResp |
5311// | |<-------------|
5312// | | |
5313//
5314//-----------------------------------------------------------------------------
5315
archaggeafbf95f2021-04-14 08:54:05 +03005316func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005317
5318 // Init counter check
5319 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005320 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005321 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005322 Counter{cSubReqToE2, 1},
5323 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005324 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005325 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005326 Counter{cSubDelReqToE2, 1},
5327 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005328 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005329 })
5330
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005331 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005332 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005333 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005334
5335 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5336 xappConn1.ExpectRESTNotification(t, restSubId)
5337 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5338 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005339 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005340
5341 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5342 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5343 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5344
5345 // Wait that subs is cleaned
5346 waitSubsCleanup(t, e2SubsId, 10)
5347 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005348 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005349}
5350
5351//-----------------------------------------------------------------------------
5352// TestRESTSubReqPolicyChangeAndSubDelOk
5353//
5354// stub stub
5355// +-------+ +---------+ +---------+
5356// | xapp | | submgr | | e2term |
5357// +-------+ +---------+ +---------+
5358// | | |
5359// | RESTSubReq | |
5360// |---------------->| |
5361// | | |
5362// | RESTSubResp | |
5363// |<----------------| |
5364// | | SubReq |
5365// | |------------->|
5366// | | |
5367// | | SubResp |
5368// | |<-------------|
5369// | | |
5370// | RESTNotif | |
5371// |<----------------| |
5372// | | |
5373// | RESTSubReq | |
5374// |---------------->| |
5375// | | |
5376// | RESTSubResp | |
5377// |<----------------| |
5378// | | SubReq |
5379// | |------------->|
5380// | | |
5381// | | SubResp |
5382// | |<-------------|
5383// | | |
5384// | RESTNotif | |
5385// |<----------------| |
5386// | | |
5387// | RESTSubDelReq | |
5388// |---------------->| |
5389// | | |
5390// | | SubDelReq |
5391// | |------------->|
5392// | | |
5393// | | SubDelResp |
5394// | |<-------------|
5395// | | |
5396// | RESTSubDelResp | |
5397// |<----------------| |
5398//
5399//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005400
archaggeafbf95f2021-04-14 08:54:05 +03005401func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005402
5403 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005404 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005405 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005406 Counter{cSubReqToE2, 2},
5407 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005408 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005409 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005410 Counter{cSubDelReqToE2, 1},
5411 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005412 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005413 })
5414
5415 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005416 const e2Timeout int64 = 1
5417 const e2RetryCount int64 = 0
5418 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005419
5420 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005421 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005422 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005423 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5424
5425 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005426 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005427
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005428 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005429 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005430 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005431 params.SetTimeToWait("w200ms")
5432 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5433
5434 // Del
5435 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5436
5437 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5438 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5439
5440 // Wait that subs is cleaned
5441 waitSubsCleanup(t, e2SubsId, 10)
5442 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005443 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005444}
5445
5446//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005447// TestRESTSubReqPolicyChangeNOk
5448//
5449// stub stub
5450// +-------+ +---------+ +---------+
5451// | xapp | | submgr | | e2term |
5452// +-------+ +---------+ +---------+
5453// | | |
5454// | RESTSubReq | |
5455// |---------------->| |
5456// | | |
5457// | RESTSubResp | |
5458// |<----------------| |
5459// | | SubReq |
5460// | |------------->|
5461// | | |
5462// | | SubResp |
5463// | |<-------------|
5464// | | |
5465// | RESTNotif | |
5466// |<----------------| |
5467// | | |
5468// | RESTSubReq | |
5469// |---------------->| |
5470// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005471// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005472// | | |
5473// | RESTSubDelReq | |
5474// |---------------->| |
5475// | | |
5476// | | SubDelReq |
5477// | |------------->|
5478// | | |
5479// | | SubDelResp |
5480// | |<-------------|
5481// | | |
5482// | RESTSubDelResp | |
5483// |<----------------| |
5484//
5485//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005486
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005487func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005488
5489 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5490 Counter{cRestSubReqFromXapp, 2},
5491 Counter{cRestSubRespToXapp, 1},
5492 Counter{cSubReqToE2, 1},
5493 Counter{cSubRespFromE2, 1},
5494 Counter{cRestSubNotifToXapp, 1},
5495 Counter{cRestSubFailToXapp, 1},
5496 Counter{cRestSubDelReqFromXapp, 1},
5497 Counter{cSubDelReqToE2, 1},
5498 Counter{cSubDelRespFromE2, 1},
5499 Counter{cRestSubDelRespToXapp, 1},
5500 })
5501
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005502 // Req
5503 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5504 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5505
5506 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005507 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5508
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005509 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005510 params.SetSubscriptionID(&restSubIdUpd)
5511 params.SetTimeToWait("w200ms")
5512
5513 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5514 assert.Equal(t, restSubId2, "")
5515
5516 // Del
5517 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5518
5519 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5520 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5521
5522 // Wait that subs is cleaned
5523 waitSubsCleanup(t, e2SubsId, 10)
5524 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005525 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005526}
5527
5528//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005529// TestRESTSubReqAndSubDelOkTwoE2termParallel
5530//
5531// stub stub stub
5532// +-------+ +---------+ +---------+ +---------+
5533// | xapp | | submgr | | e2term1 | | e2term2 |
5534// +-------+ +---------+ +---------+ +---------+
5535// | | | |
5536// | | | |
5537// | | | |
5538// | RESTSubReq1 | | |
5539// |---------------->| | |
5540// | | | |
5541// | RESTSubResp1 | | |
5542// |<----------------| | |
5543// | | SubReq1 | |
5544// | |------------->| |
5545// | | | |
5546// | RESTSubReq2 | | |
5547// |---------------->| | |
5548// | | | |
5549// | RESTSubResp2 | | |
5550// |<----------------| | |
5551// | | SubReq2 | |
5552// | |---------------------------->|
5553// | | | |
5554// | | SubResp1 | |
5555// | |<-------------| |
5556// | RESTNotif1 | | |
5557// |<----------------| | |
5558// | | SubResp2 | |
5559// | |<----------------------------|
5560// | RESTNotif2 | | |
5561// |<----------------| | |
5562// | | | |
5563// | [SUBS 1 DELETE] | |
5564// | | | |
5565// | [SUBS 2 DELETE] | |
5566// | | | |
5567//
5568//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005569
archaggeafbf95f2021-04-14 08:54:05 +03005570func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005571
5572 // Init counter check
5573 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005574 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005575 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005576 Counter{cSubReqToE2, 2},
5577 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005578 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005579 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005580 Counter{cSubDelReqToE2, 2},
5581 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005582 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005583 })
5584
5585 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005586
5587 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005588 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005589 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5590 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5591
5592 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005593 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005594 params.SetMeid("RAN_NAME_11")
5595 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5596 // would not work as notification would not be received
5597 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5598 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5599
5600 // Resp1
5601 xappConn1.ExpectRESTNotification(t, restSubId1)
5602 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5603 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005604 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005605
5606 // Resp2
5607 xappConn2.ExpectRESTNotification(t, restSubId2)
5608 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5609 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005610 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005611
5612 // Delete1
5613 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5614 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5615 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5616
5617 // Wait that subs is cleaned
5618 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5619
5620 // Delete2
5621 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5622 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5623 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5624
5625 // Wait that subs is cleaned
5626 waitSubsCleanup(t, e2SubsId2, 10)
5627
5628 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005629 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005630}
5631
5632//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005633// TestRESTSubReqInsertAndSubDelOk
5634//
5635// stub stub
5636// +-------+ +---------+ +---------+
5637// | xapp | | submgr | | e2term |
5638// +-------+ +---------+ +---------+
5639// | | |
5640// | RestSubReq | |
5641// |---------------->| |
5642// | | |
5643// | RESTSubResp | |
5644// |<----------------| |
5645// | | |
5646// | | SubReq |
5647// | |------------->|
5648// | | |
5649// | | SubResp |
5650// | |<-------------|
5651// | RESTNotif | |
5652// |<----------------| |
5653// | ... | ... |
5654// | | |
5655// | RESTSubDelReq | |
5656// |---------------->| |
5657// | | |
5658// | | SubDelReq |
5659// | |------------->|
5660// | | |
5661// | | SubDelResp |
5662// | |<-------------|
5663// | | |
5664// | RESTSubDelResp| |
5665// |<----------------| |
5666//
5667//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005668
archaggeafbf95f2021-04-14 08:54:05 +03005669func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005670
5671 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005672 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005673 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005674 Counter{cSubReqToE2, 1},
5675 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005676 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005677 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005678 Counter{cSubDelReqToE2, 1},
5679 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005680 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005681 })
5682
5683 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005684
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005685 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005686 params.SetSubActionTypes("insert")
5687
5688 // Req
5689 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5690
5691 // Del
5692 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5693
5694 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5695 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5696
5697 // Wait that subs is cleaned
5698 waitSubsCleanup(t, e2SubsId, 10)
5699 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005700 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005701}
5702
5703//-----------------------------------------------------------------------------
5704// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5705//
5706// stub stub
5707// +-------+ +---------+ +---------+
5708// | xapp | | submgr | | e2term |
5709// +-------+ +---------+ +---------+
5710// | | |
5711// | RESTSubReq | |
5712// |------------->| |
5713// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005714// | RESTSubResp | |
5715// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005716// | | SubReq |
5717// | |------------->|
5718// | | |
5719// | | SubResp |
5720// | <----|
5721// | |
5722// | Submgr restart |
5723// | |
5724// | | |
5725// | | SubDelReq |
5726// | |------------->|
5727// | | |
5728// | | SubDelResp |
5729// | |<-------------|
5730// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005731// | RESTNotif | |
5732// | unsuccess | |
5733// |<-------------| |
5734// | | |
5735// | RESTSubDelReq| |
5736// |------------->| |
5737// | | |
5738// |RESTSubDelResp| |
5739// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005740//
5741//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005742
archaggeafbf95f2021-04-14 08:54:05 +03005743func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005744
5745 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005746 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005747 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005748 Counter{cSubReqToE2, 1},
5749 Counter{cSubDelReqFromXapp, 1},
5750 Counter{cSubDelReqToE2, 1},
5751 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005752 Counter{cRestSubDelReqFromXapp, 1},
5753 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005754 })
5755
5756 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005757
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005758 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005759
5760 //Req
5761 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5762 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005763 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005764
5765 e2termConn1.RecvSubsReq(t)
5766
5767 mainCtrl.SetResetTestFlag(t, false)
5768
5769 mainCtrl.SimulateRestart(t)
5770 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5771
Anssi Mannilab43397e2021-11-16 12:06:16 +02005772 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005773 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5774 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5775
Anssi Mannilab43397e2021-11-16 12:06:16 +02005776 //Del
5777 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5778
archaggeafbf95f2021-04-14 08:54:05 +03005779 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005780 e2termConn1.TestMsgChanEmpty(t)
5781 mainCtrl.wait_registry_empty(t, 10)
5782
5783 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005784 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005785}
5786
5787//-----------------------------------------------------------------------------
5788// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5789//
5790// stub stub
5791// +-------+ +---------+ +---------+
5792// | xapp | | submgr | | e2term |
5793// +-------+ +---------+ +---------+
5794// | | |
5795// | RESTSubReq | |
5796// |---------------->| |
5797// | | |
5798// | RESTSubResp | |
5799// |<----------------| |
5800// | | SubReq |
5801// | |------------->|
5802// | | |
5803// | | SubResp |
5804// | |<-------------|
5805// | | |
5806// | RESTNotif | |
5807// |<----------------| |
5808// | | |
5809// | |
5810// | Submgr restart |
5811// | | |
5812// | RESTSubDelReq | |
5813// |---------------->| |
5814// | | |
5815// | | SubDelReq |
5816// | |------------->|
5817// | | |
5818// | | SubDelResp |
5819// | |<-------------|
5820// | | |
5821// | RESTSubDelResp | |
5822// |<----------------| |
5823//
5824//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005825
archaggeafbf95f2021-04-14 08:54:05 +03005826func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005827
5828 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005829 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005830 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005831 Counter{cSubReqToE2, 1},
5832 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005833 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005834 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005835 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005836 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005837 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005838 })
archaggeafbf95f2021-04-14 08:54:05 +03005839
5840 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005841 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005842 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005843 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005844
5845 // Check subscription
5846 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5847
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005848 mainCtrl.SimulateRestart(t)
5849 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005850
Anssi Mannila54838ed2021-11-19 11:25:01 +02005851 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5852 // That needs to be completed before successful subscription query is possible
5853 <-time.After(time.Second * 1)
5854
archaggeafbf95f2021-04-14 08:54:05 +03005855 // Check subscription
5856 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5857
5858 // Delete subscription
5859 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5860
5861 //Wait that subs is cleaned
5862 waitSubsCleanup(t, e2SubsId, 10)
5863
5864 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005865 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005866}
5867
5868//-----------------------------------------------------------------------------
5869// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5870//
5871// stub stub
5872// +-------+ +-------+ +---------+ +---------+
5873// | xapp2 | | xapp1 | | submgr | | e2term |
5874// +-------+ +-------+ +---------+ +---------+
5875// | | | |
5876// | | RESTSubReq1 | |
5877// | |---------------->| |
5878// | | | |
5879// | | RESTSubResp1 | |
5880// | |<----------------| |
5881// | | | |
5882// | | | SubReq1 |
5883// | | |------------->|
5884// | | | SubResp1 |
5885// | | |<-------------|
5886// | | RESTNotif1 | |
5887// | |<----------------| |
5888// | | | |
5889// | RESTSubReq2 | |
5890// |------------------------------>| |
5891// | | | |
5892// | RESTSubResp2 | |
5893// |<------------------------------| |
5894// | | | |
5895// | | RESTNotif2 | |
5896// |<------------------------------| |
5897// | | | |
5898// | | Submgr restart |
5899// | | | |
5900// | | RESTSubDelReq1 | |
5901// | |---------------->| |
5902// | | | |
5903// | | RESTSubDelResp1 | |
5904// | |<----------------| |
5905// | | | |
5906// | | Submgr restart |
5907// | | | |
5908// | RESTSubDelReq2 | |
5909// |------------------------------>| |
5910// | | | |
5911// | RESTSubDelResp2 | |
5912// |<------------------------------| |
5913// | | | |
5914// | | | SubDelReq2 |
5915// | | |------------->|
5916// | | | |
5917// | | | SubDelResp2 |
5918// | | |<-------------|
5919// | | | |
5920//
5921//-----------------------------------------------------------------------------
5922func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005923
5924 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005925 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005926 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005927 Counter{cSubReqToE2, 1},
5928 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005929 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005930 Counter{cMergedSubscriptions, 1},
5931 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005932 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005933 Counter{cSubDelReqToE2, 1},
5934 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005935 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005936 })
5937
archaggeafbf95f2021-04-14 08:54:05 +03005938 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005939 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005940 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005941 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005942
5943 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005944 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005945 params.SetMeid("RAN_NAME_1")
5946 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005947 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005948 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005949 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005950 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005951 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005952
5953 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5954
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005955 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005956 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5957
5958 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5959 // That needs to be completed before successful subscription delete is possible
5960 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005961
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005962 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03005963 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02005964 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005965 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02005966
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005967 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005968 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5969
5970 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5971 // That needs to be completed before successful subscription query is possible
5972 <-time.After(time.Second * 1)
5973
archaggeafbf95f2021-04-14 08:54:05 +03005974 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5975
5976 // Delete subscription 2
5977 deleteXapp2Subscription(t, &restSubId2)
5978
5979 //Wait that subs is cleaned
5980 waitSubsCleanup(t, e2SubsId2, 10)
5981
5982 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005983 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005984}
5985
5986//-----------------------------------------------------------------------------
5987// TestRESTReportSubReqAndSubDelOk
5988//
5989// stub stub
5990// +-------+ +---------+ +---------+
5991// | xapp | | submgr | | e2term |
5992// +-------+ +---------+ +---------+
5993// | | |
5994// | RestSubReq | |
5995// |---------------->| |
5996// | | |
5997// | RESTSubResp | |
5998// |<----------------| |
5999// | | |
6000// | | SubReq |
6001// | |------------->|
6002// | | |
6003// | | SubResp |
6004// | |<-------------|
6005// | RESTNotif | |
6006// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02006007// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03006008// | |------------->|
6009// | | |
6010// | | SubResp |
6011// | |<-------------|
6012// | RESTNotif | |
6013// |<----------------| |
6014// | ... | ... |
6015// | | |
6016// | | |
6017// | RESTSubDelReq | |
6018// |---------------->| |
6019// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006020// | RESTSubDelResp| |
6021// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006022// | | SubDelReq |
6023// | |------------->|
6024// | | |
6025// | | SubDelResp |
6026// | |<-------------|
6027// | | |
archaggeafbf95f2021-04-14 08:54:05 +03006028//
6029//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006030
archaggeafbf95f2021-04-14 08:54:05 +03006031func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006032 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006033 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006034 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006035}
6036
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006037func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006038 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006039
Anssi Mannila21782182021-12-10 10:56:02 +02006040 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6041 Counter{cRestSubReqFromXapp, 1},
6042 Counter{cRestSubRespToXapp, 1},
6043 Counter{cSubReqToE2, uint64(subReqCount)},
6044 Counter{cSubRespFromE2, uint64(subReqCount)},
6045 Counter{cRestSubNotifToXapp, 1},
6046 Counter{cRestSubDelReqFromXapp, 1},
6047 Counter{cRestSubDelRespToXapp, 1},
6048 Counter{cSubDelReqToE2, uint64(subReqCount)},
6049 Counter{cSubDelRespFromE2, uint64(subReqCount)},
6050 })
6051
archaggeafbf95f2021-04-14 08:54:05 +03006052 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006053 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006054 restSubId := xappConn1.SendRESTSubsReq(t, params)
6055
6056 var e2SubsId []uint32
6057 for i := 0; i < subReqCount; i++ {
6058 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6059 xappConn1.ExpectRESTNotification(t, restSubId)
6060
6061 e2termConn1.SendSubsResp(t, crereq, cremsg)
6062 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006063 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03006064 e2SubsId = append(e2SubsId, instanceId)
6065 resp, _ := xapp.Subscription.QuerySubscriptions()
6066 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
6067 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
6068 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
6069
6070 }
6071
6072 // Del
6073 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6074
6075 for i := 0; i < subReqCount; i++ {
6076 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6077 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6078 }
6079
6080 // Wait that subs is cleaned
6081 for i := 0; i < subReqCount; i++ {
6082 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6083 }
6084
6085 xappConn1.TestMsgChanEmpty(t)
6086 e2termConn1.TestMsgChanEmpty(t)
6087 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006088 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006089 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006090}
6091
Anssi Mannila27385172021-12-22 09:41:54 +02006092//-----------------------------------------------------------------------------
6093// TestRESTTwoPolicySubReqAndSubDelOk
6094//
6095// stub stub
6096// +-------+ +---------+ +---------+
6097// | xapp | | submgr | | e2term |
6098// +-------+ +---------+ +---------+
6099// | | |
6100// | RestSubReq | |
6101// |---------------->| |
6102// | | |
6103// | RESTSubResp | |
6104// |<----------------| |
6105// | | |
6106// | | SubReq |
6107// | |------------->|
6108// | | |
6109// | | SubResp |
6110// | |<-------------|
6111// | RESTNotif | |
6112// |<----------------| |
6113// | | SubReq |
6114// | |------------->|
6115// | | |
6116// | | SubResp |
6117// | |<-------------|
6118// | RESTNotif | |
6119// |<----------------| |
6120// | | |
6121// | RESTSubDelReq | |
6122// |---------------->| |
6123// | | |
6124// | RESTSubDelResp| |
6125// |<----------------| |
6126// | | SubDelReq |
6127// | |------------->|
6128// | | |
6129// | | SubDelResp |
6130// | |<-------------|
6131// | | |
6132// | | SubDelReq |
6133// | |------------->|
6134// | | |
6135// | | SubDelResp |
6136// | |<-------------|
6137// | | |
6138//
6139//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006140
archaggeafbf95f2021-04-14 08:54:05 +03006141func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6142
archaggeafbf95f2021-04-14 08:54:05 +03006143 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006144 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006145 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006146 Counter{cSubReqToE2, 2},
6147 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006148 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006149 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006150 Counter{cSubDelReqToE2, 2},
6151 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006152 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006153 })
6154
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006155 const subReqCount int = 2
6156
archaggeafbf95f2021-04-14 08:54:05 +03006157 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006158 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006159 restSubId := xappConn1.SendRESTSubsReq(t, params)
6160 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6161
6162 assert.Equal(t, len(e2SubsIds), 2)
6163
6164 // Del
6165 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6166 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6167
6168 xappConn1.TestMsgChanEmpty(t)
6169 e2termConn1.TestMsgChanEmpty(t)
6170 mainCtrl.wait_registry_empty(t, 10)
6171
6172 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006173 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006174}
Anssi Mannila27385172021-12-22 09:41:54 +02006175
6176//-----------------------------------------------------------------------------
6177// TestRESTPolicySubReqAndSubDelOk19E2Subs
6178//
6179// stub stub
6180// +-------+ +---------+ +---------+
6181// | xapp | | submgr | | e2term |
6182// +-------+ +---------+ +---------+
6183// | | |
6184// | RestSubReq | |
6185// |---------------->| |
6186// | | |
6187// | RESTSubResp | |
6188// |<----------------| |
6189// | | | ------
6190// | | SubReq |
6191// | |------------->|
6192// | | | E2 subscription x 19
6193// | | SubResp |
6194// | |<-------------|
6195// | RESTNotif | |
6196// |<----------------| |
6197// | | | ------
6198// | RESTSubDelReq | |
6199// |---------------->| |
6200// | | |
6201// | RESTSubDelResp| |
6202// |<----------------| |
6203// | | SubDelReq | ------
6204// | |------------->|
6205// | | | E2 subscription delete x 19
6206// | | SubDelResp |
6207// | |<-------------|
6208// | | | ------
6209// | | |
6210//
6211//-----------------------------------------------------------------------------
6212
6213func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006214
archaggeafbf95f2021-04-14 08:54:05 +03006215 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006216 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006217 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006218 Counter{cSubReqToE2, 19},
6219 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006220 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006221 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006222 Counter{cSubDelReqToE2, 19},
6223 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006224 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006225 })
6226
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006227 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006228 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006229 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006230 restSubId := xappConn1.SendRESTSubsReq(t, params)
6231 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6232
6233 assert.Equal(t, len(e2SubsIds), 19)
6234
6235 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6236 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6237
6238 xappConn1.TestMsgChanEmpty(t)
6239 e2termConn1.TestMsgChanEmpty(t)
6240 mainCtrl.wait_registry_empty(t, 10)
6241
6242 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006243 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006244}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006245
Anssi Mannila27385172021-12-22 09:41:54 +02006246//-----------------------------------------------------------------------------
6247// TestRESTTwoPolicySubReqAndSubDelOk
6248//
6249// stub stub
6250// +-------+ +---------+ +---------+
6251// | xapp | | submgr | | e2term |
6252// +-------+ +---------+ +---------+
6253// | | |
6254// | RestSubReq | |
6255// |---------------->| |
6256// | | |
6257// | RESTSubResp | |
6258// |<----------------| |
6259// | | |
6260// | | SubReq |
6261// | |------------->|
6262// | | |
6263// | | SubResp |
6264// | |<-------------|
6265// | RESTNotif | |
6266// |<----------------| |
6267// | | SubReq |
6268// | |------------->|
6269// | | |
6270// | | SubResp |
6271// | |<-------------|
6272// | RESTNotif | |
6273// |<----------------| |
6274// | | |
6275// | RESTSubDelReq | |
6276// |---------------->| |
6277// | | |
6278// | RESTSubDelResp| |
6279// |<----------------| |
6280// | | SubDelReq |
6281// | |------------->|
6282// | | |
6283// | | SubDelResp |
6284// | |<-------------|
6285// | | |
6286// | | SubDelReq |
6287// | |------------->|
6288// | | |
6289// | | SubDelResp |
6290// | |<-------------|
6291// | | |
6292//
6293//-----------------------------------------------------------------------------
6294
archaggeafbf95f2021-04-14 08:54:05 +03006295func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6296
6297 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006298
6299 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006300 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006301 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006302 Counter{cSubReqToE2, uint64(subReqCount)},
6303 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006304 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006305 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006306 Counter{cSubDelReqToE2, uint64(subReqCount)},
6307 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006308 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006309 })
6310
6311 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006312 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006313 restSubId := xappConn1.SendRESTSubsReq(t, params)
6314 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6315
6316 assert.Equal(t, len(e2SubsIds), subReqCount)
6317
6318 // Del
6319 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6320 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6321
6322 xappConn1.TestMsgChanEmpty(t)
6323 e2termConn1.TestMsgChanEmpty(t)
6324 mainCtrl.wait_registry_empty(t, 10)
6325
6326 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006327 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006328}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006329
Anssi Mannila27385172021-12-22 09:41:54 +02006330//-----------------------------------------------------------------------------
6331// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6332//
6333// stub stub
6334// +-------+ +---------+ +---------+
6335// | xapp | | submgr | | e2term |
6336// +-------+ +---------+ +---------+
6337// | | |
6338// | RestSubReq | |
6339// |---------------->| |
6340// | | |
6341// | RESTSubResp | |
6342// |<----------------| |
6343// | | |
6344// | | SubReq |
6345// | |------------->|
6346// | | |
6347// | | SubResp |
6348// | |<-------------|
6349// | RESTNotif | |
6350// |<----------------| |
6351// | | SubReq |
6352// | |------------->|
6353// | | |
6354// | | SubResp |
6355// | |<-------------|
6356// | RESTNotif | |
6357// |<----------------| |
6358// | | |
6359// | RESTSubDelReq | |
6360// |---------------->| |
6361// | | |
6362// | RESTSubDelResp| |
6363// |<----------------| |
6364// | | SubDelReq |
6365// | |------------->|
6366// | | |
6367// | | SubDelResp |
6368// | |<-------------|
6369// | | |
6370// | | SubDelReq |
6371// | |------------->|
6372// | | |
6373// | | SubDelResp |
6374// | |<-------------|
6375// | | |
6376//
6377//-----------------------------------------------------------------------------
6378
archaggeafbf95f2021-04-14 08:54:05 +03006379func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6380
6381 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006382
6383 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006384 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006385 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006386 Counter{cSubReqToE2, uint64(subReqCount)},
6387 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006388 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006389 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006390 Counter{cSubDelReqToE2, uint64(subReqCount)},
6391 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006392 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006393 })
6394
6395 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006396 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006397 restSubId := xappConn1.SendRESTSubsReq(t, params)
6398 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6399
6400 assert.Equal(t, len(e2SubsIds), subReqCount)
6401
6402 // Del
6403 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6404 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6405
6406 xappConn1.TestMsgChanEmpty(t)
6407 e2termConn1.TestMsgChanEmpty(t)
6408 mainCtrl.wait_registry_empty(t, 10)
6409
6410 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006411 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006412}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006413
Anssi Mannila27385172021-12-22 09:41:54 +02006414//-----------------------------------------------------------------------------
6415// TestRESTReportSubReqAndSubDelOk19E2Subs
6416//
6417// stub stub
6418// +-------+ +---------+ +---------+
6419// | xapp | | submgr | | e2term |
6420// +-------+ +---------+ +---------+
6421// | | |
6422// | RestSubReq | |
6423// |---------------->| |
6424// | | |
6425// | RESTSubResp | |
6426// |<----------------| |
6427// | | | ------
6428// | | SubReq |
6429// | |------------->|
6430// | | | E2 subscription x 19
6431// | | SubResp |
6432// | |<-------------|
6433// | RESTNotif | |
6434// |<----------------| |
6435// | | | ------
6436// | RESTSubDelReq | |
6437// |---------------->| |
6438// | | |
6439// | RESTSubDelResp| |
6440// |<----------------| |
6441// | | SubDelReq | ------
6442// | |------------->|
6443// | | | E2 subscription delete x 19
6444// | | SubDelResp |
6445// | |<-------------|
6446// | | | ------
6447// | | |
6448//
6449//-----------------------------------------------------------------------------
6450
6451func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006452
6453 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006454
6455 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006456 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006457 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006458 Counter{cSubReqToE2, uint64(subReqCount)},
6459 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006460 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006461 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006462 Counter{cSubDelReqToE2, uint64(subReqCount)},
6463 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006464 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006465 })
6466
6467 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006468 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006469 restSubId := xappConn1.SendRESTSubsReq(t, params)
6470 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6471
6472 assert.Equal(t, len(e2SubsIds), subReqCount)
6473
6474 // Del
6475 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6476 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6477
6478 xappConn1.TestMsgChanEmpty(t)
6479 e2termConn1.TestMsgChanEmpty(t)
6480 mainCtrl.wait_registry_empty(t, 10)
6481
6482 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006483 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006484}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006485
Anssi Mannila27385172021-12-22 09:41:54 +02006486//-----------------------------------------------------------------------------
6487// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6488//
6489// stub stub stub
6490// +-------+ +-------+ +---------+ +---------+
6491// | xapp2 | | xapp1 | | submgr | | e2term |
6492// +-------+ +-------+ +---------+ +---------+
6493// | | | |
6494// | | RESTSubReq1 | |
6495// | |------------->| |
6496// | | RESTSubResp1 | |
6497// | |<-------------| |
6498// | | | |
6499// | | | SubReq1 |
6500// | | |------------->|
6501// | | | |
6502// | RESTSubReq2 | |
6503// |------------------------>| |
6504// | RESTSubResp2 | |
6505// |<------------------------| |
6506// | | | |
6507// | | | SubReq2 |
6508// | | |------------->|
6509// | | | |
6510// | | | SubResp1 |
6511// | | |<-------------|
6512// | | RESTNotif1 | |
6513// | |<-------------| |
6514// | | | |
6515// | | | SubResp2 |
6516// | | |<-------------|
6517// | RESTNotif2 | |
6518// |<------------------------| |
6519// | | | |
6520// | | [SUBS 1 DELETE] |
6521// | | | |
6522// | | [SUBS 2 DELETE] |
6523// | | | |
6524//
6525//-----------------------------------------------------------------------------
6526
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006527func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006528
6529 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006530 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006531 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006532 Counter{cSubReqToE2, 2},
6533 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006534 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006535 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006536 Counter{cSubDelReqToE2, 2},
6537 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006538 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006539 })
6540
6541 // Req1
6542 var params *teststube2ap.RESTSubsReqParams = nil
6543
6544 //Subs Create
6545 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006546 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006547
6548 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6549
6550 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006551 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006552 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006553 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006554 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6555
6556 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006557 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006558 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6559 xappConn2.ExpectRESTNotification(t, restSubId2)
6560 e2termConn1.SendSubsResp(t, crereq, cremsg)
6561 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6562
6563 deleteXapp1Subscription(t, &restSubId1)
6564 deleteXapp2Subscription(t, &restSubId2)
6565
6566 waitSubsCleanup(t, e2SubsId1, 10)
6567 waitSubsCleanup(t, e2SubsId2, 10)
6568
6569 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006570 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006571}
6572
Anssi Mannila27385172021-12-22 09:41:54 +02006573//-----------------------------------------------------------------------------
6574// TestRESTSubReqReportSameActionDiffActionListLen
6575//
6576// stub stub stub
6577// +-------+ +-------+ +---------+ +---------+
6578// | xapp2 | | xapp1 | | submgr | | e2term |
6579// +-------+ +-------+ +---------+ +---------+
6580// | | | |
6581// | | RESTSubReq1 | |
6582// | |------------->| |
6583// | | RESTSubResp1 | |
6584// | |<-------------| |
6585// | | | |
6586// | | | SubReq1 |
6587// | | |------------->|
6588// | | | |
6589// | RESTSubReq2 | |
6590// |------------------------>| |
6591// | RESTSubResp2 | |
6592// |<------------------------| |
6593// | | | |
6594// | | | SubReq2 |
6595// | | |------------->|
6596// | | | |
6597// | | | SubResp1 |
6598// | | |<-------------|
6599// | | RESTNotif1 | |
6600// | |<-------------| |
6601// | | | |
6602// | | | SubResp2 |
6603// | | |<-------------|
6604// | RESTNotif2 | |
6605// |<------------------------| |
6606// | | | |
6607// | | [SUBS 1 DELETE] |
6608// | | | |
6609// | | [SUBS 2 DELETE] |
6610// | | | |
6611//
6612//-----------------------------------------------------------------------------
6613
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006614func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006615
6616 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006617 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006618 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006619 Counter{cSubReqToE2, 2},
6620 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006621 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006622 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006623 Counter{cSubDelReqToE2, 2},
6624 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006625 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006626 })
6627
6628 // Req1
6629 var params *teststube2ap.RESTSubsReqParams = nil
6630
6631 //Subs Create
6632 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006633 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006634
6635 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6636
6637 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006638 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006639 params.SetMeid("RAN_NAME_1")
6640
6641 actionId := int64(1)
6642 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006643 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006644 subsequestActionType := "continue"
6645 timeToWait := "w10ms"
6646 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6647
6648 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006649 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006650 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6651 xappConn2.ExpectRESTNotification(t, restSubId2)
6652 e2termConn1.SendSubsResp(t, crereq, cremsg)
6653 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6654
6655 deleteXapp1Subscription(t, &restSubId1)
6656 deleteXapp2Subscription(t, &restSubId2)
6657
6658 waitSubsCleanup(t, e2SubsId1, 10)
6659 waitSubsCleanup(t, e2SubsId2, 10)
6660
6661 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006662 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006663}
6664
Anssi Mannila27385172021-12-22 09:41:54 +02006665//-----------------------------------------------------------------------------
6666// TestRESTSubReqReportSameActionDiffActionID
6667//
6668// stub stub stub
6669// +-------+ +-------+ +---------+ +---------+
6670// | xapp2 | | xapp1 | | submgr | | e2term |
6671// +-------+ +-------+ +---------+ +---------+
6672// | | | |
6673// | | RESTSubReq1 | |
6674// | |------------->| |
6675// | | RESTSubResp1 | |
6676// | |<-------------| |
6677// | | | |
6678// | | | SubReq1 |
6679// | | |------------->|
6680// | | | |
6681// | RESTSubReq2 | |
6682// |------------------------>| |
6683// | RESTSubResp2 | |
6684// |<------------------------| |
6685// | | | |
6686// | | | SubReq2 |
6687// | | |------------->|
6688// | | | |
6689// | | | SubResp1 |
6690// | | |<-------------|
6691// | | RESTNotif1 | |
6692// | |<-------------| |
6693// | | | |
6694// | | | SubResp2 |
6695// | | |<-------------|
6696// | RESTNotif2 | |
6697// |<------------------------| |
6698// | | | |
6699// | | [SUBS 1 DELETE] |
6700// | | | |
6701// | | [SUBS 2 DELETE] |
6702// | | | |
6703//
6704//-----------------------------------------------------------------------------
6705
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006706func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006707
6708 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006709 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006710 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006711 Counter{cSubReqToE2, 2},
6712 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006713 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006714 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006715 Counter{cSubDelReqToE2, 2},
6716 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006717 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006718 })
6719
6720 // Req1
6721 var params *teststube2ap.RESTSubsReqParams = nil
6722
6723 //Subs Create
6724 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006725 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006726
6727 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6728
6729 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006730 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006731 params.SetMeid("RAN_NAME_1")
6732 params.SetSubActionIDs(int64(2))
6733
6734 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006735 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006736 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6737 xappConn2.ExpectRESTNotification(t, restSubId2)
6738 e2termConn1.SendSubsResp(t, crereq, cremsg)
6739 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6740
6741 deleteXapp1Subscription(t, &restSubId1)
6742 deleteXapp2Subscription(t, &restSubId2)
6743
6744 waitSubsCleanup(t, e2SubsId1, 10)
6745 waitSubsCleanup(t, e2SubsId2, 10)
6746
6747 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006748 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006749}
6750
Anssi Mannila27385172021-12-22 09:41:54 +02006751//-----------------------------------------------------------------------------
6752// TestRESTSubReqDiffActionType
6753//
6754// stub stub stub
6755// +-------+ +-------+ +---------+ +---------+
6756// | xapp2 | | xapp1 | | submgr | | e2term |
6757// +-------+ +-------+ +---------+ +---------+
6758// | | | |
6759// | | RESTSubReq1 | |
6760// | |------------->| |
6761// | | RESTSubResp1 | |
6762// | |<-------------| |
6763// | | | |
6764// | | | SubReq1 |
6765// | | |------------->|
6766// | | | |
6767// | RESTSubReq2 | |
6768// |------------------------>| |
6769// | RESTSubResp2 | |
6770// |<------------------------| |
6771// | | | |
6772// | | | SubReq2 |
6773// | | |------------->|
6774// | | | |
6775// | | | SubResp1 |
6776// | | |<-------------|
6777// | | RESTNotif1 | |
6778// | |<-------------| |
6779// | | | |
6780// | | | SubResp2 |
6781// | | |<-------------|
6782// | RESTNotif2 | |
6783// |<------------------------| |
6784// | | | |
6785// | | [SUBS 1 DELETE] |
6786// | | | |
6787// | | [SUBS 2 DELETE] |
6788// | | | |
6789//
6790//-----------------------------------------------------------------------------
6791
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006792func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006793
6794 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006795 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006796 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006797 Counter{cSubReqToE2, 2},
6798 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006799 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006800 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006801 Counter{cSubDelReqToE2, 2},
6802 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006803 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006804 })
6805
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006806 const e2Timeout int64 = 2
6807 const e2RetryCount int64 = 2
6808 const routingNeeded bool = true
6809
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006810 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006811 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006812 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006813
6814 //Subs Create
6815 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006816 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006817
6818 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6819
6820 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006821 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006822 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006823 params.SetMeid("RAN_NAME_1")
6824
6825 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006826 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006827 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6828 xappConn2.ExpectRESTNotification(t, restSubId2)
6829 e2termConn1.SendSubsResp(t, crereq, cremsg)
6830 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6831
6832 deleteXapp1Subscription(t, &restSubId1)
6833 deleteXapp2Subscription(t, &restSubId2)
6834
6835 waitSubsCleanup(t, e2SubsId1, 10)
6836 waitSubsCleanup(t, e2SubsId2, 10)
6837
6838 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006839 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006840}
6841
Anssi Mannila27385172021-12-22 09:41:54 +02006842//-----------------------------------------------------------------------------
6843// TestRESTSubReqPolicyAndSubDelOkSameAction
6844//
6845// stub stub stub
6846// +-------+ +-------+ +---------+ +---------+
6847// | xapp2 | | xapp1 | | submgr | | e2term |
6848// +-------+ +-------+ +---------+ +---------+
6849// | | | |
6850// | | RESTSubReq1 | |
6851// | |------------->| |
6852// | | RESTSubResp1 | |
6853// | |<-------------| |
6854// | | | |
6855// | | | SubReq1 |
6856// | | |------------->|
6857// | | | |
6858// | RESTSubReq2 | |
6859// |------------------------>| |
6860// | RESTSubResp2 | |
6861// |<------------------------| |
6862// | | | |
6863// | | | SubReq2 |
6864// | | |------------->|
6865// | | | |
6866// | | | SubResp1 |
6867// | | |<-------------|
6868// | | RESTNotif1 | |
6869// | |<-------------| |
6870// | | | |
6871// | | | SubResp2 |
6872// | | |<-------------|
6873// | RESTNotif2 | |
6874// |<------------------------| |
6875// | | | |
6876// | | [SUBS 1 DELETE] |
6877// | | | |
6878// | | [SUBS 2 DELETE] |
6879// | | | |
6880//
6881//-----------------------------------------------------------------------------
6882
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006883func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006884
6885 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006886 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006887 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006888 Counter{cSubReqToE2, 2},
6889 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006890 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006891 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006892 Counter{cSubDelReqToE2, 2},
6893 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006894 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006895 })
6896
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006897 const e2Timeout int64 = 2
6898 const e2RetryCount int64 = 2
6899 const routingNeeded bool = true
6900
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006901 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006902 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006903 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006904
6905 //Subs Create
6906 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006907 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006908
6909 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6910
6911 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006912 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006913 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006914 params.SetMeid("RAN_NAME_1")
6915
6916 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006917 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006918 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6919 xappConn2.ExpectRESTNotification(t, restSubId2)
6920 e2termConn1.SendSubsResp(t, crereq, cremsg)
6921 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6922
6923 deleteXapp1Subscription(t, &restSubId1)
6924 deleteXapp2Subscription(t, &restSubId2)
6925
6926 waitSubsCleanup(t, e2SubsId1, 10)
6927 waitSubsCleanup(t, e2SubsId2, 10)
6928
6929 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006930 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006931}
6932
Anssi Mannila27385172021-12-22 09:41:54 +02006933//-----------------------------------------------------------------------------
6934// TestRESTSubReqReportSameActionDiffActionDefinitionLen
6935//
6936// stub stub stub
6937// +-------+ +-------+ +---------+ +---------+
6938// | xapp2 | | xapp1 | | submgr | | e2term |
6939// +-------+ +-------+ +---------+ +---------+
6940// | | | |
6941// | | RESTSubReq1 | |
6942// | |------------->| |
6943// | | RESTSubResp1 | |
6944// | |<-------------| |
6945// | | | |
6946// | | | SubReq1 |
6947// | | |------------->|
6948// | | | |
6949// | RESTSubReq2 | |
6950// |------------------------>| |
6951// | RESTSubResp2 | |
6952// |<------------------------| |
6953// | | | |
6954// | | | SubReq2 |
6955// | | |------------->|
6956// | | | |
6957// | | | SubResp1 |
6958// | | |<-------------|
6959// | | RESTNotif1 | |
6960// | |<-------------| |
6961// | | | |
6962// | | | SubResp2 |
6963// | | |<-------------|
6964// | RESTNotif2 | |
6965// |<------------------------| |
6966// | | | |
6967// | | [SUBS 1 DELETE] |
6968// | | | |
6969// | | [SUBS 2 DELETE] |
6970// | | | |
6971//
6972//-----------------------------------------------------------------------------
6973
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006974func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006975
6976 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006977 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006978 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006979 Counter{cSubReqToE2, 2},
6980 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006981 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006982 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006983 Counter{cSubDelReqToE2, 2},
6984 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006985 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006986 })
6987
6988 // Req1
6989 var params *teststube2ap.RESTSubsReqParams = nil
6990
6991 //Subs Create
6992 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006993 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006994
6995 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6996
6997 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006998 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006999 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007000 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007001 params.SetSubActionDefinition(actionDefinition)
7002
7003 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007004 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007005 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7006 xappConn2.ExpectRESTNotification(t, restSubId2)
7007 e2termConn1.SendSubsResp(t, crereq, cremsg)
7008 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7009
7010 deleteXapp1Subscription(t, &restSubId1)
7011 deleteXapp2Subscription(t, &restSubId2)
7012
7013 waitSubsCleanup(t, e2SubsId1, 10)
7014 waitSubsCleanup(t, e2SubsId2, 10)
7015
7016 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007017 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007018}
7019
Anssi Mannila27385172021-12-22 09:41:54 +02007020//-----------------------------------------------------------------------------
7021// TestRESTSubReqReportSameActionDiffActionDefinitionContents
7022//
7023// stub stub stub
7024// +-------+ +-------+ +---------+ +---------+
7025// | xapp2 | | xapp1 | | submgr | | e2term |
7026// +-------+ +-------+ +---------+ +---------+
7027// | | | |
7028// | | RESTSubReq1 | |
7029// | |------------->| |
7030// | | RESTSubResp1 | |
7031// | |<-------------| |
7032// | | | |
7033// | | | SubReq1 |
7034// | | |------------->|
7035// | | | |
7036// | RESTSubReq2 | |
7037// |------------------------>| |
7038// | RESTSubResp2 | |
7039// |<------------------------| |
7040// | | | |
7041// | | | SubReq2 |
7042// | | |------------->|
7043// | | | |
7044// | | | SubResp1 |
7045// | | |<-------------|
7046// | | RESTNotif1 | |
7047// | |<-------------| |
7048// | | | |
7049// | | | SubResp2 |
7050// | | |<-------------|
7051// | RESTNotif2 | |
7052// |<------------------------| |
7053// | | | |
7054// | | [SUBS 1 DELETE] |
7055// | | | |
7056// | | [SUBS 2 DELETE] |
7057// | | | |
7058//
7059//-----------------------------------------------------------------------------
7060
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007061func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007062
7063 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007064 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007065 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007066 Counter{cSubReqToE2, 2},
7067 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007068 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007069 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007070 Counter{cSubDelReqToE2, 2},
7071 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007072 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007073 })
7074
7075 // Req1
7076 var params *teststube2ap.RESTSubsReqParams = nil
7077
7078 //Subs Create
7079 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007080 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007081
7082 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7083
7084 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007085 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007086 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007087 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007088 params.SetSubActionDefinition(actionDefinition)
7089
7090 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007091 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007092 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7093 xappConn2.ExpectRESTNotification(t, restSubId2)
7094 e2termConn1.SendSubsResp(t, crereq, cremsg)
7095 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7096
7097 deleteXapp1Subscription(t, &restSubId1)
7098 deleteXapp2Subscription(t, &restSubId2)
7099
7100 waitSubsCleanup(t, e2SubsId1, 10)
7101 waitSubsCleanup(t, e2SubsId2, 10)
7102
7103 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007104 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007105}
7106
Anssi Mannila27385172021-12-22 09:41:54 +02007107//-----------------------------------------------------------------------------
7108// TestRESTSubReqReportSameActionDiffSubsAction
7109//
7110// stub stub stub
7111// +-------+ +-------+ +---------+ +---------+
7112// | xapp2 | | xapp1 | | submgr | | e2term |
7113// +-------+ +-------+ +---------+ +---------+
7114// | | | |
7115// | | RESTSubReq1 | |
7116// | |------------->| |
7117// | | RESTSubResp1 | |
7118// | |<-------------| |
7119// | | | |
7120// | | | SubReq1 |
7121// | | |------------->|
7122// | | | |
7123// | RESTSubReq2 | |
7124// |------------------------>| |
7125// | RESTSubResp2 | |
7126// |<------------------------| |
7127// | | | |
7128// | | | SubReq2 |
7129// | | |------------->|
7130// | | | |
7131// | | | SubResp1 |
7132// | | |<-------------|
7133// | | RESTNotif1 | |
7134// | |<-------------| |
7135// | | | |
7136// | | | SubResp2 |
7137// | | |<-------------|
7138// | RESTNotif2 | |
7139// |<------------------------| |
7140// | | | |
7141// | | [SUBS 1 DELETE] |
7142// | | | |
7143// | | [SUBS 2 DELETE] |
7144// | | | |
7145//
7146//-----------------------------------------------------------------------------
7147
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007148func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007149
7150 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007151 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007152 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007153 Counter{cSubReqToE2, 2},
7154 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007155 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007156 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007157 Counter{cSubDelReqToE2, 2},
7158 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007159 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007160 })
7161
7162 // Req1
7163 var params *teststube2ap.RESTSubsReqParams = nil
7164
7165 //Subs Create
7166 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007167 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007168
7169 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7170
7171 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007172 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007173 params.SetMeid("RAN_NAME_1")
7174 params.SetTimeToWait("w200ms")
7175 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007176 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007177 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7178 xappConn2.ExpectRESTNotification(t, restSubId2)
7179 e2termConn1.SendSubsResp(t, crereq, cremsg)
7180 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7181
7182 deleteXapp1Subscription(t, &restSubId1)
7183 deleteXapp2Subscription(t, &restSubId2)
7184
7185 waitSubsCleanup(t, e2SubsId1, 10)
7186 waitSubsCleanup(t, e2SubsId2, 10)
7187
7188 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007189 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007190}
7191
Anssi Mannila51122392021-05-25 11:51:31 +03007192//-----------------------------------------------------------------------------
7193// TestRESTUnpackSubscriptionResponseDecodeFail
7194//
7195// stub stub
7196// +-------+ +---------+ +---------+
7197// | xapp | | submgr | | e2term |
7198// +-------+ +---------+ +---------+
7199// | | |
7200// | RestSubReq | |
7201// |---------------->| |
7202// | | |
7203// | RESTSubResp | |
7204// |<----------------| |
7205// | | |
7206// | | SubReq |
7207// | |------------->|
7208// | | |
7209// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007210// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007211// | | |
7212// | | SubReq |
7213// | |------------->|
7214// | | |
7215// | | SubFail | Duplicated action
7216// | |<-------------|
7217// | RESTNotif (fail)| |
7218// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007219// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007220// | [SUBS DELETE] |
7221// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007222//
7223//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007224
Anssi Mannila51122392021-05-25 11:51:31 +03007225func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007226
7227 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7228 Counter{cRestSubReqFromXapp, 1},
7229 Counter{cRestSubRespToXapp, 1},
7230 Counter{cSubReqToE2, 1},
7231 Counter{cSubReqTimerExpiry, 1},
7232 Counter{cSubReReqToE2, 1},
7233 Counter{cSubRespFromE2, 1},
7234 Counter{cSubFailFromE2, 1},
7235 Counter{cRestSubFailNotifToXapp, 1},
7236 Counter{cRestSubDelReqFromXapp, 1},
7237 Counter{cRestSubDelRespToXapp, 1},
7238 })
7239
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007240 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007241
7242 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007243 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007244 restSubId := xappConn1.SendRESTSubsReq(t, params)
7245
7246 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7247 // Decode of this response fails which will result resending original request
7248 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7249
7250 _, cremsg = e2termConn1.RecvSubsReq(t)
7251
Markku Virtanen55d2a282021-06-04 14:46:56 +03007252 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007253
7254 // Subscription already created in E2 Node.
7255 fparams := &teststube2ap.E2StubSubsFailParams{}
7256 fparams.Set(crereq)
7257 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7258 e2termConn1.SendSubsFail(t, fparams, cremsg)
7259
Anssi Mannila51122392021-05-25 11:51:31 +03007260 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007261 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007262
Anssi Mannilab43397e2021-11-16 12:06:16 +02007263 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7264
Anssi Mannila51122392021-05-25 11:51:31 +03007265 // Wait that subs is cleaned
7266 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7267
7268 xappConn1.TestMsgChanEmpty(t)
7269 e2termConn1.TestMsgChanEmpty(t)
7270 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007271 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007272 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007273}
7274
7275//-----------------------------------------------------------------------------
7276// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7277//
7278// stub stub
7279// +-------+ +---------+ +---------+
7280// | xapp | | submgr | | e2term |
7281// +-------+ +---------+ +---------+
7282// | | |
7283// | RestSubReq | |
7284// |---------------->| |
7285// | | |
7286// | RESTSubResp | |
7287// |<----------------| |
7288// | | |
7289// | | SubReq |
7290// | |------------->|
7291// | | |
7292// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007293// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007294// | | |
7295// | | SubReq |
7296// | |------------->|
7297// | | |
7298// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007299// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007300// | RESTNotif (fail)| |
7301// |<----------------| |
7302// | | SubDelReq |
7303// | |------------->|
7304// | | |
7305// | | SubDelResp |
7306// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007307// | | |
7308// | [SUBS DELETE] |
7309// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007310//
7311//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007312
Anssi Mannila51122392021-05-25 11:51:31 +03007313func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007314
7315 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7316 Counter{cRestSubReqFromXapp, 1},
7317 Counter{cRestSubRespToXapp, 1},
7318 Counter{cSubReqToE2, 1},
7319 Counter{cSubReqTimerExpiry, 2},
7320 Counter{cSubReReqToE2, 1},
7321 Counter{cSubRespFromE2, 1},
7322 Counter{cSubFailFromE2, 1},
7323 Counter{cRestSubFailNotifToXapp, 1},
7324 Counter{cRestSubDelReqFromXapp, 1},
7325 Counter{cRestSubDelRespToXapp, 1},
7326 Counter{cSubDelReqToE2, 1},
7327 Counter{cSubDelRespFromE2, 1},
7328 })
7329
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007330 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007331
7332 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007333 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007334 restSubId := xappConn1.SendRESTSubsReq(t, params)
7335
7336 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7337
Anssi Mannila21782182021-12-10 10:56:02 +02007338 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007339 orgInstanceId := crereq.RequestId.InstanceId
7340 crereq.RequestId.InstanceId = 0
7341 e2termConn1.SendSubsResp(t, crereq, cremsg)
7342
7343 _, cremsg = e2termConn1.RecvSubsReq(t)
7344
Markku Virtanen55d2a282021-06-04 14:46:56 +03007345 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007346
Anssi Mannila21782182021-12-10 10:56:02 +02007347 // 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 +03007348 fparams := &teststube2ap.E2StubSubsFailParams{}
7349 fparams.Set(crereq)
7350 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7351 e2termConn1.SendSubsFail(t, fparams, cremsg)
7352
7353 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7354 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7355
7356 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007357 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007358
Anssi Mannilab43397e2021-11-16 12:06:16 +02007359 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7360
Anssi Mannila51122392021-05-25 11:51:31 +03007361 // Wait that subs is cleaned
7362 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7363
7364 xappConn1.TestMsgChanEmpty(t)
7365 e2termConn1.TestMsgChanEmpty(t)
7366 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007367 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007368 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007369}
7370
7371//-----------------------------------------------------------------------------
7372// TestRESTUnpackSubscriptionResponseNoTransaction
7373//
7374// stub stub
7375// +-------+ +---------+ +---------+
7376// | xapp | | submgr | | e2term |
7377// +-------+ +---------+ +---------+
7378// | | |
7379// | RestSubReq | |
7380// |---------------->| |
7381// | | |
7382// | RESTSubResp | |
7383// |<----------------| |
7384// | | |
7385// | | SubReq |
7386// | |------------->|
7387// | | |
7388// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007389// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007390// | | |
7391// | | SubReq |
7392// | |------------->|
7393// | | |
7394// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007395// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007396// | RESTNotif (fail)| |
7397// |<----------------| |
7398// | | SubDelReq |
7399// | |------------->|
7400// | | |
7401// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007402// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007403// | | |
7404// | | SubDelReq |
7405// | |------------->|
7406// | | |
7407// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007408// | |<-------------| Ongoing transaction not found.
7409// | | |
7410// | [SUBS DELETE] |
7411// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007412//
7413//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007414
Anssi Mannila51122392021-05-25 11:51:31 +03007415func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007416
7417 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7418 Counter{cRestSubReqFromXapp, 1},
7419 Counter{cRestSubRespToXapp, 1},
7420 Counter{cSubReqToE2, 1},
7421 Counter{cSubReqTimerExpiry, 2},
7422 Counter{cSubReReqToE2, 1},
7423 Counter{cSubRespFromE2, 1},
7424 Counter{cSubFailFromE2, 1},
7425 Counter{cRestSubFailNotifToXapp, 1},
7426 Counter{cRestSubDelReqFromXapp, 1},
7427 Counter{cRestSubDelRespToXapp, 1},
7428 Counter{cSubDelReqToE2, 1},
7429 Counter{cSubDelReqTimerExpiry, 2},
7430 Counter{cSubDelReReqToE2, 1},
7431 Counter{cSubDelRespFromE2, 2},
7432 })
7433
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007434 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007435
7436 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007437 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007438 restSubId := xappConn1.SendRESTSubsReq(t, params)
7439
7440 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7441
7442 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7443 // No transaction exist for this response which will result resending original request
7444 e2termConn1.SendSubsResp(t, crereq, cremsg)
7445
7446 _, cremsg = e2termConn1.RecvSubsReq(t)
7447
Markku Virtanen55d2a282021-06-04 14:46:56 +03007448 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007449
7450 // Subscription already created in E2 Node.
7451 fparams := &teststube2ap.E2StubSubsFailParams{}
7452 fparams.Set(crereq)
7453 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7454 e2termConn1.SendSubsFail(t, fparams, cremsg)
7455
7456 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7457 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7458
7459 // Resending happens because there no transaction
7460 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7461 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7462
7463 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007464 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007465
Anssi Mannilab43397e2021-11-16 12:06:16 +02007466 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7467
Anssi Mannila51122392021-05-25 11:51:31 +03007468 // Wait that subs is cleaned
7469 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7470
7471 xappConn1.TestMsgChanEmpty(t)
7472 e2termConn1.TestMsgChanEmpty(t)
7473 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007474 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007475 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007476}
7477
7478//-----------------------------------------------------------------------------
7479// TestRESTUnpackSubscriptionFailureDecodeFail
7480//
7481// stub stub
7482// +-------+ +---------+ +---------+
7483// | xapp | | submgr | | e2term |
7484// +-------+ +---------+ +---------+
7485// | | |
7486// | RestSubReq | |
7487// |---------------->| |
7488// | | |
7489// | RESTSubResp | |
7490// |<----------------| |
7491// | | |
7492// | | SubReq |
7493// | |------------->|
7494// | | |
7495// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007496// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007497// | | |
7498// | | SubReq |
7499// | |------------->|
7500// | | |
7501// | | SubFail | Duplicated action
7502// | |<-------------|
7503// | RESTNotif (fail)| |
7504// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007505// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007506// | [SUBS DELETE] |
7507// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007508//
7509//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007510
Anssi Mannila51122392021-05-25 11:51:31 +03007511func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007512
7513 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7514 Counter{cRestSubReqFromXapp, 1},
7515 Counter{cRestSubRespToXapp, 1},
7516 Counter{cSubReqToE2, 1},
7517 Counter{cSubReqTimerExpiry, 1},
7518 Counter{cSubReReqToE2, 1},
7519 Counter{cSubFailFromE2, 2},
7520 Counter{cRestSubFailNotifToXapp, 1},
7521 Counter{cRestSubDelReqFromXapp, 1},
7522 Counter{cRestSubDelRespToXapp, 1},
7523 })
7524
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007525 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007526
7527 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007528 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007529 restSubId := xappConn1.SendRESTSubsReq(t, params)
7530
7531 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7532
7533 // Decode of this response fails which will result resending original request
7534 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7535
7536 _, cremsg = e2termConn1.RecvSubsReq(t)
7537
Markku Virtanen55d2a282021-06-04 14:46:56 +03007538 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007539
7540 // Subscription already created in E2 Node.
7541 fparams := &teststube2ap.E2StubSubsFailParams{}
7542 fparams.Set(crereq)
7543 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7544 e2termConn1.SendSubsFail(t, fparams, cremsg)
7545
Anssi Mannila51122392021-05-25 11:51:31 +03007546 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007547 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007548
Anssi Mannilab43397e2021-11-16 12:06:16 +02007549 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7550
Anssi Mannila51122392021-05-25 11:51:31 +03007551 // Wait that subs is cleaned
7552 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7553
7554 xappConn1.TestMsgChanEmpty(t)
7555 e2termConn1.TestMsgChanEmpty(t)
7556 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007557 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007558 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007559}
7560
7561//-----------------------------------------------------------------------------
7562// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7563//
7564// stub stub
7565// +-------+ +---------+ +---------+
7566// | xapp | | submgr | | e2term |
7567// +-------+ +---------+ +---------+
7568// | | |
7569// | RestSubReq | |
7570// |---------------->| |
7571// | | |
7572// | RESTSubResp | |
7573// |<----------------| |
7574// | | |
7575// | | SubReq |
7576// | |------------->|
7577// | | |
7578// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007579// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007580// | | |
7581// | | SubReq |
7582// | |------------->|
7583// | | |
7584// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007585// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007586// | RESTNotif (fail)| |
7587// |<----------------| |
7588// | | SubDelReq |
7589// | |------------->|
7590// | | |
7591// | | SubDelResp |
7592// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007593// | | |
7594// | [SUBS DELETE] |
7595// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007596//
7597//-----------------------------------------------------------------------------
7598func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007599
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007600 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007601
Anssi Mannila21782182021-12-10 10:56:02 +02007602 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7603 Counter{cRestSubReqFromXapp, 1},
7604 Counter{cRestSubRespToXapp, 1},
7605 Counter{cSubReqToE2, 1},
7606 Counter{cSubReqTimerExpiry, 2},
7607 Counter{cSubReReqToE2, 1},
7608 Counter{cSubFailFromE2, 2},
7609 Counter{cRestSubFailNotifToXapp, 1},
7610 Counter{cRestSubDelReqFromXapp, 1},
7611 Counter{cRestSubDelRespToXapp, 1},
7612 Counter{cSubDelReqToE2, 1},
7613 Counter{cSubDelRespFromE2, 1},
7614 })
7615
Anssi Mannila51122392021-05-25 11:51:31 +03007616 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007617 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007618 restSubId := xappConn1.SendRESTSubsReq(t, params)
7619
7620 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7621
Anssi Mannila21782182021-12-10 10:56:02 +02007622 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007623 fparams := &teststube2ap.E2StubSubsFailParams{}
7624 fparams.Set(crereq)
7625 fparams.Fail.RequestId.InstanceId = 0
7626 e2termConn1.SendSubsFail(t, fparams, cremsg)
7627
7628 _, cremsg = e2termConn1.RecvSubsReq(t)
7629
Markku Virtanen55d2a282021-06-04 14:46:56 +03007630 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007631
Anssi Mannila21782182021-12-10 10:56:02 +02007632 // 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 +03007633 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7634 e2termConn1.SendSubsFail(t, fparams, cremsg)
7635
7636 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7637 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7638
7639 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007640 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007641
Anssi Mannilab43397e2021-11-16 12:06:16 +02007642 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7643
Anssi Mannila51122392021-05-25 11:51:31 +03007644 // Wait that subs is cleaned
7645 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7646
7647 xappConn1.TestMsgChanEmpty(t)
7648 e2termConn1.TestMsgChanEmpty(t)
7649 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007650 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007651 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007652}
7653
7654//-----------------------------------------------------------------------------
7655// TestRESTUnpackSubscriptionFailureNoTransaction
7656//
7657// stub stub
7658// +-------+ +---------+ +---------+
7659// | xapp | | submgr | | e2term |
7660// +-------+ +---------+ +---------+
7661// | | |
7662// | RestSubReq | |
7663// |---------------->| |
7664// | | |
7665// | RESTSubResp | |
7666// |<----------------| |
7667// | | |
7668// | | SubReq |
7669// | |------------->|
7670// | | |
7671// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007672// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007673// | | |
7674// | | SubReq |
7675// | |------------->|
7676// | | |
7677// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007678// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007679// | RESTNotif (fail)| |
7680// |<----------------| |
7681// | | SubDelReq |
7682// | |------------->|
7683// | | |
7684// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007685// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7686// | | |
7687// | | SubDelReq |
7688// | |------------->|
7689// | | |
7690// | | SubDelResp |
7691// | |<-------------| Ongoing transaction not found.
7692// | | |
7693// | [SUBS DELETE] |
7694// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007695//
7696//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007697
Anssi Mannila51122392021-05-25 11:51:31 +03007698func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007699
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007700 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007701
Anssi Mannila21782182021-12-10 10:56:02 +02007702 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7703 Counter{cRestSubReqFromXapp, 1},
7704 Counter{cRestSubRespToXapp, 1},
7705 Counter{cSubReqToE2, 1},
7706 Counter{cSubReqTimerExpiry, 2},
7707 Counter{cSubReReqToE2, 1},
7708 Counter{cSubFailFromE2, 2},
7709 Counter{cRestSubFailNotifToXapp, 1},
7710 Counter{cRestSubDelReqFromXapp, 1},
7711 Counter{cRestSubDelRespToXapp, 1},
7712 Counter{cSubDelReqToE2, 1},
7713 Counter{cSubDelReqTimerExpiry, 2},
7714 Counter{cSubDelReReqToE2, 1},
7715 Counter{cSubDelRespFromE2, 2},
7716 })
7717
Anssi Mannila51122392021-05-25 11:51:31 +03007718 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007719 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007720 restSubId := xappConn1.SendRESTSubsReq(t, params)
7721
7722 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7723
7724 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7725
7726 // No transaction exist for this response which will result resending original request
7727 fparams := &teststube2ap.E2StubSubsFailParams{}
7728 fparams.Set(crereq)
7729 e2termConn1.SendSubsFail(t, fparams, cremsg)
7730
7731 _, cremsg = e2termConn1.RecvSubsReq(t)
7732
Markku Virtanen55d2a282021-06-04 14:46:56 +03007733 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007734
7735 // Subscription already created in E2 Node.
7736 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7737 e2termConn1.SendSubsFail(t, fparams, cremsg)
7738
7739 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7740 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7741
7742 // Resending happens because there no transaction
7743 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7744 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7745
7746 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007747 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007748
Anssi Mannilab43397e2021-11-16 12:06:16 +02007749 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7750
Anssi Mannila51122392021-05-25 11:51:31 +03007751 // Wait that subs is cleaned
7752 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7753
7754 xappConn1.TestMsgChanEmpty(t)
7755 e2termConn1.TestMsgChanEmpty(t)
7756 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007757 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007758 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007759}
7760
7761//-----------------------------------------------------------------------------
7762// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7763//
7764// stub stub
7765// +-------+ +---------+ +---------+
7766// | xapp | | submgr | | e2term |
7767// +-------+ +---------+ +---------+
7768// | | |
7769// | [SUBS CREATE] |
7770// | | |
7771// | | |
7772// | RESTSubDelReq | |
7773// |---------------->| |
7774// | | |
7775// | RESTSubDelResp | |
7776// |<----------------| |
7777// | | |
7778// | | SubDelReq |
7779// | |------------->|
7780// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007781// | | SubDelResp | ASN.1 decode fails.
7782// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007783// | | |
7784// | | SubDelReq |
7785// | |------------->|
7786// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007787// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007788// | |<-------------|
7789// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007790// | [SUBS DELETE] |
7791// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007792//
7793//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007794
Anssi Mannila51122392021-05-25 11:51:31 +03007795func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007796
Anssi Mannila21782182021-12-10 10:56:02 +02007797 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7798 Counter{cRestSubReqFromXapp, 1},
7799 Counter{cRestSubRespToXapp, 1},
7800 Counter{cSubReqToE2, 1},
7801 Counter{cSubRespFromE2, 1},
7802 Counter{cRestSubNotifToXapp, 1},
7803 Counter{cRestSubDelReqFromXapp, 1},
7804 Counter{cRestSubDelRespToXapp, 1},
7805 Counter{cSubDelReqToE2, 1},
7806 Counter{cSubDelReqTimerExpiry, 1},
7807 Counter{cSubDelReReqToE2, 1},
7808 Counter{cSubDelFailFromE2, 1},
7809 Counter{cSubDelRespFromE2, 1},
7810 })
7811
Anssi Mannila51122392021-05-25 11:51:31 +03007812 // Req
7813 var params *teststube2ap.RESTSubsReqParams = nil
7814 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7815
7816 // Del
7817 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7818
7819 // E2t: Receive 1st SubsDelReq
7820 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7821
7822 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02007823 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03007824
7825 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7826 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7827
7828 // Subscription does not exist in in E2 Node.
7829 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7830
7831 // Wait that subs is cleaned
7832 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7833
7834 xappConn1.TestMsgChanEmpty(t)
7835 e2termConn1.TestMsgChanEmpty(t)
7836 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007837 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007838 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007839}
7840
7841//-----------------------------------------------------------------------------
7842// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
7843//
7844// stub stub
7845// +-------+ +---------+ +---------+
7846// | xapp | | submgr | | e2term |
7847// +-------+ +---------+ +---------+
7848// | | |
7849// | [SUBS CREATE] |
7850// | | |
7851// | | |
7852// | RESTSubDelReq | |
7853// |---------------->| |
7854// | | |
7855// | RESTSubDelResp | |
7856// |<----------------| |
7857// | | |
7858// | | SubDelReq |
7859// | |------------->|
7860// | | |
7861// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007862// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007863// | | |
7864// | | SubDelReq |
7865// | |------------->|
7866// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007867// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007868// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007869// | | |
7870// | [SUBS DELETE] |
7871// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007872//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007873
Anssi Mannila51122392021-05-25 11:51:31 +03007874func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007875
Anssi Mannila21782182021-12-10 10:56:02 +02007876 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7877 Counter{cRestSubReqFromXapp, 1},
7878 Counter{cRestSubRespToXapp, 1},
7879 Counter{cSubReqToE2, 1},
7880 Counter{cSubRespFromE2, 1},
7881 Counter{cRestSubNotifToXapp, 1},
7882 Counter{cRestSubDelReqFromXapp, 1},
7883 Counter{cRestSubDelRespToXapp, 1},
7884 Counter{cSubDelReqToE2, 1},
7885 Counter{cSubDelReqTimerExpiry, 1},
7886 Counter{cSubDelReReqToE2, 1},
7887 Counter{cSubDelRespFromE2, 1},
7888 Counter{cSubDelFailFromE2, 1},
7889 })
7890
Anssi Mannila51122392021-05-25 11:51:31 +03007891 // Req
7892 var params *teststube2ap.RESTSubsReqParams = nil
7893 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7894
7895 // Del
7896 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7897
7898 // E2t: Receive 1st SubsDelReq
7899 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7900
7901 // Unknown instanceId in this response which will result resending original request
7902 delreq.RequestId.InstanceId = 0
7903 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7904
7905 // E2t: Receive 2nd SubsDelReq
7906 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7907
7908 // Subscription does not exist in in E2 Node.
7909 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7910
7911 // Wait that subs is cleaned
7912 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7913
7914 xappConn1.TestMsgChanEmpty(t)
7915 e2termConn1.TestMsgChanEmpty(t)
7916 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007917 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007918 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007919}
7920
7921//-----------------------------------------------------------------------------
7922// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
7923//
7924// stub stub
7925// +-------+ +---------+ +---------+
7926// | xapp | | submgr | | e2term |
7927// +-------+ +---------+ +---------+
7928// | | |
7929// | [SUBS CREATE] |
7930// | | |
7931// | | |
7932// | RESTSubDelReq | |
7933// |---------------->| |
7934// | | |
7935// | RESTSubDelResp | |
7936// |<----------------| |
7937// | | |
7938// | | SubDelReq |
7939// | |------------->|
7940// | | |
7941// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007942// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007943// | | |
7944// | | SubDelReq |
7945// | |------------->|
7946// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007947// | | SubDelFail | Subscription does exist any more in E2 node
7948// | |<-------------| Ongoing transaction not found. This will result timer expiry
7949// | | |
7950// | [SUBS DELETE] |
7951// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007952//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007953
Anssi Mannila51122392021-05-25 11:51:31 +03007954func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007955
Anssi Mannila21782182021-12-10 10:56:02 +02007956 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7957 Counter{cRestSubReqFromXapp, 1},
7958 Counter{cRestSubRespToXapp, 1},
7959 Counter{cSubReqToE2, 1},
7960 Counter{cSubRespFromE2, 1},
7961 Counter{cRestSubNotifToXapp, 1},
7962 Counter{cRestSubDelReqFromXapp, 1},
7963 Counter{cRestSubDelRespToXapp, 1},
7964 Counter{cSubDelReqToE2, 1},
7965 Counter{cSubDelReqTimerExpiry, 2},
7966 Counter{cSubDelReReqToE2, 1},
7967 Counter{cSubDelRespFromE2, 1},
7968 Counter{cSubDelFailFromE2, 1},
7969 })
7970
Anssi Mannila51122392021-05-25 11:51:31 +03007971 // Req
7972 var params *teststube2ap.RESTSubsReqParams = nil
7973 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7974
7975 // Del
7976 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7977
7978 // E2t: Receive 1st SubsDelReq
7979 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7980
7981 mainCtrl.MakeTransactionNil(t, e2SubsId)
7982
7983 // No transaction exist for this response which will result resending original request
7984 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7985
7986 // E2t: Receive 2nd SubsDelReq
7987 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7988
7989 // Subscription does not exist in in E2 Node.
7990 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7991
7992 // Wait that subs is cleaned
7993 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7994
7995 xappConn1.TestMsgChanEmpty(t)
7996 e2termConn1.TestMsgChanEmpty(t)
7997 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007998 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007999 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008000}
8001
8002//-----------------------------------------------------------------------------
8003// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
8004//
8005// stub stub
8006// +-------+ +---------+ +---------+
8007// | xapp | | submgr | | e2term |
8008// +-------+ +---------+ +---------+
8009// | | |
8010// | [SUBS CREATE] |
8011// | | |
8012// | | |
8013// | RESTSubDelReq | |
8014// |---------------->| |
8015// | | |
8016// | RESTSubDelResp | |
8017// |<----------------| |
8018// | | |
8019// | | SubDelReq |
8020// | |------------->|
8021// | | |
8022// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02008023// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008024// | | |
8025// | | SubDelReq |
8026// | |------------->|
8027// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008028// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008029// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008030// | | |
8031// | [SUBS DELETE] |
8032// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008033//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008034
Anssi Mannila51122392021-05-25 11:51:31 +03008035func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008036
Anssi Mannila21782182021-12-10 10:56:02 +02008037 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8038 Counter{cRestSubReqFromXapp, 1},
8039 Counter{cRestSubRespToXapp, 1},
8040 Counter{cSubReqToE2, 1},
8041 Counter{cSubRespFromE2, 1},
8042 Counter{cRestSubNotifToXapp, 1},
8043 Counter{cRestSubDelReqFromXapp, 1},
8044 Counter{cRestSubDelRespToXapp, 1},
8045 Counter{cSubDelReqToE2, 1},
8046 Counter{cSubDelReqTimerExpiry, 1},
8047 Counter{cSubDelReReqToE2, 1},
8048 Counter{cSubDelFailFromE2, 2},
8049 })
8050
Anssi Mannila51122392021-05-25 11:51:31 +03008051 // Req
8052 var params *teststube2ap.RESTSubsReqParams = nil
8053 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8054
8055 // Del
8056 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8057
8058 // E2t: Receive 1st SubsDelReq
8059 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8060
8061 // Decode of this response fails which will result resending original request
8062 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
8063
8064 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8065 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8066
8067 // Subscription does not exist in in E2 Node.
8068 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8069
8070 // Wait that subs is cleaned
8071 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8072
8073 xappConn1.TestMsgChanEmpty(t)
8074 e2termConn1.TestMsgChanEmpty(t)
8075 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008076 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008077 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008078}
8079
8080//-----------------------------------------------------------------------------
8081// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8082//
8083// stub stub
8084// +-------+ +---------+ +---------+
8085// | xapp | | submgr | | e2term |
8086// +-------+ +---------+ +---------+
8087// | | |
8088// | [SUBS CREATE] |
8089// | | |
8090// | | |
8091// | RESTSubDelReq | |
8092// |---------------->| |
8093// | | |
8094// | RESTSubDelResp | |
8095// |<----------------| |
8096// | | |
8097// | | SubDelReq |
8098// | |------------->|
8099// | | |
8100// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008101// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008102// | | |
8103// | | SubDelReq |
8104// | |------------->|
8105// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008106// | | SubDelFail | Subscription does exist any more in E2 node
8107// | |<-------------| No valid subscription found with subIds [0].
8108// | | |
8109// | [SUBS DELETE] |
8110// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008111//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008112
Anssi Mannila51122392021-05-25 11:51:31 +03008113func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008114
Anssi Mannila21782182021-12-10 10:56:02 +02008115 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8116 Counter{cRestSubReqFromXapp, 1},
8117 Counter{cRestSubRespToXapp, 1},
8118 Counter{cSubReqToE2, 1},
8119 Counter{cSubRespFromE2, 1},
8120 Counter{cRestSubNotifToXapp, 1},
8121 Counter{cRestSubDelReqFromXapp, 1},
8122 Counter{cRestSubDelRespToXapp, 1},
8123 Counter{cSubDelReqToE2, 1},
8124 Counter{cSubDelReqTimerExpiry, 1},
8125 Counter{cSubDelReReqToE2, 1},
8126 Counter{cSubDelFailFromE2, 2},
8127 })
8128
Anssi Mannila51122392021-05-25 11:51:31 +03008129 // Req
8130 var params *teststube2ap.RESTSubsReqParams = nil
8131 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8132
8133 // Del
8134 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8135
8136 // E2t: Receive 1st SubsDelReq
8137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8138
Anssi Mannila21782182021-12-10 10:56:02 +02008139 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008140 delreq.RequestId.InstanceId = 0
8141 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8142
8143 // E2t: Receive 2nd SubsDelReq
8144 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8145
Anssi Mannila21782182021-12-10 10:56:02 +02008146 // 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 +03008147 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8148
8149 // Wait that subs is cleaned
8150 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8151
8152 xappConn1.TestMsgChanEmpty(t)
8153 e2termConn1.TestMsgChanEmpty(t)
8154 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008155 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008156 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008157}
8158
8159//-----------------------------------------------------------------------------
8160// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8161//
8162// stub stub
8163// +-------+ +---------+ +---------+
8164// | xapp | | submgr | | e2term |
8165// +-------+ +---------+ +---------+
8166// | | |
8167// | [SUBS CREATE] |
8168// | | |
8169// | | |
8170// | RESTSubDelReq | |
8171// |---------------->| |
8172// | | |
8173// | RESTSubDelResp | |
8174// |<----------------| |
8175// | | |
8176// | | SubDelReq |
8177// | |------------->|
8178// | | |
8179// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008180// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008181// | | |
8182// | | SubDelReq |
8183// | |------------->|
8184// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008185// | | SubDelFail | Subscription does exist any more in E2 node
8186// | |<-------------| Ongoing transaction not found. This will result timer expiry
8187// | | |
8188// | [SUBS DELETE] |
8189// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008190//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008191
Anssi Mannila51122392021-05-25 11:51:31 +03008192func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008193
Anssi Mannila21782182021-12-10 10:56:02 +02008194 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8195 Counter{cRestSubReqFromXapp, 1},
8196 Counter{cRestSubRespToXapp, 1},
8197 Counter{cSubReqToE2, 1},
8198 Counter{cSubRespFromE2, 1},
8199 Counter{cRestSubNotifToXapp, 1},
8200 Counter{cRestSubDelReqFromXapp, 1},
8201 Counter{cRestSubDelRespToXapp, 1},
8202 Counter{cSubDelReqToE2, 1},
8203 Counter{cSubDelReqTimerExpiry, 2},
8204 Counter{cSubDelReReqToE2, 1},
8205 Counter{cSubDelFailFromE2, 2},
8206 })
8207
Anssi Mannila51122392021-05-25 11:51:31 +03008208 // Req
8209 var params *teststube2ap.RESTSubsReqParams = nil
8210 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8211
8212 // Del
8213 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8214
8215 // E2t: Receive 1st SubsDelReq
8216 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8217
8218 mainCtrl.MakeTransactionNil(t, e2SubsId)
8219
8220 // No transaction exist for this response which will result resending original request
8221 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8222
8223 // E2t: Receive 2nd SubsDelReq
8224 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8225
8226 // Subscription does not exist in in E2 Node.
8227 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8228
8229 // Wait that subs is cleaned
8230 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8231
8232 xappConn1.TestMsgChanEmpty(t)
8233 e2termConn1.TestMsgChanEmpty(t)
8234 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008235 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008236 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008237}
8238
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008239//-----------------------------------------------------------------------------
8240// TestRESTSubReqFailAsn1PackSubReqError
8241//
8242// stub stub
8243// +-------+ +---------+ +---------+
8244// | xapp | | submgr | | e2term |
8245// +-------+ +---------+ +---------+
8246// | | |
8247// | RESTSubReq | |
8248// |---------------->| |
8249// | | |
8250// | RESTSubResp | |
8251// |<----------------| |
8252// | | |
8253// | ASN.1 encode fails |
8254// | | |
8255// | | SubDelReq |
8256// | |------------->|
8257// | | |
8258// | | SubDelFail |
8259// | |<-------------|
8260// | | |
8261// | RESTNotif | |
8262// | unsuccess | |
8263// |<----------------| |
8264// | | |
8265// | [SUBS DELETE] |
8266// | | |
8267//
8268//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008269
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008270func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8271
8272 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008273 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008274 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008275 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008276 Counter{cRestSubDelReqFromXapp, 1},
8277 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008278 })
8279
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008280 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008281
8282 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008283 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008284 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8285
8286 // Req
8287 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008288 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008289
8290 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008291 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008292
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008293 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008294 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008295
8296 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008297
8298 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8299
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008300 // Wait that subs is cleaned
8301 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008302 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008303 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008304}
8305
Anssi Mannila27385172021-12-22 09:41:54 +02008306//-----------------------------------------------------------------------------
8307// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8308//
8309// stub stub
8310// +-------+ +---------+ +---------+
8311// | xapp | | submgr | | e2term |
8312// +-------+ +---------+ +---------+
8313// | | |
8314// | RESTSubReq | |
8315// |---------------->| |
8316// | | |
8317// | RESTSubResp | |
8318// |<----------------| |
8319// | | SubReq |
8320// | |------------->|
8321// | | |
8322// | | SubResp |
8323// | |<-------------|
8324// | | |
8325// | RESTNotif | |
8326// |<----------------| |
8327// | | |
8328// | RESTSubReq | | Policy modification
8329// |---------------->| |
8330// | | |
8331// | RESTSubResp | |
8332// |<----------------| |
8333// | | SubReq |
8334// | |------------->|
8335// | | |
8336// | | |
8337// | RESTNotif(Unsuccessful) | E2 timeout
8338// |<----------------| |
8339// | | |
8340// | RESTSubDelReq | |
8341// |---------------->| |
8342// | | |
8343// | | SubDelReq |
8344// | |------------->|
8345// | | |
8346// | | SubDelResp |
8347// | |<-------------|
8348// | | |
8349// | RESTSubDelResp | |
8350// |<----------------| |
8351//
8352//-----------------------------------------------------------------------------
8353
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008354func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008355
8356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8357 Counter{cRestSubReqFromXapp, 2},
8358 Counter{cRestSubRespToXapp, 2},
8359 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008360 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008361 Counter{cSubRespFromE2, 1},
8362 Counter{cRestSubNotifToXapp, 1},
8363 Counter{cRestSubFailNotifToXapp, 1},
8364 Counter{cRestSubDelReqFromXapp, 1},
8365 Counter{cSubDelReqToE2, 1},
8366 Counter{cSubDelRespFromE2, 1},
8367 Counter{cRestSubDelRespToXapp, 1},
8368 })
8369
8370 const e2Timeout int64 = 1
8371 const e2RetryCount int64 = 0
8372 const routingNeeded bool = false
8373
8374 // Req1
8375 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8376 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8377
8378 // Subs Create
8379 restSubId := xappConn1.SendRESTSubsReq(t, params)
8380 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8381
8382 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8383 xappConn1.ExpectRESTNotification(t, restSubId)
8384 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8385 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8386 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8387
8388 // Policy change
8389 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8390 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8391 params.SetSubscriptionID(&restSubId)
8392 params.SetTimeToWait("w200ms")
8393 restSubId = xappConn1.SendRESTSubsReq(t, params)
8394 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8395
8396 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8397 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008398 // SubsResp is missing, e2SubsId will be 0
8399 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8400 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008401
8402 // Del
8403 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8404 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8405 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8406
8407 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008408 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008409 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008410}
8411
8412//-----------------------------------------------------------------------------
8413// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8414//
8415// stub stub
8416// +-------+ +---------+ +---------+
8417// | xapp | | submgr | | e2term |
8418// +-------+ +---------+ +---------+
8419// | | |
8420// | RESTSubReq | |
8421// |---------------->| |
8422// | | |
8423// | RESTSubResp | |
8424// |<----------------| |
8425// | | SubReq |
8426// | |------------->|
8427// | | |
8428// | | SubResp |
8429// | |<-------------|
8430// | | |
8431// | RESTNotif | |
8432// |<----------------| |
8433// | | |
8434// | RESTSubReq | |
8435// |---------------->| |
8436// | | |
8437// | RESTSubResp | |
8438// |<----------------| |
8439// | | SubReq |
8440// | |------------->|
8441// | |
8442// | Submgr restart |
8443// | | |
8444// | RESTSubDelReq | |
8445// |---------------->| |
8446// | | |
8447// | | SubDelReq |
8448// | |------------->|
8449// | | |
8450// | | SubDelResp |
8451// | |<-------------|
8452// | | |
8453// | RESTSubDelResp | |
8454// |<----------------| |
8455//
8456//-----------------------------------------------------------------------------
8457
8458func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008459
8460 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8461 Counter{cRestSubReqFromXapp, 2},
8462 Counter{cRestSubRespToXapp, 2},
8463 Counter{cSubReqToE2, 2},
8464 Counter{cSubRespFromE2, 1},
8465 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008466 Counter{cRestSubDelReqFromXapp, 1},
8467 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008468 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008469 Counter{cRestSubDelRespToXapp, 1},
8470 })
8471
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008472 const e2Timeout int64 = 1
8473 const e2RetryCount int64 = 0
8474 const routingNeeded bool = false
8475
8476 // Req1
8477 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8478 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8479 // Create subscription
8480 restSubId := xappConn1.SendRESTSubsReq(t, params)
8481 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8482
8483 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8484 xappConn1.ExpectRESTNotification(t, restSubId)
8485 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8486 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8487 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8488
8489 // Check subscription
8490 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8491
8492 // Policy change
8493 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8494 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8495 params.SetSubscriptionID(&restSubId)
8496 params.SetTimeToWait("w200ms")
8497 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8498 restSubId = xappConn1.SendRESTSubsReq(t, params)
8499 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8500
8501 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8502 mainCtrl.SetResetTestFlag(t, false)
8503
8504 // SubsResp is missing due to submgr restart
8505
8506 mainCtrl.SimulateRestart(t)
8507 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8508
Anssi Mannila54838ed2021-11-19 11:25:01 +02008509 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8510 // That needs to be completed before successful subscription query is possible
8511 <-time.After(time.Second * 1)
8512
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008513 // Check subscription
8514 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8515
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008516 // Delete subscription
8517 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8518 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8519 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8520
8521 //Wait that subs is cleaned
8522 waitSubsCleanup(t, e2SubsId, 10)
8523
8524 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008525 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008526}
8527
archaggeafbf95f2021-04-14 08:54:05 +03008528////////////////////////////////////////////////////////////////////////////////////
8529// Services for UT cases
8530////////////////////////////////////////////////////////////////////////////////////
8531const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008532const host string = "localhost"
8533
8534func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8535 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008536 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008537 }
8538 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008539 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008540
8541 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8542 fromXappConn.ExpectRESTNotification(t, restSubId)
8543 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8544 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008545 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008546
8547 return restSubId, e2SubsId
8548}
8549
8550func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8551
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008552 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008553 if meid != "" {
8554 params.SetMeid(meid)
8555 }
8556 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8557 restSubId := xappConn2.SendRESTSubsReq(t, params)
8558 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008559 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008560 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008561 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008562
8563 return restSubId, e2SubsId
8564}
8565
8566func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008567
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008568 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008569 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008570 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008571
8572 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8573 xappConn1.ExpectRESTNotification(t, restSubId)
8574 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8575 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008576 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008577
8578 return restSubId, e2SubsId
8579}
8580
8581func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008582 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008583 restSubId := xappConn1.SendRESTSubsReq(t, params)
8584
8585 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8586 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8587 fparams1.Set(crereq1)
8588 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8589
8590 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8591 xappConn1.ExpectRESTNotification(t, restSubId)
8592 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8593 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008594 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008595
8596 return restSubId, e2SubsId
8597}
8598
8599func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8600 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8601 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8602 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8603}
8604
8605func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8606 xappConn1.SendRESTSubsDelReq(t, restSubId)
8607 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8608 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8609}
8610
8611func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8612 xappConn2.SendRESTSubsDelReq(t, restSubId)
8613 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8614 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8615}
8616
8617func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8618 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008619 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8620 assert.Equal(t, meid, resp[0].Meid)
8621 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008622}
8623
8624func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8625 //Wait that subs is cleaned
8626 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8627
8628 xappConn1.TestMsgChanEmpty(t)
8629 xappConn2.TestMsgChanEmpty(t)
8630 e2termConn1.TestMsgChanEmpty(t)
8631 mainCtrl.wait_registry_empty(t, timeout)
8632}
8633
8634func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8635
8636 var e2SubsId []uint32
8637
8638 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008639 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008640 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8641 fromXappConn.ExpectRESTNotification(t, restSubId)
8642 toE2termConn.SendSubsResp(t, crereq, cremsg)
8643 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8644 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008645 xapp.Logger.Debug("TEST: %v", e2SubsId)
8646 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008647 <-time.After(100 * time.Millisecond)
8648 }
8649 return e2SubsId
8650}
8651
8652func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8653
8654 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008655 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008656 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8657 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8658 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008659 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008660 <-time.After(100 * time.Millisecond)
8661 }
8662
8663 // Wait that subs is cleaned
8664 for i := 0; i < len(e2SubsIds); i++ {
8665 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8666 }
8667
8668}