blob: 3d0b448524d42c2793f5427fa25f88961bcf7f03 [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//-----------------------------------------------------------------------------
Anssi Mannila483bd162022-01-20 11:11:48 +0200435// TestRESTSubReqAndE2APDeleteRespUnpackingError
Markku Virtanenac8bde42021-05-25 09:54:42 +0000436//
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
Anssi Mannila483bd162022-01-20 11:11:48 +0200479func TestRESTSubReqAndE2APDeleteRespUnpackingError(t *testing.T) {
Markku Virtanenac8bde42021-05-25 09:54:42 +0000480
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//-----------------------------------------------------------------------------
Himanshu Puorhit84662c42023-08-29 15:46:18 +0530884
885//-----------------------------------------------------------------------------
886// TestSubReqAndSubDelOkOutofOrderIEs
887//
888// stub stub
889// +-------+ +---------+ +---------+
890// | xapp | | submgr | | e2term |
891// +-------+ +---------+ +---------+
892// | | |
893// | SubReq | |
894// |------------->| |
895// | | |
896// | | SubReq |
897// | |------------->|
898// | | |
899// | | SubResp | (Out of Order IEs)
900// | |<-------------|
901// | | |
902// | SubResp | |
903// |<-------------| |
904// | | |
905// | | |
906// | SubDelReq | |
907// |------------->| |
908// | | |
909// | | SubDelReq |
910// | |------------->|
911// | | |
912// | | SubDelResp |
913// | |<-------------|
914// | | |
915// | SubDelResp | |
916// |<-------------| |
917//
918//-----------------------------------------------------------------------------
919
920func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
921 CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs")
922
923 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
924 // Init counter check
925 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
926 Counter{cSubReqFromXapp, 1},
927 Counter{cSubReqToE2, 1},
928 Counter{cSubRespFromE2, 1},
929 Counter{cSubRespToXapp, 1},
930 Counter{cSubDelReqFromXapp, 1},
931 Counter{cSubDelReqToE2, 1},
932 Counter{cSubDelRespFromE2, 1},
933 Counter{cSubDelRespToXapp, 1},
934 })
935
936 cretrans := xappConn1.SendSubsReq(t, nil, nil)
937 if cretrans == nil {
938 t.Logf("Could not send SubsReq")
939 t.FailNow()
940 }
941 crereq, cremsg := e2termConn1.RecvSubsReq(t)
942 if crereq == nil || cremsg == nil {
943 t.Logf("Could not recieve SubsReq")
944 t.FailNow()
945 }
946
947 e2termConn1.SendSubsResp(t, crereq, cremsg)
948
949 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
950
951 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
952 resp, _ := xapp.Subscription.QuerySubscriptions()
953 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
954 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
955 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
956
957 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
958 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
959
960 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
961 xappConn1.RecvSubsDelResp(t, deltrans)
962
963 //Wait that subs is cleaned
964 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
965
966 xappConn1.TestMsgChanEmpty(t)
967 xappConn2.TestMsgChanEmpty(t)
968 e2termConn1.TestMsgChanEmpty(t)
969 mainCtrl.wait_registry_empty(t, 10)
970
971 mainCtrl.VerifyCounterValues(t)
972 mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
973}
974
975//-----------------------------------------------------------------------------
976
977//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200978// TestSubReqRetransmission
979//
980// stub stub
981// +-------+ +---------+ +---------+
982// | xapp | | submgr | | e2term |
983// +-------+ +---------+ +---------+
984// | | |
985// | SubReq | |
986// |------------->| |
987// | | |
988// | | SubReq |
989// | |------------->|
990// | | |
991// | SubReq | |
992// | (retrans) | |
993// |------------->| |
994// | | |
995// | | SubResp |
996// | |<-------------|
997// | | |
998// | SubResp | |
999// |<-------------| |
1000// | | |
1001// | [SUBS DELETE] |
1002// | | |
1003//
1004//-----------------------------------------------------------------------------
1005func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001006 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001007
1008 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001009 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001010 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001011
1012 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001013 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001014 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1015
Juha Hyttinen1683f912020-04-17 10:39:57 +03001016 // hack as there is no real way to see has message be handled.
1017 // Previuos counter check just tells that is has been received by submgr
1018 // --> artificial delay
1019 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001020 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001021 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001022
1023 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001024 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001025 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1026 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001027 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028
1029 //Wait that subs is cleaned
1030 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1031
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001032 xappConn1.TestMsgChanEmpty(t)
1033 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001034 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001035 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001036}
1037
1038//-----------------------------------------------------------------------------
1039// TestSubDelReqRetransmission
1040//
1041// stub stub
1042// +-------+ +---------+ +---------+
1043// | xapp | | submgr | | e2term |
1044// +-------+ +---------+ +---------+
1045// | | |
1046// | [SUBS CREATE] |
1047// | | |
1048// | | |
1049// | SubDelReq | |
1050// |------------->| |
1051// | | |
1052// | | SubDelReq |
1053// | |------------->|
1054// | | |
1055// | SubDelReq | |
1056// | (same sub) | |
1057// | (same xid) | |
1058// |------------->| |
1059// | | |
1060// | | SubDelResp |
1061// | |<-------------|
1062// | | |
1063// | SubDelResp | |
1064// |<-------------| |
1065//
1066//-----------------------------------------------------------------------------
1067func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001068 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001069
1070 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001071 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001072 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1073 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001074 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001075
1076 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001077 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001078 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001079
1080 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001081 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001082 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1083
Juha Hyttinen1683f912020-04-17 10:39:57 +03001084 // hack as there is no real way to see has message be handled.
1085 // Previuos counter check just tells that is has been received by submgr
1086 // --> artificial delay
1087 <-time.After(1 * time.Second)
1088
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001089 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001090 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001091
1092 //Wait that subs is cleaned
1093 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1094
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001095 xappConn1.TestMsgChanEmpty(t)
1096 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001097 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001098 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001099}
1100
1101//-----------------------------------------------------------------------------
1102// TestSubDelReqCollision
1103//
1104// stub stub
1105// +-------+ +---------+ +---------+
1106// | xapp | | submgr | | e2term |
1107// +-------+ +---------+ +---------+
1108// | | |
1109// | [SUBS CREATE] |
1110// | | |
1111// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001112// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001113// |------------->| |
1114// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001115// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001116// | |------------->|
1117// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001118// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001119// | (same sub) | |
1120// | (diff xid) | |
1121// |------------->| |
1122// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001123// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001124// | |<-------------|
1125// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001126// | SubDelResp 1 | |
1127// |<-------------| |
1128// | | |
1129// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001130// |<-------------| |
1131//
1132//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001133
Juha Hyttinenfa015662020-01-24 10:05:18 +02001134func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001135 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001136
1137 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001138 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001139 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1140 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001141 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001142
1143 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001144 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
Juha Hyttinen3944a222020-01-24 11:51:46 +02001147 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001148 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001149 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1150 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001151 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1152
Juha Hyttinen1683f912020-04-17 10:39:57 +03001153 // hack as there is no real way to see has message be handled.
1154 // Previuos counter check just tells that is has been received by submgr
1155 // --> artificial delay
1156 <-time.After(1 * time.Second)
1157
Juha Hyttinen3944a222020-01-24 11:51:46 +02001158 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001159 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001160
1161 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001162 xappConn1.RecvSubsDelResp(t, nil)
1163 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001164
1165 //Wait that subs is cleaned
1166 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1167
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001168 xappConn1.TestMsgChanEmpty(t)
1169 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001170 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001171 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001172}
1173
1174//-----------------------------------------------------------------------------
1175// TestSubReqAndSubDelOkTwoParallel
1176//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001177// stub stub stub
1178// +-------+ +-------+ +---------+ +---------+
1179// | xapp | | xapp | | submgr | | e2term |
1180// +-------+ +-------+ +---------+ +---------+
1181// | | | |
1182// | | | |
1183// | | | |
1184// | | SubReq1 | |
1185// | |------------->| |
1186// | | | |
1187// | | | SubReq1 |
1188// | | |------------->|
1189// | | | |
1190// | SubReq2 | |
1191// |------------------------>| |
1192// | | | |
1193// | | | SubReq2 |
1194// | | |------------->|
1195// | | | |
1196// | | | SubResp1 |
1197// | | |<-------------|
1198// | | SubResp1 | |
1199// | |<-------------| |
1200// | | | |
1201// | | | SubResp2 |
1202// | | |<-------------|
1203// | SubResp2 | |
1204// |<------------------------| |
1205// | | | |
1206// | | [SUBS 1 DELETE] |
1207// | | | |
1208// | | [SUBS 2 DELETE] |
1209// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001210//
1211//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001212
Juha Hyttinenfa015662020-01-24 10:05:18 +02001213func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001214 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001215
1216 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001218 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001220 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001221
1222 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001223 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001224 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001225
1226 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1227 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1228 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1229
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001230 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001231 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001232
1233 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001234 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001235 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001236
1237 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001238 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001239 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001240
1241 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001242 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001243 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1244 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001245 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001246 //Wait that subs is cleaned
1247 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1248
1249 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001250 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001251 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1252 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001253 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001254 //Wait that subs is cleaned
1255 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1256
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001257 xappConn1.TestMsgChanEmpty(t)
1258 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001259 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001260 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001261}
1262
1263//-----------------------------------------------------------------------------
1264// TestSameSubsDiffRan
1265// Same subscription to different RANs
1266//
1267// stub stub
1268// +-------+ +---------+ +---------+
1269// | xapp | | submgr | | e2term |
1270// +-------+ +---------+ +---------+
1271// | | |
1272// | | |
1273// | | |
1274// | SubReq(r1) | |
1275// |------------->| |
1276// | | |
1277// | | SubReq(r1) |
1278// | |------------->|
1279// | | |
1280// | | SubResp(r1) |
1281// | |<-------------|
1282// | | |
1283// | SubResp(r1) | |
1284// |<-------------| |
1285// | | |
1286// | SubReq(r2) | |
1287// |------------->| |
1288// | | |
1289// | | SubReq(r2) |
1290// | |------------->|
1291// | | |
1292// | | SubResp(r2) |
1293// | |<-------------|
1294// | | |
1295// | SubResp(r2) | |
1296// |<-------------| |
1297// | | |
1298// | [SUBS r1 DELETE] |
1299// | | |
1300// | [SUBS r2 DELETE] |
1301// | | |
1302//
1303//-----------------------------------------------------------------------------
1304func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001305 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001306
1307 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001308 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1309 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001310 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1311 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001312 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001313
1314 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001315 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1316 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001317 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1318 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001320
1321 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1323 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001324 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1325 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001326 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327 //Wait that subs is cleaned
1328 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1329
1330 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001331 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1332 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001333 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1334 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001336 //Wait that subs is cleaned
1337 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1338
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001339 xappConn1.TestMsgChanEmpty(t)
1340 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001341 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001342 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001343}
1344
1345//-----------------------------------------------------------------------------
1346// TestSubReqRetryInSubmgr
1347//
1348// stub stub
1349// +-------+ +---------+ +---------+
1350// | xapp | | submgr | | e2term |
1351// +-------+ +---------+ +---------+
1352// | | |
1353// | SubReq | |
1354// |------------->| |
1355// | | |
1356// | | SubReq |
1357// | |------------->|
1358// | | |
1359// | | |
1360// | | SubReq |
1361// | |------------->|
1362// | | |
1363// | | SubResp |
1364// | |<-------------|
1365// | | |
1366// | SubResp | |
1367// |<-------------| |
1368// | | |
1369// | [SUBS DELETE] |
1370// | | |
1371//
1372//-----------------------------------------------------------------------------
1373
1374func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001375 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001376
1377 // Init counter check
1378 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1379 Counter{cSubReqFromXapp, 1},
1380 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001381 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001382 Counter{cSubReReqToE2, 1},
1383 Counter{cSubRespFromE2, 1},
1384 Counter{cSubRespToXapp, 1},
1385 Counter{cSubDelReqFromXapp, 1},
1386 Counter{cSubDelReqToE2, 1},
1387 Counter{cSubDelRespFromE2, 1},
1388 Counter{cSubDelRespToXapp, 1},
1389 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001390
1391 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001392 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001393
1394 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001395 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001396
1397 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001398 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1399 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001400
1401 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001402 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001403
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001404 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001405 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1406 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001407 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001408
1409 // Wait that subs is cleaned
1410 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1411
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001412 xappConn1.TestMsgChanEmpty(t)
1413 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001414 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001415 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001416
1417 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001418}
1419
1420//-----------------------------------------------------------------------------
1421// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1422//
1423// stub stub
1424// +-------+ +---------+ +---------+
1425// | xapp | | submgr | | e2term |
1426// +-------+ +---------+ +---------+
1427// | | |
1428// | SubReq | |
1429// |------------->| |
1430// | | |
1431// | | SubReq |
1432// | |------------->|
1433// | | |
1434// | | |
1435// | | SubReq |
1436// | |------------->|
1437// | | |
1438// | | SubDelReq |
1439// | |------------->|
1440// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001441// | | SubDelResp |
1442// | |<-------------|
1443// | | |
1444//
1445//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001446func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001447 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001448
1449 // Init counter check
1450 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1451 Counter{cSubReqFromXapp, 1},
1452 Counter{cSubReqToE2, 1},
1453 Counter{cSubReReqToE2, 1},
1454 Counter{cSubReqTimerExpiry, 2},
1455 Counter{cSubDelReqToE2, 1},
1456 Counter{cSubDelRespFromE2, 1},
1457 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001458
1459 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001460 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001461
1462 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001463 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001464
1465 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001466 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001467
1468 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001469 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1470 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001471
1472 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001473 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001474
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001475 xappConn1.TestMsgChanEmpty(t)
1476 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001477 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001478 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001479
1480 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001481}
1482
1483//-----------------------------------------------------------------------------
1484// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1485//
1486// stub stub
1487// +-------+ +---------+ +---------+
1488// | xapp | | submgr | | e2term |
1489// +-------+ +---------+ +---------+
1490// | | |
1491// | SubReq | |
1492// |------------->| |
1493// | | |
1494// | | SubReq |
1495// | |------------->|
1496// | | |
1497// | | |
1498// | | SubReq |
1499// | |------------->|
1500// | | |
1501// | | SubDelReq |
1502// | |------------->|
1503// | | |
1504// | | |
1505// | | SubDelReq |
1506// | |------------->|
1507// | | |
1508// | | |
1509//
1510//-----------------------------------------------------------------------------
1511
1512func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001513 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001514
1515 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1516 Counter{cSubReqFromXapp, 1},
1517 Counter{cSubReqToE2, 1},
1518 Counter{cSubReReqToE2, 1},
1519 Counter{cSubReqTimerExpiry, 2},
1520 Counter{cSubDelReqToE2, 1},
1521 Counter{cSubDelReReqToE2, 1},
1522 Counter{cSubDelReqTimerExpiry, 2},
1523 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001524
1525 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001526 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001527
1528 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001529 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001530
1531 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001532 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001533
1534 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001535 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001536
1537 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001538 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001539
1540 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001541 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001542
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001543 xappConn1.TestMsgChanEmpty(t)
1544 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001545 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001546 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001547
1548 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001549}
1550
1551//-----------------------------------------------------------------------------
1552// TestSubReqSubFailRespInSubmgr
1553//
1554// stub stub
1555// +-------+ +---------+ +---------+
1556// | xapp | | submgr | | e2term |
1557// +-------+ +---------+ +---------+
1558// | | |
1559// | SubReq | |
1560// |------------->| |
1561// | | |
1562// | | SubReq |
1563// | |------------->|
1564// | | |
1565// | | SubFail |
1566// | |<-------------|
1567// | | |
1568// | SubFail | |
1569// |<-------------| |
1570// | | |
1571//
1572//-----------------------------------------------------------------------------
1573
1574func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001575 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001576
1577 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1578 Counter{cSubReqFromXapp, 1},
1579 Counter{cSubReqToE2, 1},
1580 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001581 Counter{cSubFailToXapp, 1},
1582 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001583
1584 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001585 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001586
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001587 // E2t: Receive SubsReq and send SubsFail (first)
1588 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1589 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1590 fparams1.Set(crereq1)
1591 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1592
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001593 // Xapp: Receive SubsFail
1594 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1595
1596 // Wait that subs is cleaned
1597 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1598
1599 xappConn1.TestMsgChanEmpty(t)
1600 xappConn2.TestMsgChanEmpty(t)
1601 e2termConn1.TestMsgChanEmpty(t)
1602 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001603
1604 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001605}
1606
1607//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001608// TestSubDelReqRetryInSubmgr
1609//
1610// stub stub
1611// +-------+ +---------+ +---------+
1612// | xapp | | submgr | | e2term |
1613// +-------+ +---------+ +---------+
1614// | | |
1615// | [SUBS CREATE] |
1616// | | |
1617// | | |
1618// | SubDelReq | |
1619// |------------->| |
1620// | | |
1621// | | SubDelReq |
1622// | |------------->|
1623// | | |
1624// | | SubDelReq |
1625// | |------------->|
1626// | | |
1627// | | SubDelResp |
1628// | |<-------------|
1629// | | |
1630// | SubDelResp | |
1631// |<-------------| |
1632//
1633//-----------------------------------------------------------------------------
1634
1635func TestSubDelReqRetryInSubmgr(t *testing.T) {
1636
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001637 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001638
1639 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001640 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001641 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1642 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001643 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001644
1645 // Subs Delete
1646 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001647 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001648
1649 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001650 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001651
1652 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001653 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1654 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001655
1656 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001657 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001658
1659 // Wait that subs is cleaned
1660 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1661
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001662 xappConn1.TestMsgChanEmpty(t)
1663 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001664 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001665 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001666}
1667
1668//-----------------------------------------------------------------------------
1669// TestSubDelReqTwoRetriesNoRespInSubmgr
1670//
1671// stub stub
1672// +-------+ +---------+ +---------+
1673// | xapp | | submgr | | e2term |
1674// +-------+ +---------+ +---------+
1675// | | |
1676// | [SUBS CREATE] |
1677// | | |
1678// | | |
1679// | SubDelReq | |
1680// |------------->| |
1681// | | |
1682// | | SubDelReq |
1683// | |------------->|
1684// | | |
1685// | | SubDelReq |
1686// | |------------->|
1687// | | |
1688// | | |
1689// | SubDelResp | |
1690// |<-------------| |
1691//
1692//-----------------------------------------------------------------------------
1693
1694func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1695
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001696 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001697
1698 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001699 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001700 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1701 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001702 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001703
1704 // Subs Delete
1705 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001706 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001707
1708 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001709 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001710
1711 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001712 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001713
1714 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001715 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001716
1717 // Wait that subs is cleaned
1718 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1719
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001720 xappConn1.TestMsgChanEmpty(t)
1721 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001722 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001723 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001724}
1725
1726//-----------------------------------------------------------------------------
1727// TestSubDelReqSubDelFailRespInSubmgr
1728//
1729// stub stub
1730// +-------+ +---------+ +---------+
1731// | xapp | | submgr | | e2term |
1732// +-------+ +---------+ +---------+
1733// | | |
1734// | [SUBS CREATE] |
1735// | | |
1736// | | |
1737// | SubDelReq | |
1738// |------------->| |
1739// | | |
1740// | | SubDelReq |
1741// | |------------->|
1742// | | |
1743// | | SubDelFail |
1744// | |<-------------|
1745// | | |
1746// | SubDelResp | |
1747// |<-------------| |
1748// | | |
1749//
1750//-----------------------------------------------------------------------------
1751
1752func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001753 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001754
1755 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1756 Counter{cSubReqFromXapp, 1},
1757 Counter{cSubReqToE2, 1},
1758 Counter{cSubRespFromE2, 1},
1759 Counter{cSubRespToXapp, 1},
1760 Counter{cSubDelReqFromXapp, 1},
1761 Counter{cSubDelReqToE2, 1},
1762 Counter{cSubDelFailFromE2, 1},
1763 Counter{cSubDelRespToXapp, 1},
1764 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001765
1766 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001767 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001768 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1769 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001770 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001771
1772 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001773 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001774
1775 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001776 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1777 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001778
1779 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001780 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001781
1782 // Wait that subs is cleaned
1783 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1784
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001785 xappConn1.TestMsgChanEmpty(t)
1786 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001787 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001788 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001789
1790 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001791}
1792
1793//-----------------------------------------------------------------------------
1794// TestSubReqAndSubDelOkSameAction
1795//
1796// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001797// +-------+ +-------+ +---------+ +---------+
1798// | xapp2 | | xapp1 | | submgr | | e2term |
1799// +-------+ +-------+ +---------+ +---------+
1800// | | | |
1801// | | | |
1802// | | | |
1803// | | SubReq1 | |
1804// | |------------->| |
1805// | | | |
1806// | | | SubReq1 |
1807// | | |------------->|
1808// | | | SubResp1 |
1809// | | |<-------------|
1810// | | SubResp1 | |
1811// | |<-------------| |
1812// | | | |
1813// | SubReq2 | |
1814// |--------------------------->| |
1815// | | | |
1816// | SubResp2 | |
1817// |<---------------------------| |
1818// | | | |
1819// | | SubDelReq 1 | |
1820// | |------------->| |
1821// | | | |
1822// | | SubDelResp 1 | |
1823// | |<-------------| |
1824// | | | |
1825// | SubDelReq 2 | |
1826// |--------------------------->| |
1827// | | | |
1828// | | | SubDelReq 2 |
1829// | | |------------->|
1830// | | | |
1831// | | | SubDelReq 2 |
1832// | | |------------->|
1833// | | | |
1834// | SubDelResp 2 | |
1835// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001836//
1837//-----------------------------------------------------------------------------
1838func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001839 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001840
Anssi Mannila4abf1802021-01-28 13:06:46 +02001841 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001842 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1843 Counter{cSubReqFromXapp, 2},
1844 Counter{cSubReqToE2, 1},
1845 Counter{cSubRespFromE2, 1},
1846 Counter{cSubRespToXapp, 2},
1847 Counter{cMergedSubscriptions, 1},
1848 Counter{cUnmergedSubscriptions, 1},
1849 Counter{cSubDelReqFromXapp, 2},
1850 Counter{cSubDelReqToE2, 1},
1851 Counter{cSubDelRespFromE2, 1},
1852 Counter{cSubDelRespToXapp, 2},
1853 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001854
Juha Hyttinen3944a222020-01-24 11:51:46 +02001855 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001856 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001857 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001858 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001859 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1860 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001861 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001862
1863 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001864 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001865 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001866 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001867 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001868
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001869 resp, _ := xapp.Subscription.QuerySubscriptions()
1870 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1871 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001872 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001873
Juha Hyttinen3944a222020-01-24 11:51:46 +02001874 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001875 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001876 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001877
1878 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001879 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001880 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1881 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001882 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001883 //Wait that subs is cleaned
1884 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1885
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001886 xappConn1.TestMsgChanEmpty(t)
1887 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001888 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001889 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001890
1891 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001892}
1893
1894//-----------------------------------------------------------------------------
1895// TestSubReqAndSubDelOkSameActionParallel
1896//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001897// stub stub stub
1898// +-------+ +-------+ +---------+ +---------+
1899// | xapp2 | | xapp1 | | submgr | | e2term |
1900// +-------+ +-------+ +---------+ +---------+
1901// | | | |
1902// | | | |
1903// | | | |
1904// | | SubReq1 | |
1905// | |------------->| |
1906// | | | |
1907// | | | SubReq1 |
1908// | | |------------->|
1909// | SubReq2 | |
1910// |--------------------------->| |
1911// | | | SubResp1 |
1912// | | |<-------------|
1913// | | SubResp1 | |
1914// | |<-------------| |
1915// | | | |
1916// | SubResp2 | |
1917// |<---------------------------| |
1918// | | | |
1919// | | SubDelReq 1 | |
1920// | |------------->| |
1921// | | | |
1922// | | SubDelResp 1 | |
1923// | |<-------------| |
1924// | | | |
1925// | SubDelReq 2 | |
1926// |--------------------------->| |
1927// | | | |
1928// | | | SubDelReq 2 |
1929// | | |------------->|
1930// | | | |
1931// | | | SubDelReq 2 |
1932// | | |------------->|
1933// | | | |
1934// | SubDelResp 2 | |
1935// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001936//
1937//-----------------------------------------------------------------------------
1938func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001939 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001940
1941 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001942 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001943 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001944 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001945 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001946
1947 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001948 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001949 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001950 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001951
1952 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001953 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001954 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001955
1956 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001957 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001958
1959 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001960 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1961 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001962
1963 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001964 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001965 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1966 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001967 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001968
1969 //Wait that subs is cleaned
1970 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1971
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001972 xappConn1.TestMsgChanEmpty(t)
1973 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001974 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001975 mainCtrl.wait_registry_empty(t, 10)
1976}
1977
1978//-----------------------------------------------------------------------------
1979// TestSubReqAndSubDelNokSameActionParallel
1980//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001981// stub stub stub
1982// +-------+ +-------+ +---------+ +---------+
1983// | xapp2 | | xapp1 | | submgr | | e2term |
1984// +-------+ +-------+ +---------+ +---------+
1985// | | | |
1986// | | | |
1987// | | | |
1988// | | SubReq1 | |
1989// | |------------->| |
1990// | | | |
1991// | | | SubReq1 |
1992// | | |------------->|
1993// | SubReq2 | |
1994// |--------------------------->| |
1995// | | | SubFail1 |
1996// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001997// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001998// | | SubFail1 | |
1999// | |<-------------| |
2000// | | | |
2001// | SubFail2 | |
2002// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02002003//
2004//-----------------------------------------------------------------------------
2005func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002006 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002007
2008 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002009 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002010 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002011 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002012
2013 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002014 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002015
2016 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002017 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002018 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002019 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002020 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002021 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002022
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002023 // E2t: send SubsFail (first)
2024 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2025 fparams1.Set(crereq1)
2026 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2027
Juha Hyttinen3944a222020-01-24 11:51:46 +02002028 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002029 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002030 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002031 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002032
2033 //Wait that subs is cleaned
2034 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
2035
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002036 xappConn1.TestMsgChanEmpty(t)
2037 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002038 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002039 mainCtrl.wait_registry_empty(t, 10)
2040}
2041
2042//-----------------------------------------------------------------------------
2043// TestSubReqAndSubDelNoAnswerSameActionParallel
2044//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002045// stub stub stub
2046// +-------+ +-------+ +---------+ +---------+
2047// | xapp2 | | xapp1 | | submgr | | e2term |
2048// +-------+ +-------+ +---------+ +---------+
2049// | | | |
2050// | | | |
2051// | | | |
2052// | | SubReq1 | |
2053// | |------------->| |
2054// | | | |
2055// | | | SubReq1 |
2056// | | |------------->|
2057// | | SubReq2 | |
2058// |--------------------------->| |
2059// | | | |
2060// | | | SubReq1 |
2061// | | |------------->|
2062// | | | |
2063// | | | |
2064// | | | SubDelReq |
2065// | | |------------->|
2066// | | | |
2067// | | | SubDelResp |
2068// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02002069//
2070//-----------------------------------------------------------------------------
2071func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002072 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002073
2074 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002075 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002076 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002077 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002078
Juha Hyttinen1683f912020-04-17 10:39:57 +03002079 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002080
2081 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002082 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002083 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002084 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002085 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002086 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002087
2088 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002089 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002090
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002091 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2092 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002093
2094 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002095 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002096
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002097 xappConn1.TestMsgChanEmpty(t)
2098 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002099 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002100 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002101}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002102
2103//----------------------------- Policy cases ---------------------------------
2104//-----------------------------------------------------------------------------
2105// TestSubReqPolicyAndSubDelOk
2106//
2107// stub stub
2108// +-------+ +---------+ +---------+
2109// | xapp | | submgr | | e2term |
2110// +-------+ +---------+ +---------+
2111// | | |
2112// | SubReq | |
2113// |------------->| |
2114// | | |
2115// | | SubReq |
2116// | |------------->|
2117// | | |
2118// | | SubResp |
2119// | |<-------------|
2120// | | |
2121// | SubResp | |
2122// |<-------------| |
2123// | | |
2124// | | |
2125// | SubDelReq | |
2126// |------------->| |
2127// | | |
2128// | | SubDelReq |
2129// | |------------->|
2130// | | |
2131// | | SubDelResp |
2132// | |<-------------|
2133// | | |
2134// | SubDelResp | |
2135// |<-------------| |
2136//
2137//-----------------------------------------------------------------------------
2138func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2139 CaseBegin("TestSubReqAndSubDelOk")
2140
2141 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2142 rparams1.Init()
2143 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2144 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2145
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002146 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2147 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002148 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2149 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002150 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002151
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002152 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002153 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002154
2155 //Wait that subs is cleaned
2156 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2157
2158 xappConn1.TestMsgChanEmpty(t)
2159 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002160 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002161 mainCtrl.wait_registry_empty(t, 10)
2162}
2163
2164//-----------------------------------------------------------------------------
2165// TestSubReqPolicyChangeAndSubDelOk
2166//
2167// stub stub
2168// +-------+ +---------+ +---------+
2169// | xapp | | submgr | | e2term |
2170// +-------+ +---------+ +---------+
2171// | | |
2172// | SubReq | |
2173// |------------->| |
2174// | | |
2175// | | SubReq |
2176// | |------------->|
2177// | | |
2178// | | SubResp |
2179// | |<-------------|
2180// | | |
2181// | SubResp | |
2182// |<-------------| |
2183// | | |
2184// | SubReq | |
2185// |------------->| |
2186// | | |
2187// | | SubReq |
2188// | |------------->|
2189// | | |
2190// | | SubResp |
2191// | |<-------------|
2192// | | |
2193// | SubResp | |
2194// |<-------------| |
2195// | | |
2196// | SubDelReq | |
2197// |------------->| |
2198// | | |
2199// | | SubDelReq |
2200// | |------------->|
2201// | | |
2202// | | SubDelResp |
2203// | |<-------------|
2204// | | |
2205// | SubDelResp | |
2206// |<-------------| |
2207//
2208//-----------------------------------------------------------------------------
2209
2210func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2211 CaseBegin("TestSubReqAndSubDelOk")
2212
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002213 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2214 rparams1.Init()
2215 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2216 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002217
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002218 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2219 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002220 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2221
2222 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002223 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002224 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2225 xappConn1.SendSubsReq(t, rparams1, cretrans)
2226
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002227 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2228 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002229 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2230 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002231 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002232
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002233 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002234 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002235
2236 //Wait that subs is cleaned
2237 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2238
2239 xappConn1.TestMsgChanEmpty(t)
2240 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002241 e2termConn1.TestMsgChanEmpty(t)
2242 mainCtrl.wait_registry_empty(t, 10)
2243}
2244
2245//-----------------------------------------------------------------------------
2246// TestSubReqAndSubDelOkTwoE2termParallel
2247//
2248// stub stub stub
2249// +-------+ +---------+ +---------+ +---------+
2250// | xapp | | submgr | | e2term1 | | e2term2 |
2251// +-------+ +---------+ +---------+ +---------+
2252// | | | |
2253// | | | |
2254// | | | |
2255// | SubReq1 | | |
2256// |------------->| | |
2257// | | | |
2258// | | SubReq1 | |
2259// | |------------->| |
2260// | | | |
2261// | SubReq2 | | |
2262// |------------->| | |
2263// | | | |
2264// | | SubReq2 | |
2265// | |---------------------------->|
2266// | | | |
2267// | | SubResp1 | |
2268// | |<-------------| |
2269// | SubResp1 | | |
2270// |<-------------| | |
2271// | | SubResp2 | |
2272// | |<----------------------------|
2273// | SubResp2 | | |
2274// |<-------------| | |
2275// | | | |
2276// | [SUBS 1 DELETE] | |
2277// | | | |
2278// | [SUBS 2 DELETE] | |
2279// | | | |
2280//
2281//-----------------------------------------------------------------------------
2282func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2283 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2284
2285 //Req1
2286 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2287 xappConn1.SendSubsReq(t, nil, cretrans1)
2288 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2289
2290 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2291 xappConn1.SendSubsReq(t, nil, cretrans2)
2292 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2293
2294 //Resp1
2295 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2296 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2297
2298 //Resp2
2299 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2300 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2301
2302 //Del1
2303 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2304 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2305 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2306 xappConn1.RecvSubsDelResp(t, deltrans1)
2307 //Wait that subs is cleaned
2308 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2309
2310 //Del2
2311 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2312 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2313 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2314 xappConn1.RecvSubsDelResp(t, deltrans2)
2315 //Wait that subs is cleaned
2316 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2317
2318 xappConn1.TestMsgChanEmpty(t)
2319 xappConn2.TestMsgChanEmpty(t)
2320 e2termConn1.TestMsgChanEmpty(t)
2321 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002322 mainCtrl.wait_registry_empty(t, 10)
2323}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002324
2325//-----------------------------------------------------------------------------
2326// TestSubReqInsertAndSubDelOk
2327//
2328// stub stub
2329// +-------+ +---------+ +---------+
2330// | xapp | | submgr | | e2term |
2331// +-------+ +---------+ +---------+
2332// | | |
2333// | SubReq | |
2334// |------------->| |
2335// | | |
2336// | | SubReq |
2337// | |------------->|
2338// | | |
2339// | | SubResp |
2340// | |<-------------|
2341// | | |
2342// | SubResp | |
2343// |<-------------| |
2344// | | |
2345// | | |
2346// | SubDelReq | |
2347// |------------->| |
2348// | | |
2349// | | SubDelReq |
2350// | |------------->|
2351// | | |
2352// | | SubDelResp |
2353// | |<-------------|
2354// | | |
2355// | SubDelResp | |
2356// |<-------------| |
2357//
2358//-----------------------------------------------------------------------------
2359func TestSubReqInsertAndSubDelOk(t *testing.T) {
2360 CaseBegin("TestInsertSubReqAndSubDelOk")
2361
2362 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2363 rparams1.Init()
2364 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2365 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2366
2367 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2368 e2termConn1.SendSubsResp(t, crereq, cremsg)
2369 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2370 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2371 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2372
2373 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2374 xappConn1.RecvSubsDelResp(t, deltrans)
2375
2376 //Wait that subs is cleaned
2377 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2378
2379 xappConn1.TestMsgChanEmpty(t)
2380 xappConn2.TestMsgChanEmpty(t)
2381 e2termConn1.TestMsgChanEmpty(t)
2382 mainCtrl.wait_registry_empty(t, 10)
2383}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002384
2385//-----------------------------------------------------------------------------
2386// TestSubReqRetransmissionWithSameSubIdDiffXid
2387//
2388// This case simulates case where xApp restarts and starts sending same
2389// subscription requests which have already subscribed successfully
2390
2391// stub stub
2392// +-------+ +---------+ +---------+
2393// | xapp | | submgr | | e2term |
2394// +-------+ +---------+ +---------+
2395// | | |
2396// | SubReq | |
2397// |------------->| |
2398// | | |
2399// | | SubReq |
2400// | |------------->|
2401// | | |
2402// | | SubResp |
2403// | |<-------------|
2404// | | |
2405// | SubResp | |
2406// |<-------------| |
2407// | | |
2408// | xApp restart | |
2409// | | |
2410// | SubReq | |
2411// | (retrans with same xApp generated subid but diff xid)
2412// |------------->| |
2413// | | |
2414// | SubResp | |
2415// |<-------------| |
2416// | | |
2417// | [SUBS DELETE] |
2418// | | |
2419//
2420//-----------------------------------------------------------------------------
2421func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2422 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2423
2424 //Subs Create
2425 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2426 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2427 e2termConn1.SendSubsResp(t, crereq, cremsg)
2428 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2429
2430 // xApp restart here
2431 // --> artificial delay
2432 <-time.After(1 * time.Second)
2433
2434 //Subs Create
2435 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2436 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2437
2438 //Subs Delete
2439 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2440 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2441 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2442 xappConn1.RecvSubsDelResp(t, deltrans)
2443
2444 //Wait that subs is cleaned
2445 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2446
2447 xappConn1.TestMsgChanEmpty(t)
2448 xappConn2.TestMsgChanEmpty(t)
2449 e2termConn1.TestMsgChanEmpty(t)
2450 mainCtrl.wait_registry_empty(t, 10)
2451}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002452
2453//-----------------------------------------------------------------------------
2454// TestSubReqNokAndSubDelOkWithRestartInMiddle
2455//
2456// stub stub
2457// +-------+ +---------+ +---------+
2458// | xapp | | submgr | | e2term |
2459// +-------+ +---------+ +---------+
2460// | | |
2461// | SubReq | |
2462// |------------->| |
2463// | | |
2464// | | SubReq |
2465// | |------------->|
2466// | | |
2467// | | SubResp |
2468// | <----|
2469// | |
2470// | Submgr restart |
2471// | |
2472// | | |
2473// | | SubDelReq |
2474// | |------------->|
2475// | | |
2476// | | SubDelResp |
2477// | |<-------------|
2478// | | |
2479//
2480//-----------------------------------------------------------------------------
2481
2482func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2483 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2484
Anssi Mannilac92b4212020-12-07 14:59:34 +02002485 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2486 xappConn1.SendSubsReq(t, nil, nil)
2487 e2termConn1.RecvSubsReq(t)
2488 mainCtrl.SetResetTestFlag(t, false)
2489
2490 resp, _ := xapp.Subscription.QuerySubscriptions()
2491 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002492 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002493 e2SubsId := uint32(resp[0].SubscriptionID)
2494 t.Logf("e2SubsId = %v", e2SubsId)
2495
archaggeafbf95f2021-04-14 08:54:05 +03002496 mainCtrl.SimulateRestart(t)
2497 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002498
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002499 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002500 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2501 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2502
2503 // Wait that subs is cleaned
2504 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2505
2506 xappConn1.TestMsgChanEmpty(t)
2507 xappConn2.TestMsgChanEmpty(t)
2508 e2termConn1.TestMsgChanEmpty(t)
2509 mainCtrl.wait_registry_empty(t, 10)
2510}
2511
2512//-----------------------------------------------------------------------------
2513// TestSubReqAndSubDelOkWithRestartInMiddle
2514//
2515// stub stub
2516// +-------+ +---------+ +---------+
2517// | xapp | | submgr | | e2term |
2518// +-------+ +---------+ +---------+
2519// | | |
2520// | SubReq | |
2521// |------------->| |
2522// | | |
2523// | | SubReq |
2524// | |------------->|
2525// | | |
2526// | | SubResp |
2527// | |<-------------|
2528// | | |
2529// | SubResp | |
2530// |<-------------| |
2531// | | |
2532// | |
2533// | Submgr restart |
2534// | |
2535// | SubDelReq | |
2536// |------------->| |
2537// | | |
2538// | | SubDelReq |
2539// | |------------->|
2540// | | |
2541// | | SubDelResp |
2542// | |<-------------|
2543// | | |
2544// | SubDelResp | |
2545// |<-------------| |
2546//
2547//-----------------------------------------------------------------------------
2548
2549func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2550 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2551
2552 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2553 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2554 e2termConn1.SendSubsResp(t, crereq, cremsg)
2555 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2556
2557 // Check subscription
2558 resp, _ := xapp.Subscription.QuerySubscriptions()
2559 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2560 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002561 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002562
2563 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002564 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002565
Anssi Mannila54838ed2021-11-19 11:25:01 +02002566 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2567 // That needs to be completed before successful subscription query is possible
2568 <-time.After(time.Second * 1)
2569
Anssi Mannilac92b4212020-12-07 14:59:34 +02002570 // Check that subscription is restored correctly after restart
2571 resp, _ = xapp.Subscription.QuerySubscriptions()
2572 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2573 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002574 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002575
2576 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2577 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2578 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2579 xappConn1.RecvSubsDelResp(t, deltrans)
2580
2581 //Wait that subs is cleaned
2582 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2583
2584 xappConn1.TestMsgChanEmpty(t)
2585 xappConn2.TestMsgChanEmpty(t)
2586 e2termConn1.TestMsgChanEmpty(t)
2587 mainCtrl.wait_registry_empty(t, 10)
2588}
2589
2590//-----------------------------------------------------------------------------
2591// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2592//
2593// stub stub
2594// +-------+ +-------+ +---------+ +---------+
2595// | xapp2 | | xapp1 | | submgr | | e2term |
2596// +-------+ +-------+ +---------+ +---------+
2597// | | | |
2598// | | | |
2599// | | | |
2600// | | SubReq1 | |
2601// | |------------->| |
2602// | | | |
2603// | | | SubReq1 |
2604// | | |------------->|
2605// | | | SubResp1 |
2606// | | |<-------------|
2607// | | SubResp1 | |
2608// | |<-------------| |
2609// | | | |
2610// | |
2611// | submgr restart |
2612// | |
2613// | | | |
2614// | | | |
2615// | SubReq2 | |
2616// |--------------------------->| |
2617// | | | |
2618// | SubResp2 | |
2619// |<---------------------------| |
2620// | | | |
2621// | | SubDelReq 1 | |
2622// | |------------->| |
2623// | | | |
2624// | | SubDelResp 1 | |
2625// | |<-------------| |
2626// | | | |
2627// | | | |
2628// | |
2629// | submgr restart |
2630// | |
2631// | | | |
2632// | SubDelReq 2 | |
2633// |--------------------------->| |
2634// | | | |
2635// | | | SubDelReq 2 |
2636// | | |------------->|
2637// | | | |
2638// | | | SubDelReq 2 |
2639// | | |------------->|
2640// | | | |
2641// | SubDelResp 2 | |
2642// |<---------------------------| |
2643//
2644//-----------------------------------------------------------------------------
2645
2646func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2647 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2648
2649 //Req1
2650 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2651 rparams1.Init()
2652 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2653 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2654 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2655 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2656
2657 //Req2
2658 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2659 rparams2.Init()
2660 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2661 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2662
2663 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002664 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002665 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2666 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002667 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002668
2669 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002670 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002671
Anssi Mannila54838ed2021-11-19 11:25:01 +02002672 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2673 // That needs to be completed before successful subscription query is possible
2674 <-time.After(time.Second * 1)
2675
Anssi Mannilac92b4212020-12-07 14:59:34 +02002676 // Check that subscription is restored correctly after restart
2677 resp, _ = xapp.Subscription.QuerySubscriptions()
2678 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2679 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002680 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002681
2682 //Del1
2683 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2684 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2685 xappConn1.RecvSubsDelResp(t, deltrans1)
2686 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2687
2688 mainCtrl.SimulateRestart(t)
2689 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2690
Anssi Mannila54838ed2021-11-19 11:25:01 +02002691 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2692 // Submgr need be ready before successful subscription deletion is possible
2693 <-time.After(time.Second * 1)
2694
Anssi Mannilac92b4212020-12-07 14:59:34 +02002695 //Del2
2696 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2697 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2698
2699 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2700 xappConn2.RecvSubsDelResp(t, deltrans2)
2701
2702 //Wait that subs is cleaned
2703 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2704
2705 xappConn1.TestMsgChanEmpty(t)
2706 xappConn2.TestMsgChanEmpty(t)
2707 e2termConn1.TestMsgChanEmpty(t)
2708 mainCtrl.wait_registry_empty(t, 10)
2709}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002710
archaggeafbf95f2021-04-14 08:54:05 +03002711//*****************************************************************************
2712// REST interface test cases
2713//*****************************************************************************
2714
Anssi Mannila47518ae2021-04-16 09:27:07 +03002715//-----------------------------------------------------------------------------
2716// Test debug GET and POST requests
2717//
2718// curl
2719// +-------+ +---------+
2720// | user | | submgr |
2721// +-------+ +---------+
2722// | |
2723// | GET/POST Req |
2724// |------------->|
2725// | Resp |
2726// |<-------------|
2727// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002728func TestGetSubscriptions(t *testing.T) {
2729
Anssi Mannila92c38552021-12-29 09:59:24 +02002730 mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002731}
2732
2733func TestGetSymptomData(t *testing.T) {
2734
Anssi Mannila92c38552021-12-29 09:59:24 +02002735 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002736}
2737
2738func TestPostdeleteSubId(t *testing.T) {
2739
Anssi Mannila92c38552021-12-29 09:59:24 +02002740 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002741}
2742
2743func TestPostEmptyDb(t *testing.T) {
2744
Anssi Mannila92c38552021-12-29 09:59:24 +02002745 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002746}
archaggeafbf95f2021-04-14 08:54:05 +03002747
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002748func TestGetRestSubscriptions(t *testing.T) {
2749
Anssi Mannila92c38552021-12-29 09:59:24 +02002750 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2751}
2752
2753//-----------------------------------------------------------------------------
2754// TestDelAllE2nodeSubsViaDebugIf
2755//
2756// stub stub stub
2757// +-------+ +---------+ +---------+ +---------+
2758// | xapp | | submgr | | e2term | | rtmgr |
2759// +-------+ +---------+ +---------+ +---------+
2760// | | | |
2761// | RESTSubReq | | |
2762// |---------------->| | |
2763// | RESTSubResp | | |
2764// |<----------------| | |
2765// | | RouteCreate | |
2766// | |--------------------------->|
2767// | | RouteResponse| |
2768// | |<---------------------------|
2769// | | SubReq | |
2770// | |------------->| |
2771// | | SubResp | |
2772// | |<-------------| |
2773// | RESTNotif1 | | |
2774// |<----------------| | |
2775// | | | |
2776// | REST get_all_e2nodes | |
2777// |---------------->| | |
2778// | OK 200 | | |
2779// |<----------------| | |
2780// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1
2781// |---------------->| | |
2782// | OK 200 | | |
2783// |<----------------| | |
2784// | | SubDelReq | |
2785// | |------------->| |
2786// | | SubDelResp | |
2787// | |<-------------| |
2788// | | | |
2789// | | RouteDelete | |
2790// | |--------------------------->|
2791// | | RouteResponse| |
2792// | |<---------------------------|
2793//
2794//-----------------------------------------------------------------------------
2795
2796func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
2797
2798 // Init counter check
2799 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2800 Counter{cRestSubReqFromXapp, 1},
2801 Counter{cRestSubRespToXapp, 1},
2802 Counter{cSubReqToE2, 1},
2803 Counter{cSubRespFromE2, 1},
2804 Counter{cRestSubNotifToXapp, 1},
2805 Counter{cRestSubDelReqFromXapp, 1},
2806 Counter{cSubDelReqToE2, 1},
2807 Counter{cSubDelRespFromE2, 1},
2808 Counter{cRestSubDelRespToXapp, 1},
2809 })
2810
2811 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2812 restSubId := xappConn1.SendRESTSubsReq(t, params)
2813 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2814
2815 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2816 xappConn1.ExpectRESTNotification(t, restSubId)
2817 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2818 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2819 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2820
2821 e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes")
2822
2823 var e2nodesList []string
2824 err := json.Unmarshal(e2nodesJson, &e2nodesList)
2825 if err != nil {
2826 t.Errorf("Unmarshal error: %s", err)
2827 }
2828 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList))
2829
2830 e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2831 var e2RestSubsMap map[string]RESTSubscription
2832 err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap)
2833 if err != nil {
2834 t.Errorf("Unmarshal error: %s", err)
2835 }
2836
2837 if len(e2RestSubsMap) != 1 {
2838 t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap))
2839 }
2840
2841 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002842 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 +02002843 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2844 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2845
2846 // Wait that subs is cleaned
2847 waitSubsCleanup(t, e2SubsId, 10)
2848 mainCtrl.VerifyCounterValues(t)
2849 mainCtrl.VerifyAllClean(t)
2850}
2851
2852//-----------------------------------------------------------------------------
2853// TestDelAllxAppSubsViaDebugIf
2854//
2855// stub stub stub
2856// +-------+ +---------+ +---------+ +---------+
2857// | xapp | | submgr | | e2term | | rtmgr |
2858// +-------+ +---------+ +---------+ +---------+
2859// | | | |
2860// | RESTSubReq | | |
2861// |---------------->| | |
2862// | RESTSubResp | | |
2863// |<----------------| | |
2864// | | RouteCreate | |
2865// | |--------------------------->|
2866// | | RouteResponse| |
2867// | |<---------------------------|
2868// | | SubReq | |
2869// | |------------->| |
2870// | | SubResp | |
2871// | |<-------------| |
2872// | RESTNotif1 | | |
2873// |<----------------| | |
2874// | | | |
2875// | REST get_all_xapps | |
2876// |---------------->| | |
2877// | OK 200 | | |
2878// |<----------------| | |
2879// | REST delete_all_xapp_subscriptions | xappServiceName = localhost
2880// |---------------->| | |
2881// | OK 200 | | |
2882// |<----------------| | |
2883// | | SubDelReq | |
2884// | |------------->| |
2885// | | SubDelResp | |
2886// | |<-------------| |
2887// | | | |
2888// | | RouteDelete | |
2889// | |--------------------------->|
2890// | | RouteResponse| |
2891// | |<---------------------------|
2892//
2893//-----------------------------------------------------------------------------
2894
2895func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
2896
2897 // Init counter check
2898 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2899 Counter{cRestSubReqFromXapp, 1},
2900 Counter{cRestSubRespToXapp, 1},
2901 Counter{cSubReqToE2, 1},
2902 Counter{cSubRespFromE2, 1},
2903 Counter{cRestSubNotifToXapp, 1},
2904 Counter{cRestSubDelReqFromXapp, 1},
2905 Counter{cSubDelReqToE2, 1},
2906 Counter{cSubDelRespFromE2, 1},
2907 Counter{cRestSubDelRespToXapp, 1},
2908 })
2909
2910 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2911 restSubId := xappConn1.SendRESTSubsReq(t, params)
2912 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2913
2914 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2915 xappConn1.ExpectRESTNotification(t, restSubId)
2916 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2917 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2918 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2919
2920 xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps")
2921
2922 var xappList []string
2923 err := json.Unmarshal(xappsJson, &xappList)
2924 if err != nil {
2925 t.Errorf("Unmarshal error: %s", err)
2926 }
2927 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
2928
2929 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002930 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
Anssi Mannila92c38552021-12-29 09:59:24 +02002931 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2932 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2933
2934 // Wait that subs is cleaned
2935 waitSubsCleanup(t, e2SubsId, 10)
2936 mainCtrl.VerifyCounterValues(t)
2937 mainCtrl.VerifyAllClean(t)
2938}
2939
2940//-----------------------------------------------------------------------------
2941// TestDelViaxAppSubsIf
2942//
2943// stub stub stub
2944// +-------+ +---------+ +---------+ +---------+
2945// | xapp | | submgr | | e2term | | rtmgr |
2946// +-------+ +---------+ +---------+ +---------+
2947// | | | |
2948// | RESTSubReq | | |
2949// |---------------->| | |
2950// | RESTSubResp | | |
2951// |<----------------| | |
2952// | | RouteCreate | |
2953// | |--------------------------->|
2954// | | RouteResponse| |
2955// | |<---------------------------|
2956// | | SubReq | |
2957// | |------------->| |
2958// | | SubResp | |
2959// | |<-------------| |
2960// | RESTNotif1 | | |
2961// |<----------------| | |
2962// | | | |
2963// | REST get_xapp_rest_restsubscriptions |
2964// |---------------->| | |
2965// | OK 200 | | |
2966// |<----------------| | |
2967// | RESTSudDel | | |
2968// |---------------->| | | Via user curl command (port 8088)
2969// | RESTSudDel | | |
2970// |<----------------| | |
2971// | | SubDelReq | |
2972// | |------------->| |
2973// | | SubDelResp | |
2974// | |<-------------| |
2975// | | | |
2976// | | RouteDelete | |
2977// | |--------------------------->|
2978// | | RouteResponse| |
2979// | |<---------------------------|
2980//
2981//-----------------------------------------------------------------------------
2982
2983func TestDelViaxAppSubsIf(t *testing.T) {
2984
2985 // Init counter check
2986 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2987 Counter{cRestSubReqFromXapp, 1},
2988 Counter{cRestSubRespToXapp, 1},
2989 Counter{cSubReqToE2, 1},
2990 Counter{cSubRespFromE2, 1},
2991 Counter{cRestSubNotifToXapp, 1},
2992 Counter{cRestSubDelReqFromXapp, 1},
2993 Counter{cSubDelReqToE2, 1},
2994 Counter{cSubDelRespFromE2, 1},
2995 Counter{cRestSubDelRespToXapp, 1},
2996 })
2997
2998 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2999 restSubId := xappConn1.SendRESTSubsReq(t, params)
3000 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3001
3002 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3003 xappConn1.ExpectRESTNotification(t, restSubId)
3004 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3005 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3006 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
3007
3008 restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName
3009
3010 var restSubsMap map[string]RESTSubscription
3011 err := json.Unmarshal(restSubsListJson, &restSubsMap)
3012 if err != nil {
3013 t.Errorf("Unmarshal error: %s", err)
3014 }
3015 _, ok := restSubsMap[restSubId]
3016 if !ok {
3017 t.Errorf("REST subscription not found. restSubId=%s", restSubId)
3018 }
3019
3020 var e2Subscriptions []Subscription
3021 e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId)
3022 err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions)
3023 if err != nil {
3024 t.Errorf("Unmarshal error: %s", err)
3025 }
3026 if len(e2Subscriptions) != 1 {
3027 t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions))
3028 }
3029
3030 // Simulate deletion through xapp REST test interface
3031 mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId)
3032 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3033 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3034
3035 // Wait that subs is cleaned
3036 waitSubsCleanup(t, e2SubsId, 10)
3037 mainCtrl.VerifyCounterValues(t)
3038 mainCtrl.VerifyAllClean(t)
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03003039}
3040
archaggeafbf95f2021-04-14 08:54:05 +03003041//-----------------------------------------------------------------------------
3042// TestRESTSubReqAndRouteNok
3043//
3044// stub stub
3045// +-------+ +---------+ +---------+
3046// | xapp | | submgr | | rtmgr |
3047// +-------+ +---------+ +---------+
3048// | | |
3049// | RESTSubReq | |
3050// |---------------->| |
3051// | | |
3052// | RESTSubResp | |
3053// |<----------------| |
3054// | | RouteCreate |
3055// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03003056// | | RouteCreate |
3057// | | status:400 |
3058// | |(Bad request) |
3059// | |<-------------|
3060// | RESTNotif | |
3061// |<----------------| |
3062// | | |
3063// | [SUBS INT DELETE] |
3064// | | |
3065// | RESTSubDelReq | |
3066// |---------------->| |
3067// | RESTSubDelResp | |
3068// |<----------------| |
3069//
3070//-----------------------------------------------------------------------------
3071func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003072
3073 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003074 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003075 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003076 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003077 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003078 Counter{cRestSubDelReqFromXapp, 1},
3079 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003080 })
3081
3082 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003083
Markku Virtanenda34eec2021-05-20 08:22:04 +00003084 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
3085 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03003086 newSubsId := mainCtrl.get_registry_next_subid(t)
3087
3088 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003089 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003090 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003091 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03003092 waiter.WaitResult(t)
3093
archaggeafbf95f2021-04-14 08:54:05 +03003094 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003095 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003096
3097 // Del
3098 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3099
3100 // Wait that subs is cleaned
3101 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3102 waitSubsCleanup(t, e2SubsId, 10)
3103 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003104 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003105}
3106
Anssi Mannila27385172021-12-22 09:41:54 +02003107//-----------------------------------------------------------------------------
3108// TestRESTSubReqAndRouteUpdateNok
3109//
3110// stub stub stub stub
3111// +-------+ +-------+ +---------+ +---------+ +---------+
3112// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3113// +-------+ +-------+ +---------+ +---------+ +---------+
3114// | | | | |
3115// | RESTSubReq1 | | |
3116// |------------------------>| | |
3117// | RESTSubResp2 | | |
3118// |<------------------------| | |
3119// | | | | |
3120// | | | RouteCreate | |
3121// | | |------------->| |
3122// | | | CreateResp | |
3123// | | |<-------------| |
3124// | | | SubReq | |
3125// | | |---------------------------->|
3126// | | | SubResp | |
3127// | | |<----------------------------|
3128// | RESTNotif1 | | |
3129// |<------------------------| | |
3130// | | | | |
3131// | | RESTSubReq2 | | |
3132// | |------------>| | |
3133// | | RESTSubResp2| | |
3134// | |<------------| | |
3135// | | | RouteUpdate | |
3136// | | |------------->| |
3137// | | | RouteUpdate | |
3138// | | | status:400 | |
3139// | | |(Bad request) | |
3140// | | |<-------------| |
3141// | | RESTNotif2(unsuccessful) | |
3142// | |<------------| | |
3143// | | | | |
3144// | [SUBS INT DELETE] | |
3145// | | | | |
3146// | RESTSubDelReq1 | | |
3147// |------------------------>| | |
3148// | RESTSubDelResp1 | | |
3149// |<------------------------| | |
3150// | | | | |
3151// | | | [SUBS DELETE] |
3152//
3153//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003154func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003155
3156 //Init counter check
3157 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003158 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003159 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003160 Counter{cSubReqToE2, 1},
3161 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003162 Counter{cRestSubNotifToXapp, 1},
3163 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003164 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003165 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003166 Counter{cSubDelReqToE2, 1},
3167 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003168 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003169 })
3170
3171 var params *teststube2ap.RESTSubsReqParams = nil
3172
Anssi Mannila27385172021-12-22 09:41:54 +02003173 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03003174 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3175
3176 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3177
3178 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
3179 waiter := rtmgrHttp.AllocNextEvent(false)
3180 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003181 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003182 params.SetMeid("RAN_NAME_1")
3183 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003184 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003185 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003186 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003187 xappConn2.WaitRESTNotification(t, restSubId2)
3188
3189 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3190
3191 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003192 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003193
3194 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3195 //Wait that subs is cleaned
3196 waitSubsCleanup(t, e2SubsId, 10)
3197
3198 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003199 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003200}
3201
Anssi Mannila27385172021-12-22 09:41:54 +02003202//-----------------------------------------------------------------------------
3203// TestRESTSubDelReqAndRouteDeleteNok
3204//
3205// stub stub stub
3206// +-------+ +---------+ +---------+ +---------+
3207// | xapp | | submgr | | rtmgr | | e2term |
3208// +-------+ +---------+ +---------+ +---------+
3209// | | | |
3210// | RESTSubReq | | |
3211// |---------------->| | |
3212// | | | |
3213// | RESTSubResp | | |
3214// |<----------------| | |
3215// | | SubReq | |
3216// | |---------------------------->|
3217// | | SubResp | |
3218// | |<----------------------------|
3219// | RESTNotif | | |
3220// |<----------------| | |
3221// | | | |
3222// | | | |
3223// | RESTSubDelReq | | |
3224// |---------------->| | |
3225// | RESTSubDelResp | | |
3226// |<----------------| | |
3227// | | SubSelReq | |
3228// | |---------------------------->|
3229// | | SubSelResp | |
3230// | |<----------------------------|
3231// | | RouteDelete | |
3232// | |------------->| |
3233// | | Routedelete | |
3234// | | status:400 | |
3235// | |(Bad request) | |
3236// | |<-------------| |
3237//
3238//-----------------------------------------------------------------------------
3239
archaggeafbf95f2021-04-14 08:54:05 +03003240func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003241
3242 // Init counter check
3243 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003244 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003245 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003246 Counter{cSubReqToE2, 1},
3247 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003248 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003249 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003250 Counter{cRouteDeleteFail, 1},
3251 Counter{cSubDelReqToE2, 1},
3252 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003253 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003254 })
3255
3256 var params *teststube2ap.RESTSubsReqParams = nil
3257
3258 //Subs Create
3259 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3260
3261 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3262
3263 waiter := rtmgrHttp.AllocNextEvent(false)
3264 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3265 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3266 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3267 waiter.WaitResult(t)
3268
3269 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003270 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003271 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003272}
3273
Anssi Mannila27385172021-12-22 09:41:54 +02003274//-----------------------------------------------------------------------------
3275// TestRESTSubMergeDelAndRouteUpdateNok
3276//
3277// stub stub stub stub
3278// +-------+ +-------+ +---------+ +---------+ +---------+
3279// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3280// +-------+ +-------+ +---------+ +---------+ +---------+
3281// | | | | |
3282// | RESTSubReq1 | | |
3283// |------------------------>| | |
3284// | RESTSubResp2 | | |
3285// |<------------------------| | |
3286// | | | | |
3287// | | | RouteCreate | |
3288// | | |------------->| |
3289// | | | CreateResp | |
3290// | | |<-------------| |
3291// | | | SubReq | |
3292// | | |---------------------------->|
3293// | | | SubResp | |
3294// | | |<----------------------------|
3295// | RESTNotif1 | | |
3296// |<------------------------| | |
3297// | | | | |
3298// | | RESTSubReq2 | | |
3299// | |------------>| | |
3300// | | RESTSubResp2| | |
3301// | |<------------| | |
3302// | | | RouteCreate | |
3303// | | |------------->| |
3304// | | | CreateResp | |
3305// | | |<-------------| |
3306// | | | SubReq | |
3307// | | |---------------------------->|
3308// | | | SubResp | |
3309// | | |<----------------------------|
3310// | | RESTNotif2 | | |
3311// | |<------------| | |
3312// | | | | |
3313// | [SUBS INT DELETE] | |
3314// | | | | |
3315// | RESTSubDelReq1 | | |
3316// |------------------------>| | |
3317// | RESTSubDelResp1 | | |
3318// |<------------------------| | |
3319// | | | SubDelReq | |
3320// | | |---------------------------->|
3321// | | | SubDelResp | |
3322// | | |<----------------------------|
3323// | | | RouteUpdate | |
3324// | | |------------->| |
3325// | | | RouteUpdate | |
3326// | | | status:400 | |
3327// | | |(Bad request) | |
3328// | | |<-------------| |
3329// | | | | |
3330// | | RESTSubDelReq2 | |
3331// | |------------>| | |
3332// | | RESTSubDelResp2 | |
3333// | |<------------| | |
3334// | | | SubDelReq | |
3335// | | |---------------------------->|
3336// | | | SubdelResp | |
3337// | | |<----------------------------|
3338// | | | RouteDelete | |
3339// | | |------------->| |
3340// | | | Deleteresp | |
3341// | | |<-------------| |
3342
3343//-----------------------------------------------------------------------------
3344
archaggeafbf95f2021-04-14 08:54:05 +03003345func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003346
3347 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003348 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003349 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003350 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003351 Counter{cSubReqToE2, 1},
3352 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003353 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003354 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003355 Counter{cRouteDeleteUpdateFail, 1},
3356 Counter{cSubDelReqToE2, 1},
3357 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003358 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003359 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003360 })
3361
3362 var params *teststube2ap.RESTSubsReqParams = nil
3363
3364 //Subs Create
3365 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3366
3367 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3368 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
3369
3370 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3371
3372 //Del1, this shall fail on rtmgr side
3373 waiter := rtmgrHttp.AllocNextEvent(false)
3374 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3375 waiter.WaitResult(t)
3376
3377 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
3378
3379 //Del2
3380 deleteXapp2Subscription(t, &restSubId2)
3381
3382 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003383 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003384 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003385}
3386
3387//-----------------------------------------------------------------------------
3388// TestRESTSubReqRetransmission
3389//
3390// stub stub
3391// +-------+ +---------+ +---------+
3392// | xapp | | submgr | | e2term |
3393// +-------+ +---------+ +---------+
3394// | | |
3395// | RESTSubReq1 | |
3396// |---------------->| |
3397// | | |
3398// | RESTSubResp | |
3399// |<----------------| |
3400// | | SubReq1 |
3401// | |------------->|
3402// | | |
3403// | RESTSubReq2 | |
3404// | (retrans) | |
3405// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003406// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003407// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003408// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003409// | | SubResp1 |
3410// | |<-------------|
3411// | RESTNotif1 | |
3412// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003413// | | |
3414// | [SUBS DELETE] |
3415// | | |
3416//
3417//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003418
archaggeafbf95f2021-04-14 08:54:05 +03003419func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003420
3421 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003422 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003423 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003424 Counter{cSubReqToE2, 1},
3425 Counter{cSubRespFromE2, 1},
3426 Counter{cRestSubNotifToXapp, 1},
3427 Counter{cRestSubDelReqFromXapp, 1},
3428 Counter{cSubDelReqToE2, 1},
3429 Counter{cSubDelRespFromE2, 1},
3430 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003431 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003432 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003433 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3434 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3435
3436 // Subs Create
3437 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003438
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003439 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003440 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003441
Anssi Mannilab43397e2021-11-16 12:06:16 +02003442 xappConn1.SendRESTSubsReq(t, params)
3443 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003444
Anssi Mannilab43397e2021-11-16 12:06:16 +02003445 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003446
3447 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003448 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003449 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3450 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003451
Anssi Mannilab43397e2021-11-16 12:06:16 +02003452 e2SubsId := <-xappConn1.ListedRESTNotifications
3453
3454 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003455
3456 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003457 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003458 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3459 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3460
Anssi Mannilab43397e2021-11-16 12:06:16 +02003461 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003462
3463 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003464 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003465}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003466
Markku Virtanen42723e22021-06-15 10:09:23 +03003467//-----------------------------------------------------------------------------
3468// stub stub stub
3469// +-------+ +---------+ +---------+ +---------+
3470// | xapp | | submgr | | e2term | | rtmgr |
3471// +-------+ +---------+ +---------+ +---------+
3472// | | | |
3473// | RESTSubReq | | |
3474// |---------------->| | |
3475// | RESTSubResp | | |
3476// |<----------------| | |
3477// | | RouteCreate | |
3478// | |--------------------------->|
3479// | | RouteResponse| |
3480// | |<---------------------------| // The order of these events may vary
3481// | | SubReq | |
3482// | |------------->| | // The order of these events may vary
3483// | | SubResp | |
3484// | |<-------------| |
3485// | RESTNotif1 | | |
3486// |<----------------| | |
3487// | RESTSubReq | | |
3488// | [RETRANS1] | | |
3489// |---------------->| | |
3490// | RESTNotif1 | | |
3491// |<----------------| | |
3492// | RESTSubReq | | |
3493// | [RETRANS2] | | |
3494// |---------------->| | |
3495// | RESTNotif1 | | |
3496// |<----------------| | |
3497// | RESTSubDelReq | | |
3498// |---------------->| | |
3499// | | SubDelReq | |
3500// | |------------->| |
3501// | RESTSubDelResp| | |
3502// |<----------------| | |
3503// | | SubDelResp | |
3504// | |<-------------| |
3505// | | | |
3506//
3507//-----------------------------------------------------------------------------
3508
3509func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003510
3511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3512 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003513 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003514 Counter{cRestSubRespToXapp, 3},
3515 Counter{cSubReqToE2, 1},
3516 Counter{cSubRespFromE2, 1},
3517 Counter{cRestSubNotifToXapp, 3},
3518 Counter{cRestSubDelReqFromXapp, 1},
3519 Counter{cSubDelReqToE2, 1},
3520 Counter{cSubDelRespFromE2, 1},
3521 Counter{cRestSubDelRespToXapp, 1},
3522 })
3523
3524 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3525
3526 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3527
3528 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3529
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003530 mainCtrl.WaitOngoingRequestMapEmpty()
3531
Markku Virtanen42723e22021-06-15 10:09:23 +03003532 //1.st resend
3533 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3534
3535 assert.Equal(t, restSubId_resend, restSubId)
3536
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003537 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003538
3539 //2.nd resend
3540 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3541
3542 assert.Equal(t, restSubId_resend2, restSubId)
3543
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003544 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003545
3546 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3547
3548 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003549 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003550 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003551}
3552
3553//-----------------------------------------------------------------------------
3554// stub stub stub
3555// +-------+ +---------+ +---------+ +---------+
3556// | xapp | | submgr | | e2term | | rtmgr |
3557// +-------+ +---------+ +---------+ +---------+
3558// | | | |
3559// | RESTSubReq | | |
3560// |---------------->| | |
3561// | RESTSubResp | | |
3562// |<----------------| | |
3563// | | RouteCreate | |
3564// | |--------------------------->|
3565// | | RouteResponse| |
3566// | |<---------------------------| // The order of these events may vary
3567// | | SubReq | |
3568// | |------------->| | // The order of these events may vary
3569// | | SubResp | |
3570// | |<-------------| |
3571// | RESTNotif1 | | |
3572// |<----------------| | |
3573// | RESTSubReq | | |
3574// | [RETRANS, with RESTsubsId] | |
3575// |---------------->| | |
3576// | RESTNotif1 | | |
3577// |<----------------| | |
3578// | RESTSubReq | | |
3579// | [RETRANS, without RESTsubsId] | |
3580// |---------------->| | |
3581// | RESTNotif1 | | |
3582// |<----------------| | |
3583// | RESTSubDelReq | | |
3584// |---------------->| | |
3585// | | SubDelReq | |
3586// | |------------->| |
3587// | RESTSubDelResp| | |
3588// |<----------------| | |
3589// | | SubDelResp | |
3590// | |<-------------| |
3591// | | | |
3592//
3593//-----------------------------------------------------------------------------
3594func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003595
3596 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3597 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003598 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003599 Counter{cRestSubRespToXapp, 3},
3600 Counter{cSubReqToE2, 1},
3601 Counter{cSubRespFromE2, 1},
3602 Counter{cRestSubNotifToXapp, 3},
3603 Counter{cRestSubDelReqFromXapp, 1},
3604 Counter{cSubDelReqToE2, 1},
3605 Counter{cSubDelRespFromE2, 1},
3606 Counter{cRestSubDelRespToXapp, 1},
3607 })
3608
3609 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3610
3611 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3612
3613 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3614
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003615 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003616
3617 //1.st resend with subscription ID
3618 params.SetSubscriptionID(&restSubId)
3619 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3620
3621 assert.Equal(t, restSubId_resend, restSubId)
3622
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003623 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003624
3625 //2.nd resend without subscription ID (faking app restart)
3626 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3627 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3628
3629 assert.Equal(t, restSubId_resend2, restSubId)
3630
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003631 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003632
3633 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3634
3635 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003636 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003637 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003638}
3639
3640//-----------------------------------------------------------------------------
3641// stub stub stub
3642// +-------+ +---------+ +---------+ +---------+
3643// | xapp | | submgr | | e2term | | rtmgr |
3644// +-------+ +---------+ +---------+ +---------+
3645// | | | |
3646// | RESTSubReq | | |
3647// |---------------->| | |
3648// | RESTSubResp | | |
3649// |<----------------| | |
3650// | | RouteCreate | |
3651// | |--------------------------->|
3652// | | RouteResponse| |
3653// | |<---------------------------|
3654// | | SubReq | |
3655// | |------------->| |
3656// | | SubResp | |
3657// | |<-------------| |
3658// | RESTNotif1 | | |
3659// |<----------------| | |
3660// | RESTSubReq | | |
3661// | [with RestSUbsId + one additional e2 subDetail]
3662// |---------------->| | |
3663// | RESTNotif1 | | |
3664// | [for initial e2 subDetail] | |
3665// |<----------------| | |
3666// | | RouteCreate | |
3667// | |--------------------------->|
3668// | | RouteResponse| |
3669// | |<---------------------------|
3670// | | SubReq | |
3671// | |------------->| |
3672// | | SubResp | |
3673// | |<-------------| |
3674// | RESTNotif1 | | |
3675// |<----------------| | |
3676// | RESTSubReq | | |
3677// | [with RESTsubsId initial request] |
3678// |---------------->| | |
3679// | RESTNotif1 | | |
3680// |<----------------| | |
3681// | RESTSubDelReq | | |
3682// |---------------->| | |
3683// | RESTSubDelResp| | |
3684// |<----------------| | |
3685// | | SubDelReq | |
3686// | |------------->| |
3687// | | SubDelResp | |
3688// | |<-------------| |
3689// | | SubDelReq | |
3690// | |------------->| |
3691// | | SubDelResp | |
3692// | |<-------------| |
3693// | | | |
3694//
3695//-----------------------------------------------------------------------------
3696
3697func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003698
3699 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3700 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003701 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003702 Counter{cRestSubRespToXapp, 3},
3703 Counter{cSubReqToE2, 2},
3704 Counter{cSubRespFromE2, 2},
3705 Counter{cRestSubNotifToXapp, 4},
3706 Counter{cRestSubDelReqFromXapp, 1},
3707 Counter{cSubDelReqToE2, 2},
3708 Counter{cSubDelRespFromE2, 2},
3709 Counter{cRestSubDelRespToXapp, 1},
3710 })
3711
3712 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3713
3714 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3715
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003716 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003717
3718 // Send modified requst, this time with e2 subscriptions.
3719 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3720 params2.SetSubscriptionID(&restSubId)
3721
3722 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003723 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003724 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3725 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003726 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3727 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003728
3729 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3730
Markku Virtanen2b512b62021-07-30 12:04:00 +00003731 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003732 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3733 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3734 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3735 assert.NotEqual(t, e2SubsId2, 0)
3736
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003737 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003738
3739 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3740 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3741 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003742 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003743 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3744 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3745 assert.Equal(t, restSubId_resend, restSubId_resend2)
3746
Markku Virtanen2b512b62021-07-30 12:04:00 +00003747 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3748 assert.Equal(t, e2SubsId, e2SubsId1)
3749
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003750 mainCtrl.WaitOngoingRequestMapEmpty()
3751
Markku Virtanen42723e22021-06-15 10:09:23 +03003752 // Delete both e2 subscriptions
3753 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3754 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3755 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3756
3757 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003758 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003759 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003760}
3761
3762//-----------------------------------------------------------------------------
3763// stub stub stub
3764// +-------+ +---------+ +---------+ +---------+
3765// | xapp | | submgr | | e2term | | rtmgr |
3766// +-------+ +---------+ +---------+ +---------+
3767// | | | |
3768// | RESTSubReq | | |
3769// |---------------->| | |
3770// | RESTSubResp | | |
3771// |<----------------| | |
3772// | | RouteCreate | |
3773// | |--------------------------->|
3774// | | RouteResponse| |
3775// | |<---------------------------|
3776// | | SubReq | |
3777// | |------------->| |
3778// | | SubResp | |
3779// | |<-------------| |
3780// | RESTNotif1 | | |
3781// |<----------------| | |
3782// | RESTSubReq | | |
3783// | [with RestSUbsId + one additional e2 subDetail]
3784// |---------------->| | |
3785// | RESTNotif1 | | |
3786// | [for initial e2 subDetail] | |
3787// |<----------------| | |
3788// | | RouteCreate | |
3789// | |--------------------------->|
3790// | | RouteResponse| |
3791// | |<---------------------------|
3792// | | SubReq | |
3793// | |------------->| |
3794// | | SubResp | |
3795// | |<-------------| |
3796// | RESTNotif1 | | |
3797// |<----------------| | |
3798// | RESTSubReq | | |
3799// | [without RESTsubsId initial request] |
3800// |---------------->| | |
3801// | RESTNotif1 | | |
3802// |<----------------| | |
3803// | RESTSubDelReq | | |
3804// |---------------->| | |
3805// | RESTSubDelResp| | |
3806// |<----------------| | |
3807// | | SubDelReq | |
3808// | |------------->| |
3809// | | SubDelResp | |
3810// | |<-------------| |
3811// | | SubDelReq | |
3812// | |------------->| |
3813// | | SubDelResp | |
3814// | |<-------------| |
3815// | | | |
3816//
3817//-----------------------------------------------------------------------------
3818
3819func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003820
3821 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3822 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003823 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003824 Counter{cRestSubRespToXapp, 3},
3825 Counter{cSubReqToE2, 2},
3826 Counter{cSubRespFromE2, 2},
3827 Counter{cRestSubNotifToXapp, 4},
3828 Counter{cRestSubDelReqFromXapp, 1},
3829 Counter{cSubDelReqToE2, 2},
3830 Counter{cSubDelRespFromE2, 2},
3831 Counter{cRestSubDelRespToXapp, 1},
3832 })
3833
3834 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3835
3836 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3837
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003838 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003839
Anssi Mannila21782182021-12-10 10:56:02 +02003840 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003841 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3842 params2.SetSubscriptionID(&restSubId)
3843
3844 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003845 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003846 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3847 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3848
Markku Virtanen2b512b62021-07-30 12:04:00 +00003849 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3850 assert.Equal(t, e2SubsId, e2SubsId1)
3851 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3852 xappConn1.DecrementRequestCount()
3853
Markku Virtanen42723e22021-06-15 10:09:23 +03003854 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3855
3856 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3857 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3858 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3859 assert.NotEqual(t, e2SubsId2, 0)
3860
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003861 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003862
3863 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3864 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003865 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003866 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3867 // md5sum shall find the original request
3868 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3869 assert.Equal(t, restSubId_resend, restSubId_resend2)
3870
Markku Virtanen2b512b62021-07-30 12:04:00 +00003871 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3872 assert.Equal(t, e2SubsId, e2SubsId1)
3873
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003874 mainCtrl.WaitOngoingRequestMapEmpty()
3875
Markku Virtanen42723e22021-06-15 10:09:23 +03003876 // Delete both e2 subscriptions
3877 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3878 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3879 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3880
3881 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003882 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003883 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003884}
3885
3886//-----------------------------------------------------------------------------
3887// stub stub stub
3888// +-------+ +---------+ +---------+ +---------+
3889// | xapp | | submgr | | e2term | | rtmgr |
3890// +-------+ +---------+ +---------+ +---------+
3891// | | | |
3892// | RESTSubReq | | |
3893// |---------------->| | |
3894// | RESTSubResp | | |
3895// |<----------------| | |
3896// | | RouteCreate | |
3897// | |--------------------------->|
3898// | | RouteResponse| |
3899// | |<---------------------------|
3900// | | SubReq | |
3901// | |------------->| |
3902// | | SubResp | |
3903// | |<-------------| |
3904// | RESTNotif1 | | |
3905// |<----------------| | |
3906// | RESTSubReq | | |
3907// | [with RestSUbsId + one additional e2 subDetail]
3908// |---------------->| | |
3909// | RESTNotif1 | | |
3910// | [for initial e2 subDetail] | |
3911// |<----------------| | |
3912// | | RouteCreate | |
3913// | |--------------------------->|
3914// | | RouteResponse| |
3915// | |<---------------------------|
3916// | | SubReq | |
3917// | |------------->| |
3918// | | SubResp | |
3919// | |<-------------| |
3920// | RESTNotif1 | | |
3921// |<----------------| | |
3922// | RESTSubDelReq | | |
3923// |---------------->| | |
3924// | RESTSubDelResp| | |
3925// |<----------------| | |
3926// | | SubDelReq | |
3927// | |------------->| |
3928// | | SubDelResp | |
3929// | |<-------------| |
3930// | | SubDelReq | |
3931// | |------------->| |
3932// | | SubDelResp | |
3933// | |<-------------| |
3934// | RESTSubReq | | |
3935// | [with RESTsubsId initial request] |
3936// |---------------->| | |
3937// | RESTSubResp | | |
3938// |<----------------| | |
3939// | | RouteCreate | |
3940// | |--------------------------->|
3941// | | RouteResponse| |
3942// | |<---------------------------|
3943// | | SubReq | |
3944// | |------------->| |
3945// | | SubResp | |
3946// | |<-------------| |
3947// | RESTNotif1 | | |
3948// |<----------------| | |
3949// | | | |
3950//
3951//-----------------------------------------------------------------------------
3952func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003953
3954 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3955 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003956 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003957 Counter{cRestSubRespToXapp, 3},
3958 Counter{cSubReqToE2, 3},
3959 Counter{cSubRespFromE2, 3},
3960 Counter{cRestSubNotifToXapp, 4},
3961 Counter{cRestSubDelReqFromXapp, 2},
3962 Counter{cSubDelReqToE2, 3},
3963 Counter{cSubDelRespFromE2, 3},
3964 Counter{cRestSubDelRespToXapp, 2},
3965 })
3966
3967 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3968
3969 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3970
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003971 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003972
3973 // Send modified requst, this time with e2 subscriptions.
3974 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3975 params2.SetSubscriptionID(&restSubId)
3976
3977 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003978 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003979 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3980 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3981
Markku Virtanen2b512b62021-07-30 12:04:00 +00003982 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3983 assert.Equal(t, e2SubsId, e2SubsId1)
3984
Markku Virtanen42723e22021-06-15 10:09:23 +03003985 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3986
3987 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3988 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3989 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3990 assert.NotEqual(t, e2SubsId2, 0)
3991
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003992 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003993
3994 // Delete both e2 subscriptions
3995 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3996 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3997 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3998
3999 waitSubsCleanup(t, e2SubsId, 10)
4000
4001 // Resend the original request, we shall find it's previous md5sum/restsubs
4002 // but the restsubscription has been already removed. This shall trigger a
4003 // fresh create.
4004 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4005
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004006 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03004007
4008 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4009
4010 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03004011 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004012 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03004013}
4014
Anssi Mannila27385172021-12-22 09:41:54 +02004015//-----------------------------------------------------------------------------
4016// TestRESTSubDelReqRetransmission
4017//
4018// stub stub
4019// +-------+ +---------+ +---------+
4020// | xapp | | submgr | | e2term |
4021// +-------+ +---------+ +---------+
4022// | | |
4023// | RESTSubReq | |
4024// |---------------->| |
4025// | | |
4026// | RESTSubResp | |
4027// |<----------------| |
4028// | | SubReq |
4029// | |------------->|
4030// | | SubResp |
4031// | |<-------------|
4032// | RESTNotif1 | |
4033// |<----------------| |
4034// | | |
4035// | RESTSubDelReq | |
4036// |---------------->| |
4037// | RESTSubDelResp | |
4038// |<----------------| |
4039// | | SubDelReq |
4040// | |------------->|
4041// | RESTSubDelReq | |
4042// |---------------->| |
4043// | RESTSubDelResp | |
4044// |<----------------| |
4045// | | SubDelResp |
4046// | |<-------------|
4047// | | |
4048//
4049//-----------------------------------------------------------------------------
4050
archaggeafbf95f2021-04-14 08:54:05 +03004051func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004052
4053 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004054 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004055 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004056 Counter{cSubReqToE2, 1},
4057 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004058 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004059 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004060 Counter{cSubDelReqToE2, 1},
4061 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004062 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004063 })
4064
4065 var params *teststube2ap.RESTSubsReqParams = nil
4066
4067 //Subs Create
4068 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4069
4070 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4071
4072 //Subs Delete
4073 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4074 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4075
Anssi Mannila27385172021-12-22 09:41:54 +02004076 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03004077 seqBef := mainCtrl.get_msgcounter(t)
4078 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4079 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
4080
Anssi Mannila27385172021-12-22 09:41:54 +02004081 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03004082 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4083
4084 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004085 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004086 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004087}
4088
4089//-----------------------------------------------------------------------------
4090// TestRESTSubReqDelReq
4091//
4092// stub stub
4093// +-------+ +---------+ +---------+
4094// | xapp | | submgr | | e2term |
4095// +-------+ +---------+ +---------+
4096// | | |
4097// | RESTSubReq | |
4098// |---------------->| |
4099// | | |
4100// | RESTSubResp | |
4101// |<----------------| |
4102// | | SubReq |
4103// | |------------->|
4104// | RESTSubDelReq | |
4105// |---------------->| |
4106// | RESTSubDelResp | |
4107// | unsuccess | |
4108// |<----------------| |
4109// | | SubResp |
4110// | |<-------------|
4111// | RESTNotif1 | |
4112// |<----------------| |
4113// | | |
4114// | [SUBS DELETE] |
4115// | | |
4116//
4117//-----------------------------------------------------------------------------
4118func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004119
4120 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004121 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004122 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004123 Counter{cSubReqToE2, 1},
4124 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004125 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004126 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004127 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004128 Counter{cSubDelReqToE2, 1},
4129 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004130 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004131 })
4132
4133 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004134
4135 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004136 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004137 restSubId := xappConn1.SendRESTSubsReq(t, params)
4138
4139 // Del. This will fail as processing of the subscription
4140 // is still ongoing in submgr. Deletion is not allowed before
4141 // subscription creation has been completed.
4142 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4143 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4144 xappConn1.ExpectRESTNotification(t, restSubId)
4145 e2termConn1.SendSubsResp(t, crereq, cremsg)
4146 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4147
4148 // Retry del
4149 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4150
4151 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4152 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4153
4154 // Wait that subs is cleaned
4155 waitSubsCleanup(t, e2SubsId, 10)
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// TestRESTSubReqAndSubDelOkTwoParallel
4162//
4163// stub stub stub
4164// +-------+ +-------+ +---------+ +---------+
4165// | xapp2 | | xapp1 | | submgr | | e2term |
4166// +-------+ +-------+ +---------+ +---------+
4167// | | | |
4168// | | RESTSubReq1 | |
4169// | |------------->| |
4170// | | RESTSubResp1 | |
4171// | |<-------------| |
4172// | | | |
4173// | | | SubReq1 |
4174// | | |------------->|
4175// | | | |
4176// | RESTSubReq2 | |
4177// |------------------------>| |
4178// | RESTSubResp2 | |
4179// |<------------------------| |
4180// | | | |
4181// | | | SubReq2 |
4182// | | |------------->|
4183// | | | |
4184// | | | SubResp1 |
4185// | | |<-------------|
4186// | | RESTNotif1 | |
4187// | |<-------------| |
4188// | | | |
4189// | | | SubResp2 |
4190// | | |<-------------|
4191// | RESTNotif2 | |
4192// |<------------------------| |
4193// | | | |
4194// | | [SUBS 1 DELETE] |
4195// | | | |
4196// | | [SUBS 2 DELETE] |
4197// | | | |
4198//
4199//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004200
4201func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004202
4203 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004204 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004205 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004206 Counter{cSubReqToE2, 2},
4207 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004208 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004209 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004210 Counter{cSubDelReqToE2, 2},
4211 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004212 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004213 })
4214
4215 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004216 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004217 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004218 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004219
4220 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004221 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004222 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004223 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004224
4225 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4226 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4227
4228 //XappConn1 receives both of the responses
4229 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4230
4231 //Resp1
4232 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4233 //Resp2
4234 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4235
4236 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004237 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004238 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004239 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004240
4241 //Del1
4242 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4243 //Del2
4244 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
4245
4246 //Wait that subs is cleaned
4247 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
4248 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4249
4250 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004251 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004252}
4253
Anssi Mannila27385172021-12-22 09:41:54 +02004254//-----------------------------------------------------------------------------
4255// TestRESTSameSubsDiffRan
4256// Same subscription to different RANs
4257//
4258// stub stub
4259// +-------+ +---------+ +---------+
4260// | xapp | | submgr | | e2term |
4261// +-------+ +---------+ +---------+
4262// | | |
4263// | RESTSubReq(r1) | |
4264// |---------------->| |
4265// | RESTSubResp(r1) | |
4266// |<----------------| |
4267// | | |
4268// | | SubReq(r1) |
4269// | |------------->|
4270// | | |
4271// | | SubResp(r1) |
4272// | |<-------------|
4273// | | |
4274// | RESTNotif(r1) | |
4275// |<----------------| |
4276// | | |
4277// | RESTSubReq(r2) | |
4278// |---------------->| |
4279// | | |
4280// | RESTSubResp(r2) | |
4281// |<----------------| |
4282// | | SubReq(r2) |
4283// | |------------->|
4284// | | |
4285// | | SubResp(r2) |
4286// | |<-------------|
4287// | | |
4288// | RESTNotif(r2) | |
4289// |<----------------| |
4290// | | |
4291// | [SUBS r1 DELETE] |
4292// | | |
4293// | [SUBS r2 DELETE] |
4294// | | |
4295//
4296//-----------------------------------------------------------------------------
4297
archaggeafbf95f2021-04-14 08:54:05 +03004298func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004299
4300 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004301 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004302 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004303 Counter{cSubReqToE2, 2},
4304 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004305 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004306 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004307 Counter{cSubDelReqToE2, 2},
4308 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004309 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004310 })
4311
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004312 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004313 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004314 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004315
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004316 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004317 params.SetMeid("RAN_NAME_2")
4318 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004319 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004320
4321 //Del1
4322 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4323 //Del2
4324 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
4325
4326 //Wait that subs is cleaned
4327 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4328 waitSubsCleanup(t, e2SubsId2, 10)
4329
4330 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004331 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004332}
4333
Anssi Mannila27385172021-12-22 09:41:54 +02004334//-----------------------------------------------------------------------------
4335// TestRESTSubReqRetryInSubmgr
4336//
4337// stub stub
4338// +-------+ +---------+ +---------+
4339// | xapp | | submgr | | e2term |
4340// +-------+ +---------+ +---------+
4341// | | |
4342// | RESTSubReq | |
4343// |---------------->| |
4344// | RESTSubResp | |
4345// |<----------------| |
4346// | | SubReq |
Anssi Mannila92c38552021-12-29 09:59:24 +02004347// | |------------->|
Anssi Mannila27385172021-12-22 09:41:54 +02004348// | | |
4349// | | |
4350// | | SubReq |
4351// | |------------->|
4352// | | SubResp |
4353// | |<-------------|
4354// | | |
4355// | RESTNotif | |
4356// |<----------------| |
4357// | | |
4358// | [SUBS DELETE] |
4359// | | |
4360//
4361//-----------------------------------------------------------------------------
4362
archaggeafbf95f2021-04-14 08:54:05 +03004363func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004364
4365 // Init counter check
4366 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004367 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004368 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004369 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004370 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004371 Counter{cSubReReqToE2, 1},
4372 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004373 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004374 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004375 Counter{cSubDelReqToE2, 1},
4376 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004377 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004378 })
4379
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004380 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004381 restSubId := xappConn1.SendRESTSubsReq(t, params)
4382
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004383 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004384
4385 // Catch the first message and ignore it
4386 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004387 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004388
4389 // The second request is being handled normally
4390 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4391 xappConn1.ExpectRESTNotification(t, restSubId)
4392 e2termConn1.SendSubsResp(t, crereq, cremsg)
4393 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4394
4395 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4396
Anssi Mannila27385172021-12-22 09:41:54 +02004397 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004398 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4399
4400 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4401 //Wait that subs is cleaned
4402 waitSubsCleanup(t, e2SubsId, 10)
4403
4404 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004405 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004406}
4407
4408//-----------------------------------------------------------------------------
4409// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4410//
4411// stub stub
4412// +-------+ +---------+ +---------+
4413// | xapp | | submgr | | e2term |
4414// +-------+ +---------+ +---------+
4415// | | |
4416// | RESTSubReq | |
4417// |---------------->| |
4418// | | |
4419// | RESTSubResp | |
4420// |<----------------| |
4421// | | SubReq |
4422// | |------------->|
4423// | | |
4424// | | |
4425// | | SubReq |
4426// | |------------->|
4427// | | |
4428// | | SubDelReq |
4429// | |------------->|
4430// | | |
4431// | | |
4432// | | SubDelReq |
4433// | |------------->|
4434// | | |
4435// | | |
4436// | | SubDelResp |
4437// | |<-------------|
4438// | RESTNotif | |
4439// | unsuccess | |
4440// |<----------------| |
4441// | | |
4442// | [SUBS DELETE] |
4443// | | |
4444//
4445//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004446
archaggeafbf95f2021-04-14 08:54:05 +03004447func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004448
4449 // Init counter check
4450 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004451 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004452 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004453 Counter{cSubReqToE2, 1},
4454 Counter{cSubReReqToE2, 1},
4455 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004456 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004457 Counter{cSubDelReqToE2, 1},
4458 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004459 Counter{cRestSubDelReqFromXapp, 1},
4460 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004461 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004462
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004463 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004464 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004465 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004466
4467 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004468 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004469
4470 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004471 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004472
4473 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004474 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004475 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004476 xappConn1.WaitRESTNotification(t, restSubId)
4477
Anssi Mannilab43397e2021-11-16 12:06:16 +02004478 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4479
archaggeafbf95f2021-04-14 08:54:05 +03004480 // Wait that subs is cleaned
4481 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004482 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004483 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004484}
4485
Anssi Mannila27385172021-12-22 09:41:54 +02004486//-----------------------------------------------------------------------------
4487// TestREST2eTermNotRespondingToSubReq
4488//
4489// stub stub
4490// +-------+ +---------+ +---------+
4491// | xapp | | submgr | | e2term |
4492// +-------+ +---------+ +---------+
4493// | | |
4494// | RESTSubReq | |
4495// |---------------->| |
4496// | RESTSubResp | |
4497// |<----------------| |
4498// | | SubReq |
4499// | |------------->|
4500// | | |
4501// | | SubReq |
4502// | |------------->|
4503// | | |
4504// | | SubDelReq |
4505// | |------------->|
4506// | | |
4507// | | SubDelReq |
4508// | |------------->|
4509// | RESTNotif(Unsuccessful) |
4510// |<----------------| |
4511// | | |
4512// | RESTSubDelReq | |
4513// |---------------->| |
4514// | RESTSubDelResp | |
4515// |<----------------| |
4516// | | |
4517//
4518//-----------------------------------------------------------------------------
4519
archaggeafbf95f2021-04-14 08:54:05 +03004520func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004521
4522 // Init counter check
4523 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004524 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004525 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004526 Counter{cSubReqToE2, 1},
4527 Counter{cSubReReqToE2, 1},
4528 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004529 Counter{cSubDelReReqToE2, 1},
4530 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004531 Counter{cSubDelReqToE2, 1},
4532 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004533 Counter{cRestSubDelReqFromXapp, 1},
4534 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004535 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004536
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004537 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004538 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004539 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004540
4541 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004542 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004543
4544 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004545 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004546
4547 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004548 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004549
Markku Virtanen55d2a282021-06-04 14:46:56 +03004550 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004551 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004552 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004553
4554 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4555
Anssi Mannilab43397e2021-11-16 12:06:16 +02004556 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004557
Anssi Mannilab43397e2021-11-16 12:06:16 +02004558 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004559 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004560 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004561}
4562
4563//-----------------------------------------------------------------------------
4564// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4565//
4566// stub stub
4567// +-------+ +---------+ +---------+
4568// | xapp | | submgr | | e2term |
4569// +-------+ +---------+ +---------+
4570// | | |
4571// | RESTSubReq | |
4572// |---------------->| |
4573// | | |
4574// | RESTSubResp | |
4575// |<----------------| |
4576// | | SubReq |
4577// | |------------->|
4578// | | |
4579// | | |
4580// | | SubReq |
4581// | |------------->|
4582// | | |
4583// | | SubDelReq |
4584// | |------------->|
4585// | | |
4586// | | |
4587// | | SubDelReq |
4588// | |------------->|
4589// | | |
4590// | | |
4591// | | SubDelResp |
4592// | |<-------------|
4593// | RESTNotif | |
4594// | unsuccess | |
4595// |<----------------| |
4596// | | |
4597// | [SUBS DELETE] |
4598// | | |
4599//
4600//-----------------------------------------------------------------------------
4601func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004602
4603 // Init counter check
4604 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004605 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004606 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004607 Counter{cSubReqToE2, 1},
4608 Counter{cSubReReqToE2, 1},
4609 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004610 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004611 Counter{cSubDelReqToE2, 1},
4612 Counter{cSubDelReReqToE2, 1},
4613 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004614 Counter{cRestSubDelReqFromXapp, 1},
4615 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004616 })
4617
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004618 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004619 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004620 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004621
4622 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004623 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004624
4625 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004626 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004627
4628 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004629 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004630
Markku Virtanen55d2a282021-06-04 14:46:56 +03004631 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004632 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004633 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004634
4635 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4636
Anssi Mannilab43397e2021-11-16 12:06:16 +02004637 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004638
Anssi Mannilab43397e2021-11-16 12:06:16 +02004639 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004640 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004641 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004642}
4643
4644//-----------------------------------------------------------------------------
4645// TestRESTSubReqSubFailRespInSubmgr
4646//
4647// stub stub
4648// +-------+ +---------+ +---------+
4649// | xapp | | submgr | | e2term |
4650// +-------+ +---------+ +---------+
4651// | | |
4652// | RESTSubReq | |
4653// |---------------->| |
4654// | | |
4655// | RESTSubResp | |
4656// |<----------------| |
4657// | | SubReq |
4658// | |------------->|
4659// | | |
4660// | | SubFail |
4661// | |<-------------|
4662// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004663// | RESTNotif | |
4664// | unsuccess | |
4665// |<----------------| |
4666// | | |
4667// | [SUBS DELETE] |
4668// | | |
4669//
4670//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004671
archaggeafbf95f2021-04-14 08:54:05 +03004672func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004673
4674 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004675 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004676 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004677 Counter{cSubReqToE2, 1},
4678 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004679 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004680 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004681 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004682 })
4683
4684 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004685 const e2Timeout int64 = 2
4686 const e2RetryCount int64 = 1
4687 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004688
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004689 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004690 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004691 restSubId := xappConn1.SendRESTSubsReq(t, params)
4692
4693 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4694 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4695 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004696 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004697 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4698
archaggeafbf95f2021-04-14 08:54:05 +03004699 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004700 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004701
4702 // REST subscription sill there to be deleted
4703 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4704
4705 // Wait that subs is cleaned
4706 waitSubsCleanup(t, e2SubsId, 10)
4707
4708 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004709 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004710}
4711
4712//-----------------------------------------------------------------------------
Anssi Mannila56233b02022-01-24 13:26:42 +02004713// TestRESTSubReqPartialResp
4714//
4715// stub stub
4716// +-------+ +---------+ +---------+
4717// | xapp | | submgr | | e2term |
4718// +-------+ +---------+ +---------+
4719// | | |
4720// | RESTSubReq | |
4721// |---------------->| |
4722// | RESTSubResp | |
4723// |<----------------| |
4724// | | SubReq |
4725// | |------------->|
4726// | | SubResp | Partially accepted
4727// | |<-------------|
4728// | | |
4729// | RESTNotif | |
4730// |<----------------| |
4731// | | |
4732// | [SUBS DELETE] |
4733// | | |
4734//
4735//-----------------------------------------------------------------------------
4736
4737func TestRESTSubReqPartialResp(t *testing.T) {
4738
4739 // Init counter check
4740 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4741 Counter{cRestSubReqFromXapp, 1},
4742 Counter{cRestSubRespToXapp, 1},
4743 Counter{cSubReqToE2, 1},
4744 Counter{cSubRespFromE2, 1},
4745 Counter{cPartialSubRespFromE2, 1},
4746 Counter{cRestSubNotifToXapp, 1},
4747 Counter{cRestSubDelReqFromXapp, 1},
4748 Counter{cSubDelReqToE2, 1},
4749 Counter{cSubDelRespFromE2, 1},
4750 Counter{cRestSubDelRespToXapp, 1},
4751 })
4752
4753 // Req
4754 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4755
4756 actionId := int64(2)
4757 actionType := "report"
4758 actionDefinition := []int64{5678, 1}
4759 subsequestActionType := "continue"
4760 timeToWait := "w10ms"
4761 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4762
4763 restSubId := xappConn1.SendRESTSubsReq(t, params)
4764 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4765 xappConn1.ExpectRESTNotification(t, restSubId)
4766
4767 actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{}
4768 actionNotAdmittedItem.ActionId = 1
4769 actionNotAdmittedItem.Cause.Content = 1
4770 actionNotAdmittedItem.Cause.Value = 8
4771 actionNotAdmittedList := e2ap.ActionNotAdmittedList{}
4772 actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem)
4773 e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList)
4774 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4775
4776 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4777
4778 // Del
4779 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4780
4781 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4782 //Wait that subs is cleaned
4783 waitSubsCleanup(t, e2SubsId, 10)
4784
4785 mainCtrl.VerifyCounterValues(t)
4786 mainCtrl.VerifyAllClean(t)
4787}
4788
4789//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004790// TestRESTSubDelReqRetryInSubmgr
4791//
4792// stub stub
4793// +-------+ +---------+ +---------+
4794// | xapp | | submgr | | e2term |
4795// +-------+ +---------+ +---------+
4796// | | |
4797// | [SUBS CREATE] |
4798// | | |
4799// | | |
4800// | RESTSubDelReq | |
4801// |---------------->| |
4802// | | |
4803// | RESTSubDelResp | |
4804// |<----------------| |
4805// | | SubDelReq |
4806// | |------------->|
4807// | | |
4808// | | SubDelReq |
4809// | |------------->|
4810// | | |
4811// | | SubDelResp |
4812// | |<-------------|
4813// | | |
4814//
4815//-----------------------------------------------------------------------------
4816func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004817
4818 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004819 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004820 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004821 Counter{cSubReqToE2, 1},
4822 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004823 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004824 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004825 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004826 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004827 Counter{cSubDelReReqToE2, 1},
4828 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004829 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004830 })
4831 // Req
4832 var params *teststube2ap.RESTSubsReqParams = nil
4833 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4834
4835 // Del
4836 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4837
4838 // E2t: Receive 1st SubsDelReq
4839 e2termConn1.RecvSubsDelReq(t)
4840
4841 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4842 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4843 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4844
4845 //Wait that subs is cleaned
4846 waitSubsCleanup(t, e2SubsId, 10)
4847
4848 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004849 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004850}
4851
4852//-----------------------------------------------------------------------------
4853// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4854//
4855// stub stub
4856// +-------+ +---------+ +---------+
4857// | xapp | | submgr | | e2term |
4858// +-------+ +---------+ +---------+
4859// | | |
4860// | [SUBS CREATE] |
4861// | | |
4862// | | |
4863// | RESTSubDelReq | |
4864// |---------------->| |
4865// | | |
4866// | RESTSubDelResp | |
4867// |<----------------| |
4868// | | SubDelReq |
4869// | |------------->|
4870// | | |
4871// | | SubDelReq |
4872// | |------------->|
4873// | | |
4874// | | |
4875//
4876//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004877
archaggeafbf95f2021-04-14 08:54:05 +03004878func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004879
4880 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004881 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004882 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004883 Counter{cSubReqToE2, 1},
4884 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004885 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004886 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004887 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004888 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004889 Counter{cSubDelReReqToE2, 1},
4890 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004891 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004892 })
4893
4894 // Req
4895 var params *teststube2ap.RESTSubsReqParams = nil
4896 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4897
4898 // Del
4899 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4900
4901 // E2t: Receive 1st SubsDelReq
4902 e2termConn1.RecvSubsDelReq(t)
4903
4904 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4905 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4906 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4907
4908 //Wait that subs is cleaned
4909 waitSubsCleanup(t, e2SubsId, 10)
4910
4911 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004912 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004913}
4914
4915//-----------------------------------------------------------------------------
4916// TestRESTSubDelReqSubDelFailRespInSubmgr
4917//
4918// stub stub
4919// +-------+ +---------+ +---------+
4920// | xapp | | submgr | | e2term |
4921// +-------+ +---------+ +---------+
4922// | | |
4923// | [SUBS CREATE] |
4924// | | |
4925// | | |
4926// | RESTSubDelReq | |
4927// |---------------->| |
4928// | | |
4929// | RESTSubDelResp | |
4930// |<----------------| |
4931// | | SubDelReq |
4932// | |------------->|
4933// | | |
4934// | | SubDelFail |
4935// | |<-------------|
4936// | | |
4937//
4938//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004939
archaggeafbf95f2021-04-14 08:54:05 +03004940func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004941
4942 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004943 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004944 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004945 Counter{cSubReqToE2, 1},
4946 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004947 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004948 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004949 Counter{cSubDelReqToE2, 1},
4950 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004951 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004952 })
4953
4954 // Req
4955 var params *teststube2ap.RESTSubsReqParams = nil
4956 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4957
4958 // Del
4959 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4960
4961 // E2t: Send receive SubsDelReq and send SubsDelFail
4962 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4963 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4964
4965 //Wait that subs is cleaned
4966 waitSubsCleanup(t, e2SubsId, 10)
4967
4968 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004969 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004970}
4971
4972//-----------------------------------------------------------------------------
4973// TestRESTSubReqAndSubDelOkSameAction
4974//
4975// stub stub
4976// +-------+ +-------+ +---------+ +---------+
4977// | xapp2 | | xapp1 | | submgr | | e2term |
4978// +-------+ +-------+ +---------+ +---------+
4979// | | | |
4980// | | RESTSubReq1 | |
4981// | |---------------->| |
4982// | | | |
4983// | | RESTSubResp1 | |
4984// | |<----------------| |
4985// | | | |
4986// | | | SubReq1 |
4987// | | |------------->|
4988// | | | SubResp1 |
4989// | | |<-------------|
4990// | | RESTNotif1 | |
4991// | |<----------------| |
4992// | | | |
4993// | RESTSubReq2 | |
4994// |------------------------------>| |
4995// | | | |
4996// | RESTSubResp2 | |
4997// |<------------------------------| |
4998// | | | |
4999// | | RESTNotif2 | |
5000// |<------------------------------| |
5001// | | | |
5002// | | RESTSubDelReq1 | |
5003// | |---------------->| |
5004// | | | |
5005// | | RESTSubDelResp1 | |
5006// | |<----------------| |
5007// | | | |
5008// | RESTSubDelReq2 | |
5009// |------------------------------>| |
5010// | | | |
5011// | RESTSubDelResp2 | |
5012// |<------------------------------| |
5013// | | | |
5014// | | | SubDelReq2 |
5015// | | |------------->|
5016// | | | |
5017// | | | SubDelResp2 |
5018// | | |<-------------|
5019// | | | |
5020//
5021//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005022
archaggeafbf95f2021-04-14 08:54:05 +03005023func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005024
5025 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005026 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005027 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005028 Counter{cSubReqToE2, 1},
5029 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005030 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005031 Counter{cMergedSubscriptions, 1},
5032 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005033 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005034 Counter{cSubDelReqToE2, 1},
5035 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005036 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005037 })
5038
5039 // Req1
5040 var params *teststube2ap.RESTSubsReqParams = nil
5041
5042 //Subs Create
5043 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5044 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5045
5046 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005047 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005048 params.SetMeid("RAN_NAME_1")
5049
5050 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005051 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005052 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03005053 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005054 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005055 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005056 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005057 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005058
5059 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5060
5061 // Del1
5062 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5063
5064 // Del2
5065 deleteXapp2Subscription(t, &restSubId2)
5066
5067 //Wait that subs is cleaned
5068 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005069 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005070 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005071}
5072
5073//-----------------------------------------------------------------------------
5074// TestSubReqAndSubDelOkSameActionParallel
5075//
5076// stub stub stub
5077// +-------+ +-------+ +---------+ +---------+
5078// | xapp2 | | xapp1 | | submgr | | e2term |
5079// +-------+ +-------+ +---------+ +---------+
5080// | | | |
5081// | | | |
5082// | | | |
5083// | | SubReq1 | |
5084// | |------------->| |
5085// | | | |
5086// | | | SubReq1 |
5087// | | |------------->|
5088// | SubReq2 | |
5089// |--------------------------->| |
5090// | | | SubResp1 |
5091// | | |<-------------|
5092// | | SubResp1 | |
5093// | |<-------------| |
5094// | | | SubReq2 |
5095// | | |------------->|
5096// | | | |
5097// | | | SubResp2 |
5098// | | |<-------------|
5099// | SubResp2 | |
5100// |<---------------------------| |
5101// | | | |
5102// | | SubDelReq 1 | |
5103// | |------------->| |
5104// | | | |
5105// | | SubDelResp 1 | |
5106// | |<-------------| |
5107// | | | |
5108// | SubDelReq 2 | |
5109// |--------------------------->| |
5110// | | | |
5111// | | | SubDelReq 2 |
5112// | | |------------->|
5113// | | | |
5114// | | | SubDelReq 2 |
5115// | | |------------->|
5116// | | | |
5117// | SubDelResp 2 | |
5118// |<---------------------------| |
5119//
5120func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005121
5122 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005123 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005124 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005125 Counter{cSubReqToE2, 2},
5126 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005127 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005128 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005129 Counter{cSubDelReqToE2, 2},
5130 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005131 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005132 })
5133
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005134 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005135 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5136 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5137
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005138 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005139 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5140
5141 xappConn1.ExpectRESTNotification(t, restSubId1)
5142 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5143 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
5144
5145 xappConn2.ExpectRESTNotification(t, restSubId2)
5146 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
5147 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
5148 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5149
5150 // Del1
5151 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5152 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5153 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5154 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5155
5156 // Del2
5157 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5158 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
5159 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
5160
5161 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005162 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005163 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005164}
5165
5166//-----------------------------------------------------------------------------
5167// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
5168//
5169// stub stub stub
5170// +-------+ +-------+ +---------+ +---------+
5171// | xapp2 | | xapp1 | | submgr | | e2term |
5172// +-------+ +-------+ +---------+ +---------+
5173// | | | |
5174// | | | |
5175// | | | |
5176// | | RESTSubReq1 | |
5177// | |---------------->| |
5178// | | | |
5179// | | RESTSubResp1 | |
5180// | |<----------------| |
5181// | | | SubReq1 |
5182// | | |------------->|
5183// | RESTSubReq2 | |
5184// |------------------------------>| |
5185// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005186// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005187// |<------------------------------| |
5188// | | | SubReq1 |
5189// | | |------------->|
5190// | | | |
5191// | | | |
5192// | | | SubDelReq |
5193// | | |------------->|
5194// | | | |
5195// | | | SubDelResp |
5196// | | |<-------------|
5197// | | RESTNotif1 | |
5198// | | unsuccess | |
5199// | |<----------------| |
5200// | RESTNotif2 | |
5201// | | unsuccess | |
5202// |<------------------------------| |
5203// | | | |
5204// | | RESTSubDelReq1 | |
5205// | |---------------->| |
5206// | | | |
5207// | | RESTSubDelResp1 | |
5208// | |<----------------| |
5209// | | | |
5210// | RESTSubDelReq2 | |
5211// |------------------------------>| |
5212// | | | |
5213// | RESTSubDelResp2 | |
5214// |<------------------------------| |
5215//
5216//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005217
archaggeafbf95f2021-04-14 08:54:05 +03005218func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005219
5220 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005221 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005222 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005223 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005224 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005225 Counter{cSubReqTimerExpiry, 2},
5226 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005227 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005228 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005229 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005230 Counter{cSubDelReqToE2, 1},
5231 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005232 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005233 })
archaggeafbf95f2021-04-14 08:54:05 +03005234 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005235
5236 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005237 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005238 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5239 crereq1, _ := e2termConn1.RecvSubsReq(t)
5240
5241 // Req2
5242 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005243 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005244 params2.SetMeid("RAN_NAME_1")
5245 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5246 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5247
5248 //Req1 (retransmitted)
5249 e2termConn1.RecvSubsReq(t)
5250
5251 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005252
5253 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005254 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5255
Markku Virtanenda34eec2021-05-20 08:22:04 +00005256 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005257 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005258 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005259 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005260
5261 // Del1
5262 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5263
5264 // Del2
5265 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5266
Markku Virtanenda34eec2021-05-20 08:22:04 +00005267 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5268
archaggeafbf95f2021-04-14 08:54:05 +03005269 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005270 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005271 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005272 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005273}
5274
5275//-----------------------------------------------------------------------------
5276// TestRESTSubReqAndSubDelNokSameActionParallel
5277//
5278// stub stub stub
5279// +-------+ +-------+ +---------+ +---------+
5280// | xapp2 | | xapp1 | | submgr | | e2term |
5281// +-------+ +-------+ +---------+ +---------+
5282// | | | |
5283// | | | |
5284// | | | |
5285// | | RESTSubReq1 | |
5286// | |---------------->| |
5287// | | | |
5288// | | RESTSubResp1 | |
5289// | |<----------------| |
5290// | | | SubReq1 |
5291// | | |------------->|
5292// | RESTSubReq2 | |
5293// |------------------------------>| |
5294// | | | |
5295// | RESTSubDelResp2 | |
5296// |<------------------------------| |
5297// | | | SubFail1 |
5298// | | |<-------------|
5299// | | | |
5300// | | RESTNotif1 | |
5301// | | unsuccess | |
5302// | |<----------------| |
5303// | RESTNotif2 | |
5304// | | unsuccess | |
5305// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005306// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005307// | | 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 +03005308// | |---------------->| |
5309// | | | |
5310// | | RESTSubDelResp1 | |
5311// | |<----------------| |
5312// | | | |
5313// | RESTSubDelReq2 | |
5314// |------------------------------>| |
5315// | | | |
5316// | RESTSubDelResp2 | |
5317// |<------------------------------| |
5318//
5319//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005320
archaggeafbf95f2021-04-14 08:54:05 +03005321func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005322
5323 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005324 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005325 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005326 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005327 Counter{cSubReqToE2, 1},
5328 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005329 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005330 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005331 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005332 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005333 })
5334
5335 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005336
5337 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005338 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005339 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5340 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5341
5342 // Req2
5343 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005344 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005345 params2.SetMeid("RAN_NAME_1")
5346 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5347 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5348
5349 // E2t: send SubsFail (first)
5350 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5351 fparams1.Set(crereq1)
5352 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5353
archaggeafbf95f2021-04-14 08:54:05 +03005354 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005355 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005356 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005357 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005358 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005359
5360 // Del1
5361 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5362
5363 // Del2
5364 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5365
5366 //Wait that subs is cleaned
5367 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5368 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005369 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005370 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005371}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005372
Anssi Mannila27385172021-12-22 09:41:54 +02005373//-----------------------------------------------------------------------------
5374// TestRESTSubReqPolicyAndSubDelOk
5375//
5376// stub stub
5377// +-------+ +---------+ +---------+
5378// | xapp | | submgr | | e2term |
5379// +-------+ +---------+ +---------+
5380// | | |
5381// | RESTSubReq | |
5382// |--------------->| |
5383// | RESTSubResp | |
5384// |<---------------| |
5385// | | |
5386// | | SubReq |
5387// | |------------->|
5388// | | |
5389// | | SubResp |
5390// | |<-------------|
5391// | | |
5392// | RESTNotif | |
5393// |<---------------| |
5394// | | |
5395// | | |
5396// | RESTSubDelReq | |
5397// |--------------->| |
5398// | RESTSubDelResp | |
5399// |<---------------| |
5400// | | |
5401// | | SubDelReq |
5402// | |------------->|
5403// | | |
5404// | | SubDelResp |
5405// | |<-------------|
5406// | | |
5407//
5408//-----------------------------------------------------------------------------
5409
archaggeafbf95f2021-04-14 08:54:05 +03005410func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005411
5412 // Init counter check
5413 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005414 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005415 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005416 Counter{cSubReqToE2, 1},
5417 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005418 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005419 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005420 Counter{cSubDelReqToE2, 1},
5421 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005422 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005423 })
5424
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005425 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005426 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005427 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005428
5429 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5430 xappConn1.ExpectRESTNotification(t, restSubId)
5431 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5432 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005433 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005434
5435 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5436 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5437 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5438
5439 // Wait that subs is cleaned
5440 waitSubsCleanup(t, e2SubsId, 10)
5441 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005442 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005443}
5444
5445//-----------------------------------------------------------------------------
5446// TestRESTSubReqPolicyChangeAndSubDelOk
5447//
5448// stub stub
5449// +-------+ +---------+ +---------+
5450// | xapp | | submgr | | e2term |
5451// +-------+ +---------+ +---------+
5452// | | |
5453// | RESTSubReq | |
5454// |---------------->| |
5455// | | |
5456// | RESTSubResp | |
5457// |<----------------| |
5458// | | SubReq |
5459// | |------------->|
5460// | | |
5461// | | SubResp |
5462// | |<-------------|
5463// | | |
5464// | RESTNotif | |
5465// |<----------------| |
5466// | | |
5467// | RESTSubReq | |
5468// |---------------->| |
5469// | | |
5470// | RESTSubResp | |
5471// |<----------------| |
5472// | | SubReq |
5473// | |------------->|
5474// | | |
5475// | | SubResp |
5476// | |<-------------|
5477// | | |
5478// | RESTNotif | |
5479// |<----------------| |
5480// | | |
5481// | RESTSubDelReq | |
5482// |---------------->| |
5483// | | |
5484// | | SubDelReq |
5485// | |------------->|
5486// | | |
5487// | | SubDelResp |
5488// | |<-------------|
5489// | | |
5490// | RESTSubDelResp | |
5491// |<----------------| |
5492//
5493//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005494
archaggeafbf95f2021-04-14 08:54:05 +03005495func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005496
5497 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005498 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005499 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005500 Counter{cSubReqToE2, 2},
5501 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005502 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005503 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005504 Counter{cSubDelReqToE2, 1},
5505 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005506 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005507 })
5508
5509 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005510 const e2Timeout int64 = 1
5511 const e2RetryCount int64 = 0
5512 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005513
5514 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005515 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005516 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005517 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5518
5519 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005520 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005521
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005522 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005523 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005524 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005525 params.SetTimeToWait("w200ms")
5526 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5527
5528 // Del
5529 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5530
5531 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5532 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5533
5534 // Wait that subs is cleaned
5535 waitSubsCleanup(t, e2SubsId, 10)
5536 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005537 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005538}
5539
5540//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005541// TestRESTSubReqPolicyChangeNOk
5542//
5543// stub stub
5544// +-------+ +---------+ +---------+
5545// | xapp | | submgr | | e2term |
5546// +-------+ +---------+ +---------+
5547// | | |
5548// | RESTSubReq | |
5549// |---------------->| |
5550// | | |
5551// | RESTSubResp | |
5552// |<----------------| |
5553// | | SubReq |
5554// | |------------->|
5555// | | |
5556// | | SubResp |
5557// | |<-------------|
5558// | | |
5559// | RESTNotif | |
5560// |<----------------| |
5561// | | |
5562// | RESTSubReq | |
5563// |---------------->| |
5564// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005565// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005566// | | |
5567// | RESTSubDelReq | |
5568// |---------------->| |
5569// | | |
5570// | | SubDelReq |
5571// | |------------->|
5572// | | |
5573// | | SubDelResp |
5574// | |<-------------|
5575// | | |
5576// | RESTSubDelResp | |
5577// |<----------------| |
5578//
5579//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005580
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005581func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005582
5583 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5584 Counter{cRestSubReqFromXapp, 2},
5585 Counter{cRestSubRespToXapp, 1},
5586 Counter{cSubReqToE2, 1},
5587 Counter{cSubRespFromE2, 1},
5588 Counter{cRestSubNotifToXapp, 1},
5589 Counter{cRestSubFailToXapp, 1},
5590 Counter{cRestSubDelReqFromXapp, 1},
5591 Counter{cSubDelReqToE2, 1},
5592 Counter{cSubDelRespFromE2, 1},
5593 Counter{cRestSubDelRespToXapp, 1},
5594 })
5595
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005596 // Req
5597 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5598 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5599
5600 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005601 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5602
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005603 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005604 params.SetSubscriptionID(&restSubIdUpd)
5605 params.SetTimeToWait("w200ms")
5606
5607 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5608 assert.Equal(t, restSubId2, "")
5609
5610 // Del
5611 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5612
5613 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5614 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5615
5616 // Wait that subs is cleaned
5617 waitSubsCleanup(t, e2SubsId, 10)
5618 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005619 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005620}
5621
5622//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005623// TestRESTSubReqAndSubDelOkTwoE2termParallel
5624//
5625// stub stub stub
5626// +-------+ +---------+ +---------+ +---------+
5627// | xapp | | submgr | | e2term1 | | e2term2 |
5628// +-------+ +---------+ +---------+ +---------+
5629// | | | |
5630// | | | |
5631// | | | |
5632// | RESTSubReq1 | | |
5633// |---------------->| | |
5634// | | | |
5635// | RESTSubResp1 | | |
5636// |<----------------| | |
5637// | | SubReq1 | |
5638// | |------------->| |
5639// | | | |
5640// | RESTSubReq2 | | |
5641// |---------------->| | |
5642// | | | |
5643// | RESTSubResp2 | | |
5644// |<----------------| | |
5645// | | SubReq2 | |
5646// | |---------------------------->|
5647// | | | |
5648// | | SubResp1 | |
5649// | |<-------------| |
5650// | RESTNotif1 | | |
5651// |<----------------| | |
5652// | | SubResp2 | |
5653// | |<----------------------------|
5654// | RESTNotif2 | | |
5655// |<----------------| | |
5656// | | | |
5657// | [SUBS 1 DELETE] | |
5658// | | | |
5659// | [SUBS 2 DELETE] | |
5660// | | | |
5661//
5662//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005663
archaggeafbf95f2021-04-14 08:54:05 +03005664func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005665
5666 // Init counter check
5667 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005668 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005669 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005670 Counter{cSubReqToE2, 2},
5671 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005672 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005673 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005674 Counter{cSubDelReqToE2, 2},
5675 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005676 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005677 })
5678
5679 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005680
5681 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005682 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005683 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5684 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5685
5686 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005687 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005688 params.SetMeid("RAN_NAME_11")
5689 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5690 // would not work as notification would not be received
5691 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5692 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5693
5694 // Resp1
5695 xappConn1.ExpectRESTNotification(t, restSubId1)
5696 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5697 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005698 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005699
5700 // Resp2
5701 xappConn2.ExpectRESTNotification(t, restSubId2)
5702 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5703 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005704 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005705
5706 // Delete1
5707 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5708 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5709 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5710
5711 // Wait that subs is cleaned
5712 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5713
5714 // Delete2
5715 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5716 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5717 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5718
5719 // Wait that subs is cleaned
5720 waitSubsCleanup(t, e2SubsId2, 10)
5721
5722 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005723 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005724}
5725
5726//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005727// TestRESTSubReqInsertAndSubDelOk
5728//
5729// stub stub
5730// +-------+ +---------+ +---------+
5731// | xapp | | submgr | | e2term |
5732// +-------+ +---------+ +---------+
5733// | | |
5734// | RestSubReq | |
5735// |---------------->| |
5736// | | |
5737// | RESTSubResp | |
5738// |<----------------| |
5739// | | |
5740// | | SubReq |
5741// | |------------->|
5742// | | |
5743// | | SubResp |
5744// | |<-------------|
5745// | RESTNotif | |
5746// |<----------------| |
5747// | ... | ... |
5748// | | |
5749// | RESTSubDelReq | |
5750// |---------------->| |
5751// | | |
5752// | | SubDelReq |
5753// | |------------->|
5754// | | |
5755// | | SubDelResp |
5756// | |<-------------|
5757// | | |
5758// | RESTSubDelResp| |
5759// |<----------------| |
5760//
5761//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005762
archaggeafbf95f2021-04-14 08:54:05 +03005763func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005764
5765 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005766 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005767 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005768 Counter{cSubReqToE2, 1},
5769 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005770 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005771 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005772 Counter{cSubDelReqToE2, 1},
5773 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005774 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005775 })
5776
5777 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005778
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005779 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005780 params.SetSubActionTypes("insert")
5781
5782 // Req
5783 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5784
5785 // Del
5786 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5787
5788 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5789 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5790
5791 // Wait that subs is cleaned
5792 waitSubsCleanup(t, e2SubsId, 10)
5793 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005794 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005795}
5796
5797//-----------------------------------------------------------------------------
5798// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5799//
5800// stub stub
5801// +-------+ +---------+ +---------+
5802// | xapp | | submgr | | e2term |
5803// +-------+ +---------+ +---------+
5804// | | |
5805// | RESTSubReq | |
5806// |------------->| |
5807// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005808// | RESTSubResp | |
5809// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005810// | | SubReq |
5811// | |------------->|
5812// | | |
5813// | | SubResp |
5814// | <----|
5815// | |
5816// | Submgr restart |
5817// | |
5818// | | |
5819// | | SubDelReq |
5820// | |------------->|
5821// | | |
5822// | | SubDelResp |
5823// | |<-------------|
5824// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005825// | RESTNotif | |
5826// | unsuccess | |
5827// |<-------------| |
5828// | | |
5829// | RESTSubDelReq| |
5830// |------------->| |
5831// | | |
5832// |RESTSubDelResp| |
5833// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005834//
5835//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005836
archaggeafbf95f2021-04-14 08:54:05 +03005837func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005838
5839 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005840 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005841 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005842 Counter{cSubReqToE2, 1},
5843 Counter{cSubDelReqFromXapp, 1},
5844 Counter{cSubDelReqToE2, 1},
5845 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005846 Counter{cRestSubDelReqFromXapp, 1},
5847 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005848 })
5849
5850 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005851
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005852 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005853
5854 //Req
5855 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5856 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005857 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005858
5859 e2termConn1.RecvSubsReq(t)
5860
5861 mainCtrl.SetResetTestFlag(t, false)
5862
5863 mainCtrl.SimulateRestart(t)
5864 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5865
Anssi Mannilab43397e2021-11-16 12:06:16 +02005866 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005867 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5868 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5869
Anssi Mannilab43397e2021-11-16 12:06:16 +02005870 //Del
5871 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5872
archaggeafbf95f2021-04-14 08:54:05 +03005873 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005874 e2termConn1.TestMsgChanEmpty(t)
5875 mainCtrl.wait_registry_empty(t, 10)
5876
5877 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005878 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005879}
5880
5881//-----------------------------------------------------------------------------
5882// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5883//
5884// stub stub
5885// +-------+ +---------+ +---------+
5886// | xapp | | submgr | | e2term |
5887// +-------+ +---------+ +---------+
5888// | | |
5889// | RESTSubReq | |
5890// |---------------->| |
5891// | | |
5892// | RESTSubResp | |
5893// |<----------------| |
5894// | | SubReq |
5895// | |------------->|
5896// | | |
5897// | | SubResp |
5898// | |<-------------|
5899// | | |
5900// | RESTNotif | |
5901// |<----------------| |
5902// | | |
5903// | |
5904// | Submgr restart |
5905// | | |
5906// | RESTSubDelReq | |
5907// |---------------->| |
5908// | | |
5909// | | SubDelReq |
5910// | |------------->|
5911// | | |
5912// | | SubDelResp |
5913// | |<-------------|
5914// | | |
5915// | RESTSubDelResp | |
5916// |<----------------| |
5917//
5918//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005919
archaggeafbf95f2021-04-14 08:54:05 +03005920func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005921
5922 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005923 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005924 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005925 Counter{cSubReqToE2, 1},
5926 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005927 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005928 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005929 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005930 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005931 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005932 })
archaggeafbf95f2021-04-14 08:54:05 +03005933
5934 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005935 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005936 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005937 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005938
5939 // Check subscription
5940 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5941
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005942 mainCtrl.SimulateRestart(t)
5943 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005944
Anssi Mannila54838ed2021-11-19 11:25:01 +02005945 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5946 // That needs to be completed before successful subscription query is possible
5947 <-time.After(time.Second * 1)
5948
archaggeafbf95f2021-04-14 08:54:05 +03005949 // Check subscription
5950 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5951
5952 // Delete subscription
5953 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5954
5955 //Wait that subs is cleaned
5956 waitSubsCleanup(t, e2SubsId, 10)
5957
5958 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005959 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005960}
5961
5962//-----------------------------------------------------------------------------
5963// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5964//
5965// stub stub
5966// +-------+ +-------+ +---------+ +---------+
5967// | xapp2 | | xapp1 | | submgr | | e2term |
5968// +-------+ +-------+ +---------+ +---------+
5969// | | | |
5970// | | RESTSubReq1 | |
5971// | |---------------->| |
5972// | | | |
5973// | | RESTSubResp1 | |
5974// | |<----------------| |
5975// | | | |
5976// | | | SubReq1 |
5977// | | |------------->|
5978// | | | SubResp1 |
5979// | | |<-------------|
5980// | | RESTNotif1 | |
5981// | |<----------------| |
5982// | | | |
5983// | RESTSubReq2 | |
5984// |------------------------------>| |
5985// | | | |
5986// | RESTSubResp2 | |
5987// |<------------------------------| |
5988// | | | |
5989// | | RESTNotif2 | |
5990// |<------------------------------| |
5991// | | | |
5992// | | Submgr restart |
5993// | | | |
5994// | | RESTSubDelReq1 | |
5995// | |---------------->| |
5996// | | | |
5997// | | RESTSubDelResp1 | |
5998// | |<----------------| |
5999// | | | |
6000// | | Submgr restart |
6001// | | | |
6002// | RESTSubDelReq2 | |
6003// |------------------------------>| |
6004// | | | |
6005// | RESTSubDelResp2 | |
6006// |<------------------------------| |
6007// | | | |
6008// | | | SubDelReq2 |
6009// | | |------------->|
6010// | | | |
6011// | | | SubDelResp2 |
6012// | | |<-------------|
6013// | | | |
6014//
6015//-----------------------------------------------------------------------------
6016func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006017
6018 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006019 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006020 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006021 Counter{cSubReqToE2, 1},
6022 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006023 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006024 Counter{cMergedSubscriptions, 1},
6025 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006026 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006027 Counter{cSubDelReqToE2, 1},
6028 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006029 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006030 })
6031
archaggeafbf95f2021-04-14 08:54:05 +03006032 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02006033 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006034 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006035 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03006036
6037 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006038 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006039 params.SetMeid("RAN_NAME_1")
6040 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006041 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03006042 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006043 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006044 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006045 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03006046
6047 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
6048
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006049 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006050 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
6051
6052 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6053 // That needs to be completed before successful subscription delete is possible
6054 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03006055
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006056 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03006057 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02006058 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006059 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02006060
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006061 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006062 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
6063
6064 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6065 // That needs to be completed before successful subscription query is possible
6066 <-time.After(time.Second * 1)
6067
archaggeafbf95f2021-04-14 08:54:05 +03006068 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
6069
6070 // Delete subscription 2
6071 deleteXapp2Subscription(t, &restSubId2)
6072
6073 //Wait that subs is cleaned
6074 waitSubsCleanup(t, e2SubsId2, 10)
6075
6076 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006077 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006078}
6079
6080//-----------------------------------------------------------------------------
6081// TestRESTReportSubReqAndSubDelOk
6082//
6083// stub stub
6084// +-------+ +---------+ +---------+
6085// | xapp | | submgr | | e2term |
6086// +-------+ +---------+ +---------+
6087// | | |
6088// | RestSubReq | |
6089// |---------------->| |
6090// | | |
6091// | RESTSubResp | |
6092// |<----------------| |
6093// | | |
6094// | | SubReq |
6095// | |------------->|
6096// | | |
6097// | | SubResp |
6098// | |<-------------|
6099// | RESTNotif | |
6100// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02006101// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03006102// | |------------->|
6103// | | |
6104// | | SubResp |
6105// | |<-------------|
6106// | RESTNotif | |
6107// |<----------------| |
6108// | ... | ... |
6109// | | |
6110// | | |
6111// | RESTSubDelReq | |
6112// |---------------->| |
6113// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006114// | RESTSubDelResp| |
6115// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006116// | | SubDelReq |
6117// | |------------->|
6118// | | |
6119// | | SubDelResp |
6120// | |<-------------|
6121// | | |
archaggeafbf95f2021-04-14 08:54:05 +03006122//
6123//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006124
archaggeafbf95f2021-04-14 08:54:05 +03006125func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006126 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006127 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006128 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006129}
6130
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006131func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006132 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006133
Anssi Mannila21782182021-12-10 10:56:02 +02006134 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6135 Counter{cRestSubReqFromXapp, 1},
6136 Counter{cRestSubRespToXapp, 1},
6137 Counter{cSubReqToE2, uint64(subReqCount)},
6138 Counter{cSubRespFromE2, uint64(subReqCount)},
6139 Counter{cRestSubNotifToXapp, 1},
6140 Counter{cRestSubDelReqFromXapp, 1},
6141 Counter{cRestSubDelRespToXapp, 1},
6142 Counter{cSubDelReqToE2, uint64(subReqCount)},
6143 Counter{cSubDelRespFromE2, uint64(subReqCount)},
6144 })
6145
archaggeafbf95f2021-04-14 08:54:05 +03006146 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006147 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006148 restSubId := xappConn1.SendRESTSubsReq(t, params)
6149
6150 var e2SubsId []uint32
6151 for i := 0; i < subReqCount; i++ {
6152 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6153 xappConn1.ExpectRESTNotification(t, restSubId)
6154
6155 e2termConn1.SendSubsResp(t, crereq, cremsg)
6156 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006157 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03006158 e2SubsId = append(e2SubsId, instanceId)
6159 resp, _ := xapp.Subscription.QuerySubscriptions()
6160 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
6161 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
6162 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
6163
6164 }
6165
6166 // Del
6167 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6168
6169 for i := 0; i < subReqCount; i++ {
6170 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6171 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6172 }
6173
6174 // Wait that subs is cleaned
6175 for i := 0; i < subReqCount; i++ {
6176 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6177 }
6178
6179 xappConn1.TestMsgChanEmpty(t)
6180 e2termConn1.TestMsgChanEmpty(t)
6181 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006182 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006183 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006184}
6185
Anssi Mannila27385172021-12-22 09:41:54 +02006186//-----------------------------------------------------------------------------
6187// TestRESTTwoPolicySubReqAndSubDelOk
6188//
6189// stub stub
6190// +-------+ +---------+ +---------+
6191// | xapp | | submgr | | e2term |
6192// +-------+ +---------+ +---------+
6193// | | |
6194// | RestSubReq | |
6195// |---------------->| |
6196// | | |
6197// | RESTSubResp | |
6198// |<----------------| |
6199// | | |
6200// | | SubReq |
6201// | |------------->|
6202// | | |
6203// | | SubResp |
6204// | |<-------------|
6205// | RESTNotif | |
6206// |<----------------| |
6207// | | SubReq |
6208// | |------------->|
6209// | | |
6210// | | SubResp |
6211// | |<-------------|
6212// | RESTNotif | |
6213// |<----------------| |
6214// | | |
6215// | RESTSubDelReq | |
6216// |---------------->| |
6217// | | |
6218// | RESTSubDelResp| |
6219// |<----------------| |
6220// | | SubDelReq |
6221// | |------------->|
6222// | | |
6223// | | SubDelResp |
6224// | |<-------------|
6225// | | |
6226// | | SubDelReq |
6227// | |------------->|
6228// | | |
6229// | | SubDelResp |
6230// | |<-------------|
6231// | | |
6232//
6233//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006234
archaggeafbf95f2021-04-14 08:54:05 +03006235func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6236
archaggeafbf95f2021-04-14 08:54:05 +03006237 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006238 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006239 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006240 Counter{cSubReqToE2, 2},
6241 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006242 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006243 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006244 Counter{cSubDelReqToE2, 2},
6245 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006246 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006247 })
6248
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006249 const subReqCount int = 2
6250
archaggeafbf95f2021-04-14 08:54:05 +03006251 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006252 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006253 restSubId := xappConn1.SendRESTSubsReq(t, params)
6254 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6255
6256 assert.Equal(t, len(e2SubsIds), 2)
6257
6258 // Del
6259 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6260 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6261
6262 xappConn1.TestMsgChanEmpty(t)
6263 e2termConn1.TestMsgChanEmpty(t)
6264 mainCtrl.wait_registry_empty(t, 10)
6265
6266 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006267 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006268}
Anssi Mannila27385172021-12-22 09:41:54 +02006269
6270//-----------------------------------------------------------------------------
6271// TestRESTPolicySubReqAndSubDelOk19E2Subs
6272//
6273// stub stub
6274// +-------+ +---------+ +---------+
6275// | xapp | | submgr | | e2term |
6276// +-------+ +---------+ +---------+
6277// | | |
6278// | RestSubReq | |
6279// |---------------->| |
6280// | | |
6281// | RESTSubResp | |
6282// |<----------------| |
6283// | | | ------
6284// | | SubReq |
6285// | |------------->|
6286// | | | E2 subscription x 19
6287// | | SubResp |
6288// | |<-------------|
6289// | RESTNotif | |
6290// |<----------------| |
6291// | | | ------
6292// | RESTSubDelReq | |
6293// |---------------->| |
6294// | | |
6295// | RESTSubDelResp| |
6296// |<----------------| |
6297// | | SubDelReq | ------
6298// | |------------->|
6299// | | | E2 subscription delete x 19
6300// | | SubDelResp |
6301// | |<-------------|
6302// | | | ------
6303// | | |
6304//
6305//-----------------------------------------------------------------------------
6306
6307func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006308
archaggeafbf95f2021-04-14 08:54:05 +03006309 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006310 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006311 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006312 Counter{cSubReqToE2, 19},
6313 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006314 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006315 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006316 Counter{cSubDelReqToE2, 19},
6317 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006318 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006319 })
6320
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006321 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006322 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006323 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006324 restSubId := xappConn1.SendRESTSubsReq(t, params)
6325 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6326
6327 assert.Equal(t, len(e2SubsIds), 19)
6328
6329 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6330 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6331
6332 xappConn1.TestMsgChanEmpty(t)
6333 e2termConn1.TestMsgChanEmpty(t)
6334 mainCtrl.wait_registry_empty(t, 10)
6335
6336 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006337 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006338}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006339
Anssi Mannila27385172021-12-22 09:41:54 +02006340//-----------------------------------------------------------------------------
6341// TestRESTTwoPolicySubReqAndSubDelOk
6342//
6343// stub stub
6344// +-------+ +---------+ +---------+
6345// | xapp | | submgr | | e2term |
6346// +-------+ +---------+ +---------+
6347// | | |
6348// | RestSubReq | |
6349// |---------------->| |
6350// | | |
6351// | RESTSubResp | |
6352// |<----------------| |
6353// | | |
6354// | | SubReq |
6355// | |------------->|
6356// | | |
6357// | | SubResp |
6358// | |<-------------|
6359// | RESTNotif | |
6360// |<----------------| |
6361// | | SubReq |
6362// | |------------->|
6363// | | |
6364// | | SubResp |
6365// | |<-------------|
6366// | RESTNotif | |
6367// |<----------------| |
6368// | | |
6369// | RESTSubDelReq | |
6370// |---------------->| |
6371// | | |
6372// | RESTSubDelResp| |
6373// |<----------------| |
6374// | | SubDelReq |
6375// | |------------->|
6376// | | |
6377// | | SubDelResp |
6378// | |<-------------|
6379// | | |
6380// | | SubDelReq |
6381// | |------------->|
6382// | | |
6383// | | SubDelResp |
6384// | |<-------------|
6385// | | |
6386//
6387//-----------------------------------------------------------------------------
6388
archaggeafbf95f2021-04-14 08:54:05 +03006389func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6390
6391 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006392
6393 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006394 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006395 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006396 Counter{cSubReqToE2, uint64(subReqCount)},
6397 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006398 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006399 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006400 Counter{cSubDelReqToE2, uint64(subReqCount)},
6401 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006402 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006403 })
6404
6405 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006406 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006407 restSubId := xappConn1.SendRESTSubsReq(t, params)
6408 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6409
6410 assert.Equal(t, len(e2SubsIds), subReqCount)
6411
6412 // Del
6413 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6414 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6415
6416 xappConn1.TestMsgChanEmpty(t)
6417 e2termConn1.TestMsgChanEmpty(t)
6418 mainCtrl.wait_registry_empty(t, 10)
6419
6420 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006421 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006422}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006423
Anssi Mannila27385172021-12-22 09:41:54 +02006424//-----------------------------------------------------------------------------
6425// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6426//
6427// stub stub
6428// +-------+ +---------+ +---------+
6429// | xapp | | submgr | | e2term |
6430// +-------+ +---------+ +---------+
6431// | | |
6432// | RestSubReq | |
6433// |---------------->| |
6434// | | |
6435// | RESTSubResp | |
6436// |<----------------| |
6437// | | |
6438// | | SubReq |
6439// | |------------->|
6440// | | |
6441// | | SubResp |
6442// | |<-------------|
6443// | RESTNotif | |
6444// |<----------------| |
6445// | | SubReq |
6446// | |------------->|
6447// | | |
6448// | | SubResp |
6449// | |<-------------|
6450// | RESTNotif | |
6451// |<----------------| |
6452// | | |
6453// | RESTSubDelReq | |
6454// |---------------->| |
6455// | | |
6456// | RESTSubDelResp| |
6457// |<----------------| |
6458// | | SubDelReq |
6459// | |------------->|
6460// | | |
6461// | | SubDelResp |
6462// | |<-------------|
6463// | | |
6464// | | SubDelReq |
6465// | |------------->|
6466// | | |
6467// | | SubDelResp |
6468// | |<-------------|
6469// | | |
6470//
6471//-----------------------------------------------------------------------------
6472
archaggeafbf95f2021-04-14 08:54:05 +03006473func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6474
6475 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006476
6477 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006478 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006479 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006480 Counter{cSubReqToE2, uint64(subReqCount)},
6481 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006482 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006483 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006484 Counter{cSubDelReqToE2, uint64(subReqCount)},
6485 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006486 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006487 })
6488
6489 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006490 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006491 restSubId := xappConn1.SendRESTSubsReq(t, params)
6492 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6493
6494 assert.Equal(t, len(e2SubsIds), subReqCount)
6495
6496 // Del
6497 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6498 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6499
6500 xappConn1.TestMsgChanEmpty(t)
6501 e2termConn1.TestMsgChanEmpty(t)
6502 mainCtrl.wait_registry_empty(t, 10)
6503
6504 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006505 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006506}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006507
Anssi Mannila27385172021-12-22 09:41:54 +02006508//-----------------------------------------------------------------------------
6509// TestRESTReportSubReqAndSubDelOk19E2Subs
6510//
6511// stub stub
6512// +-------+ +---------+ +---------+
6513// | xapp | | submgr | | e2term |
6514// +-------+ +---------+ +---------+
6515// | | |
6516// | RestSubReq | |
6517// |---------------->| |
6518// | | |
6519// | RESTSubResp | |
6520// |<----------------| |
6521// | | | ------
6522// | | SubReq |
6523// | |------------->|
6524// | | | E2 subscription x 19
6525// | | SubResp |
6526// | |<-------------|
6527// | RESTNotif | |
6528// |<----------------| |
6529// | | | ------
6530// | RESTSubDelReq | |
6531// |---------------->| |
6532// | | |
6533// | RESTSubDelResp| |
6534// |<----------------| |
6535// | | SubDelReq | ------
6536// | |------------->|
6537// | | | E2 subscription delete x 19
6538// | | SubDelResp |
6539// | |<-------------|
6540// | | | ------
6541// | | |
6542//
6543//-----------------------------------------------------------------------------
6544
6545func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006546
6547 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006548
6549 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006550 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006551 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006552 Counter{cSubReqToE2, uint64(subReqCount)},
6553 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006554 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006555 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006556 Counter{cSubDelReqToE2, uint64(subReqCount)},
6557 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006558 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006559 })
6560
6561 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006562 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006563 restSubId := xappConn1.SendRESTSubsReq(t, params)
6564 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6565
6566 assert.Equal(t, len(e2SubsIds), subReqCount)
6567
6568 // Del
6569 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6570 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6571
6572 xappConn1.TestMsgChanEmpty(t)
6573 e2termConn1.TestMsgChanEmpty(t)
6574 mainCtrl.wait_registry_empty(t, 10)
6575
6576 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006577 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006578}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006579
Anssi Mannila27385172021-12-22 09:41:54 +02006580//-----------------------------------------------------------------------------
6581// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6582//
6583// stub stub stub
6584// +-------+ +-------+ +---------+ +---------+
6585// | xapp2 | | xapp1 | | submgr | | e2term |
6586// +-------+ +-------+ +---------+ +---------+
6587// | | | |
6588// | | RESTSubReq1 | |
6589// | |------------->| |
6590// | | RESTSubResp1 | |
6591// | |<-------------| |
6592// | | | |
6593// | | | SubReq1 |
6594// | | |------------->|
6595// | | | |
6596// | RESTSubReq2 | |
6597// |------------------------>| |
6598// | RESTSubResp2 | |
6599// |<------------------------| |
6600// | | | |
6601// | | | SubReq2 |
6602// | | |------------->|
6603// | | | |
6604// | | | SubResp1 |
6605// | | |<-------------|
6606// | | RESTNotif1 | |
6607// | |<-------------| |
6608// | | | |
6609// | | | SubResp2 |
6610// | | |<-------------|
6611// | RESTNotif2 | |
6612// |<------------------------| |
6613// | | | |
6614// | | [SUBS 1 DELETE] |
6615// | | | |
6616// | | [SUBS 2 DELETE] |
6617// | | | |
6618//
6619//-----------------------------------------------------------------------------
6620
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006621func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006622
6623 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006624 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006625 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006626 Counter{cSubReqToE2, 2},
6627 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006628 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006629 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006630 Counter{cSubDelReqToE2, 2},
6631 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006632 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006633 })
6634
6635 // Req1
6636 var params *teststube2ap.RESTSubsReqParams = nil
6637
6638 //Subs Create
6639 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006640 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006641
6642 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6643
6644 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006645 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006646 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006647 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006648 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6649
6650 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006651 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006652 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6653 xappConn2.ExpectRESTNotification(t, restSubId2)
6654 e2termConn1.SendSubsResp(t, crereq, cremsg)
6655 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6656
6657 deleteXapp1Subscription(t, &restSubId1)
6658 deleteXapp2Subscription(t, &restSubId2)
6659
6660 waitSubsCleanup(t, e2SubsId1, 10)
6661 waitSubsCleanup(t, e2SubsId2, 10)
6662
6663 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006664 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006665}
6666
Anssi Mannila27385172021-12-22 09:41:54 +02006667//-----------------------------------------------------------------------------
6668// TestRESTSubReqReportSameActionDiffActionListLen
6669//
6670// stub stub stub
6671// +-------+ +-------+ +---------+ +---------+
6672// | xapp2 | | xapp1 | | submgr | | e2term |
6673// +-------+ +-------+ +---------+ +---------+
6674// | | | |
6675// | | RESTSubReq1 | |
6676// | |------------->| |
6677// | | RESTSubResp1 | |
6678// | |<-------------| |
6679// | | | |
6680// | | | SubReq1 |
6681// | | |------------->|
6682// | | | |
6683// | RESTSubReq2 | |
6684// |------------------------>| |
6685// | RESTSubResp2 | |
6686// |<------------------------| |
6687// | | | |
6688// | | | SubReq2 |
6689// | | |------------->|
6690// | | | |
6691// | | | SubResp1 |
6692// | | |<-------------|
6693// | | RESTNotif1 | |
6694// | |<-------------| |
6695// | | | |
6696// | | | SubResp2 |
6697// | | |<-------------|
6698// | RESTNotif2 | |
6699// |<------------------------| |
6700// | | | |
6701// | | [SUBS 1 DELETE] |
6702// | | | |
6703// | | [SUBS 2 DELETE] |
6704// | | | |
6705//
6706//-----------------------------------------------------------------------------
6707
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006708func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006709
6710 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006711 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006712 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006713 Counter{cSubReqToE2, 2},
6714 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006715 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006716 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006717 Counter{cSubDelReqToE2, 2},
6718 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006719 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006720 })
6721
6722 // Req1
6723 var params *teststube2ap.RESTSubsReqParams = nil
6724
6725 //Subs Create
6726 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006727 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006728
6729 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6730
6731 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006732 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006733 params.SetMeid("RAN_NAME_1")
6734
6735 actionId := int64(1)
6736 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006737 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006738 subsequestActionType := "continue"
6739 timeToWait := "w10ms"
6740 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6741
6742 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006743 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006744 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6745 xappConn2.ExpectRESTNotification(t, restSubId2)
6746 e2termConn1.SendSubsResp(t, crereq, cremsg)
6747 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6748
6749 deleteXapp1Subscription(t, &restSubId1)
6750 deleteXapp2Subscription(t, &restSubId2)
6751
6752 waitSubsCleanup(t, e2SubsId1, 10)
6753 waitSubsCleanup(t, e2SubsId2, 10)
6754
6755 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006756 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006757}
6758
Anssi Mannila27385172021-12-22 09:41:54 +02006759//-----------------------------------------------------------------------------
6760// TestRESTSubReqReportSameActionDiffActionID
6761//
6762// stub stub stub
6763// +-------+ +-------+ +---------+ +---------+
6764// | xapp2 | | xapp1 | | submgr | | e2term |
6765// +-------+ +-------+ +---------+ +---------+
6766// | | | |
6767// | | RESTSubReq1 | |
6768// | |------------->| |
6769// | | RESTSubResp1 | |
6770// | |<-------------| |
6771// | | | |
6772// | | | SubReq1 |
6773// | | |------------->|
6774// | | | |
6775// | RESTSubReq2 | |
6776// |------------------------>| |
6777// | RESTSubResp2 | |
6778// |<------------------------| |
6779// | | | |
6780// | | | SubReq2 |
6781// | | |------------->|
6782// | | | |
6783// | | | SubResp1 |
6784// | | |<-------------|
6785// | | RESTNotif1 | |
6786// | |<-------------| |
6787// | | | |
6788// | | | SubResp2 |
6789// | | |<-------------|
6790// | RESTNotif2 | |
6791// |<------------------------| |
6792// | | | |
6793// | | [SUBS 1 DELETE] |
6794// | | | |
6795// | | [SUBS 2 DELETE] |
6796// | | | |
6797//
6798//-----------------------------------------------------------------------------
6799
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006800func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006801
6802 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006803 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006804 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006805 Counter{cSubReqToE2, 2},
6806 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006807 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006808 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006809 Counter{cSubDelReqToE2, 2},
6810 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006811 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006812 })
6813
6814 // Req1
6815 var params *teststube2ap.RESTSubsReqParams = nil
6816
6817 //Subs Create
6818 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006819 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006820
6821 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6822
6823 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006824 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006825 params.SetMeid("RAN_NAME_1")
6826 params.SetSubActionIDs(int64(2))
6827
6828 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006829 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006830 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6831 xappConn2.ExpectRESTNotification(t, restSubId2)
6832 e2termConn1.SendSubsResp(t, crereq, cremsg)
6833 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6834
6835 deleteXapp1Subscription(t, &restSubId1)
6836 deleteXapp2Subscription(t, &restSubId2)
6837
6838 waitSubsCleanup(t, e2SubsId1, 10)
6839 waitSubsCleanup(t, e2SubsId2, 10)
6840
6841 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006842 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006843}
6844
Anssi Mannila27385172021-12-22 09:41:54 +02006845//-----------------------------------------------------------------------------
6846// TestRESTSubReqDiffActionType
6847//
6848// stub stub stub
6849// +-------+ +-------+ +---------+ +---------+
6850// | xapp2 | | xapp1 | | submgr | | e2term |
6851// +-------+ +-------+ +---------+ +---------+
6852// | | | |
6853// | | RESTSubReq1 | |
6854// | |------------->| |
6855// | | RESTSubResp1 | |
6856// | |<-------------| |
6857// | | | |
6858// | | | SubReq1 |
6859// | | |------------->|
6860// | | | |
6861// | RESTSubReq2 | |
6862// |------------------------>| |
6863// | RESTSubResp2 | |
6864// |<------------------------| |
6865// | | | |
6866// | | | SubReq2 |
6867// | | |------------->|
6868// | | | |
6869// | | | SubResp1 |
6870// | | |<-------------|
6871// | | RESTNotif1 | |
6872// | |<-------------| |
6873// | | | |
6874// | | | SubResp2 |
6875// | | |<-------------|
6876// | RESTNotif2 | |
6877// |<------------------------| |
6878// | | | |
6879// | | [SUBS 1 DELETE] |
6880// | | | |
6881// | | [SUBS 2 DELETE] |
6882// | | | |
6883//
6884//-----------------------------------------------------------------------------
6885
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006886func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006887
6888 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006889 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006890 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006891 Counter{cSubReqToE2, 2},
6892 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006893 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006894 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006895 Counter{cSubDelReqToE2, 2},
6896 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006897 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006898 })
6899
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006900 const e2Timeout int64 = 2
6901 const e2RetryCount int64 = 2
6902 const routingNeeded bool = true
6903
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006904 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006905 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006906 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006907
6908 //Subs Create
6909 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006910 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006911
6912 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6913
6914 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006915 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006916 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006917 params.SetMeid("RAN_NAME_1")
6918
6919 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006920 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006921 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6922 xappConn2.ExpectRESTNotification(t, restSubId2)
6923 e2termConn1.SendSubsResp(t, crereq, cremsg)
6924 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6925
6926 deleteXapp1Subscription(t, &restSubId1)
6927 deleteXapp2Subscription(t, &restSubId2)
6928
6929 waitSubsCleanup(t, e2SubsId1, 10)
6930 waitSubsCleanup(t, e2SubsId2, 10)
6931
6932 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006933 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006934}
6935
Anssi Mannila27385172021-12-22 09:41:54 +02006936//-----------------------------------------------------------------------------
6937// TestRESTSubReqPolicyAndSubDelOkSameAction
6938//
6939// stub stub stub
6940// +-------+ +-------+ +---------+ +---------+
6941// | xapp2 | | xapp1 | | submgr | | e2term |
6942// +-------+ +-------+ +---------+ +---------+
6943// | | | |
6944// | | RESTSubReq1 | |
6945// | |------------->| |
6946// | | RESTSubResp1 | |
6947// | |<-------------| |
6948// | | | |
6949// | | | SubReq1 |
6950// | | |------------->|
6951// | | | |
6952// | RESTSubReq2 | |
6953// |------------------------>| |
6954// | RESTSubResp2 | |
6955// |<------------------------| |
6956// | | | |
6957// | | | SubReq2 |
6958// | | |------------->|
6959// | | | |
6960// | | | SubResp1 |
6961// | | |<-------------|
6962// | | RESTNotif1 | |
6963// | |<-------------| |
6964// | | | |
6965// | | | SubResp2 |
6966// | | |<-------------|
6967// | RESTNotif2 | |
6968// |<------------------------| |
6969// | | | |
6970// | | [SUBS 1 DELETE] |
6971// | | | |
6972// | | [SUBS 2 DELETE] |
6973// | | | |
6974//
6975//-----------------------------------------------------------------------------
6976
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006977func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006978
6979 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006980 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006981 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006982 Counter{cSubReqToE2, 2},
6983 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006984 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006985 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006986 Counter{cSubDelReqToE2, 2},
6987 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006988 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006989 })
6990
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006991 const e2Timeout int64 = 2
6992 const e2RetryCount int64 = 2
6993 const routingNeeded bool = true
6994
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006995 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006996 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006997 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006998
6999 //Subs Create
7000 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007001 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007002
7003 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7004
7005 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007006 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007007 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007008 params.SetMeid("RAN_NAME_1")
7009
7010 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007011 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007012 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7013 xappConn2.ExpectRESTNotification(t, restSubId2)
7014 e2termConn1.SendSubsResp(t, crereq, cremsg)
7015 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7016
7017 deleteXapp1Subscription(t, &restSubId1)
7018 deleteXapp2Subscription(t, &restSubId2)
7019
7020 waitSubsCleanup(t, e2SubsId1, 10)
7021 waitSubsCleanup(t, e2SubsId2, 10)
7022
7023 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007024 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007025}
7026
Anssi Mannila27385172021-12-22 09:41:54 +02007027//-----------------------------------------------------------------------------
7028// TestRESTSubReqReportSameActionDiffActionDefinitionLen
7029//
7030// stub stub stub
7031// +-------+ +-------+ +---------+ +---------+
7032// | xapp2 | | xapp1 | | submgr | | e2term |
7033// +-------+ +-------+ +---------+ +---------+
7034// | | | |
7035// | | RESTSubReq1 | |
7036// | |------------->| |
7037// | | RESTSubResp1 | |
7038// | |<-------------| |
7039// | | | |
7040// | | | SubReq1 |
7041// | | |------------->|
7042// | | | |
7043// | RESTSubReq2 | |
7044// |------------------------>| |
7045// | RESTSubResp2 | |
7046// |<------------------------| |
7047// | | | |
7048// | | | SubReq2 |
7049// | | |------------->|
7050// | | | |
7051// | | | SubResp1 |
7052// | | |<-------------|
7053// | | RESTNotif1 | |
7054// | |<-------------| |
7055// | | | |
7056// | | | SubResp2 |
7057// | | |<-------------|
7058// | RESTNotif2 | |
7059// |<------------------------| |
7060// | | | |
7061// | | [SUBS 1 DELETE] |
7062// | | | |
7063// | | [SUBS 2 DELETE] |
7064// | | | |
7065//
7066//-----------------------------------------------------------------------------
7067
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007068func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007069
7070 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007071 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007072 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007073 Counter{cSubReqToE2, 2},
7074 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007075 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007076 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007077 Counter{cSubDelReqToE2, 2},
7078 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007079 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007080 })
7081
7082 // Req1
7083 var params *teststube2ap.RESTSubsReqParams = nil
7084
7085 //Subs Create
7086 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007087 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007088
7089 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7090
7091 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007092 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007093 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007094 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007095 params.SetSubActionDefinition(actionDefinition)
7096
7097 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007098 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007099 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7100 xappConn2.ExpectRESTNotification(t, restSubId2)
7101 e2termConn1.SendSubsResp(t, crereq, cremsg)
7102 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7103
7104 deleteXapp1Subscription(t, &restSubId1)
7105 deleteXapp2Subscription(t, &restSubId2)
7106
7107 waitSubsCleanup(t, e2SubsId1, 10)
7108 waitSubsCleanup(t, e2SubsId2, 10)
7109
7110 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007111 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007112}
7113
Anssi Mannila27385172021-12-22 09:41:54 +02007114//-----------------------------------------------------------------------------
7115// TestRESTSubReqReportSameActionDiffActionDefinitionContents
7116//
7117// stub stub stub
7118// +-------+ +-------+ +---------+ +---------+
7119// | xapp2 | | xapp1 | | submgr | | e2term |
7120// +-------+ +-------+ +---------+ +---------+
7121// | | | |
7122// | | RESTSubReq1 | |
7123// | |------------->| |
7124// | | RESTSubResp1 | |
7125// | |<-------------| |
7126// | | | |
7127// | | | SubReq1 |
7128// | | |------------->|
7129// | | | |
7130// | RESTSubReq2 | |
7131// |------------------------>| |
7132// | RESTSubResp2 | |
7133// |<------------------------| |
7134// | | | |
7135// | | | SubReq2 |
7136// | | |------------->|
7137// | | | |
7138// | | | SubResp1 |
7139// | | |<-------------|
7140// | | RESTNotif1 | |
7141// | |<-------------| |
7142// | | | |
7143// | | | SubResp2 |
7144// | | |<-------------|
7145// | RESTNotif2 | |
7146// |<------------------------| |
7147// | | | |
7148// | | [SUBS 1 DELETE] |
7149// | | | |
7150// | | [SUBS 2 DELETE] |
7151// | | | |
7152//
7153//-----------------------------------------------------------------------------
7154
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007155func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007156
7157 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007158 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007159 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007160 Counter{cSubReqToE2, 2},
7161 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007162 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007163 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007164 Counter{cSubDelReqToE2, 2},
7165 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007166 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007167 })
7168
7169 // Req1
7170 var params *teststube2ap.RESTSubsReqParams = nil
7171
7172 //Subs Create
7173 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007174 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007175
7176 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7177
7178 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007179 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007180 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007181 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007182 params.SetSubActionDefinition(actionDefinition)
7183
7184 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007185 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007186 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7187 xappConn2.ExpectRESTNotification(t, restSubId2)
7188 e2termConn1.SendSubsResp(t, crereq, cremsg)
7189 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7190
7191 deleteXapp1Subscription(t, &restSubId1)
7192 deleteXapp2Subscription(t, &restSubId2)
7193
7194 waitSubsCleanup(t, e2SubsId1, 10)
7195 waitSubsCleanup(t, e2SubsId2, 10)
7196
7197 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007198 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007199}
7200
Anssi Mannila27385172021-12-22 09:41:54 +02007201//-----------------------------------------------------------------------------
7202// TestRESTSubReqReportSameActionDiffSubsAction
7203//
7204// stub stub stub
7205// +-------+ +-------+ +---------+ +---------+
7206// | xapp2 | | xapp1 | | submgr | | e2term |
7207// +-------+ +-------+ +---------+ +---------+
7208// | | | |
7209// | | RESTSubReq1 | |
7210// | |------------->| |
7211// | | RESTSubResp1 | |
7212// | |<-------------| |
7213// | | | |
7214// | | | SubReq1 |
7215// | | |------------->|
7216// | | | |
7217// | RESTSubReq2 | |
7218// |------------------------>| |
7219// | RESTSubResp2 | |
7220// |<------------------------| |
7221// | | | |
7222// | | | SubReq2 |
7223// | | |------------->|
7224// | | | |
7225// | | | SubResp1 |
7226// | | |<-------------|
7227// | | RESTNotif1 | |
7228// | |<-------------| |
7229// | | | |
7230// | | | SubResp2 |
7231// | | |<-------------|
7232// | RESTNotif2 | |
7233// |<------------------------| |
7234// | | | |
7235// | | [SUBS 1 DELETE] |
7236// | | | |
7237// | | [SUBS 2 DELETE] |
7238// | | | |
7239//
7240//-----------------------------------------------------------------------------
7241
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007242func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007243
7244 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007245 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007246 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007247 Counter{cSubReqToE2, 2},
7248 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007249 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007250 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007251 Counter{cSubDelReqToE2, 2},
7252 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007253 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007254 })
7255
7256 // Req1
7257 var params *teststube2ap.RESTSubsReqParams = nil
7258
7259 //Subs Create
7260 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007261 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007262
7263 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7264
7265 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007266 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007267 params.SetMeid("RAN_NAME_1")
7268 params.SetTimeToWait("w200ms")
7269 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007270 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007271 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7272 xappConn2.ExpectRESTNotification(t, restSubId2)
7273 e2termConn1.SendSubsResp(t, crereq, cremsg)
7274 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7275
7276 deleteXapp1Subscription(t, &restSubId1)
7277 deleteXapp2Subscription(t, &restSubId2)
7278
7279 waitSubsCleanup(t, e2SubsId1, 10)
7280 waitSubsCleanup(t, e2SubsId2, 10)
7281
7282 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007283 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007284}
7285
Anssi Mannila51122392021-05-25 11:51:31 +03007286//-----------------------------------------------------------------------------
7287// TestRESTUnpackSubscriptionResponseDecodeFail
7288//
7289// stub stub
7290// +-------+ +---------+ +---------+
7291// | xapp | | submgr | | e2term |
7292// +-------+ +---------+ +---------+
7293// | | |
7294// | RestSubReq | |
7295// |---------------->| |
7296// | | |
7297// | RESTSubResp | |
7298// |<----------------| |
7299// | | |
7300// | | SubReq |
7301// | |------------->|
7302// | | |
7303// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007304// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007305// | | |
7306// | | SubReq |
7307// | |------------->|
7308// | | |
7309// | | SubFail | Duplicated action
7310// | |<-------------|
7311// | RESTNotif (fail)| |
7312// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007313// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007314// | [SUBS DELETE] |
7315// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007316//
7317//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007318
Anssi Mannila51122392021-05-25 11:51:31 +03007319func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007320
7321 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7322 Counter{cRestSubReqFromXapp, 1},
7323 Counter{cRestSubRespToXapp, 1},
7324 Counter{cSubReqToE2, 1},
7325 Counter{cSubReqTimerExpiry, 1},
7326 Counter{cSubReReqToE2, 1},
7327 Counter{cSubRespFromE2, 1},
7328 Counter{cSubFailFromE2, 1},
7329 Counter{cRestSubFailNotifToXapp, 1},
7330 Counter{cRestSubDelReqFromXapp, 1},
7331 Counter{cRestSubDelRespToXapp, 1},
7332 })
7333
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007334 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007335
7336 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007337 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007338 restSubId := xappConn1.SendRESTSubsReq(t, params)
7339
7340 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7341 // Decode of this response fails which will result resending original request
7342 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7343
7344 _, cremsg = e2termConn1.RecvSubsReq(t)
7345
Markku Virtanen55d2a282021-06-04 14:46:56 +03007346 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007347
7348 // Subscription already created in E2 Node.
7349 fparams := &teststube2ap.E2StubSubsFailParams{}
7350 fparams.Set(crereq)
7351 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7352 e2termConn1.SendSubsFail(t, fparams, cremsg)
7353
Anssi Mannila51122392021-05-25 11:51:31 +03007354 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007355 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007356
Anssi Mannilab43397e2021-11-16 12:06:16 +02007357 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7358
Anssi Mannila51122392021-05-25 11:51:31 +03007359 // Wait that subs is cleaned
7360 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7361
7362 xappConn1.TestMsgChanEmpty(t)
7363 e2termConn1.TestMsgChanEmpty(t)
7364 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007365 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007366 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007367}
7368
7369//-----------------------------------------------------------------------------
7370// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7371//
7372// stub stub
7373// +-------+ +---------+ +---------+
7374// | xapp | | submgr | | e2term |
7375// +-------+ +---------+ +---------+
7376// | | |
7377// | RestSubReq | |
7378// |---------------->| |
7379// | | |
7380// | RESTSubResp | |
7381// |<----------------| |
7382// | | |
7383// | | SubReq |
7384// | |------------->|
7385// | | |
7386// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007387// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007388// | | |
7389// | | SubReq |
7390// | |------------->|
7391// | | |
7392// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007393// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007394// | RESTNotif (fail)| |
7395// |<----------------| |
7396// | | SubDelReq |
7397// | |------------->|
7398// | | |
7399// | | SubDelResp |
7400// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007401// | | |
7402// | [SUBS DELETE] |
7403// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007404//
7405//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007406
Anssi Mannila51122392021-05-25 11:51:31 +03007407func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007408
7409 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7410 Counter{cRestSubReqFromXapp, 1},
7411 Counter{cRestSubRespToXapp, 1},
7412 Counter{cSubReqToE2, 1},
7413 Counter{cSubReqTimerExpiry, 2},
7414 Counter{cSubReReqToE2, 1},
7415 Counter{cSubRespFromE2, 1},
7416 Counter{cSubFailFromE2, 1},
7417 Counter{cRestSubFailNotifToXapp, 1},
7418 Counter{cRestSubDelReqFromXapp, 1},
7419 Counter{cRestSubDelRespToXapp, 1},
7420 Counter{cSubDelReqToE2, 1},
7421 Counter{cSubDelRespFromE2, 1},
7422 })
7423
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007424 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007425
7426 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007427 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007428 restSubId := xappConn1.SendRESTSubsReq(t, params)
7429
7430 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7431
Anssi Mannila21782182021-12-10 10:56:02 +02007432 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007433 orgInstanceId := crereq.RequestId.InstanceId
7434 crereq.RequestId.InstanceId = 0
7435 e2termConn1.SendSubsResp(t, crereq, cremsg)
7436
7437 _, cremsg = e2termConn1.RecvSubsReq(t)
7438
Markku Virtanen55d2a282021-06-04 14:46:56 +03007439 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007440
Anssi Mannila21782182021-12-10 10:56:02 +02007441 // 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 +03007442 fparams := &teststube2ap.E2StubSubsFailParams{}
7443 fparams.Set(crereq)
7444 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7445 e2termConn1.SendSubsFail(t, fparams, cremsg)
7446
7447 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7448 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7449
7450 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007451 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007452
Anssi Mannilab43397e2021-11-16 12:06:16 +02007453 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7454
Anssi Mannila51122392021-05-25 11:51:31 +03007455 // Wait that subs is cleaned
7456 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7457
7458 xappConn1.TestMsgChanEmpty(t)
7459 e2termConn1.TestMsgChanEmpty(t)
7460 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007461 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007462 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007463}
7464
7465//-----------------------------------------------------------------------------
7466// TestRESTUnpackSubscriptionResponseNoTransaction
7467//
7468// stub stub
7469// +-------+ +---------+ +---------+
7470// | xapp | | submgr | | e2term |
7471// +-------+ +---------+ +---------+
7472// | | |
7473// | RestSubReq | |
7474// |---------------->| |
7475// | | |
7476// | RESTSubResp | |
7477// |<----------------| |
7478// | | |
7479// | | SubReq |
7480// | |------------->|
7481// | | |
7482// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007483// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007484// | | |
7485// | | SubReq |
7486// | |------------->|
7487// | | |
7488// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007489// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007490// | RESTNotif (fail)| |
7491// |<----------------| |
7492// | | SubDelReq |
7493// | |------------->|
7494// | | |
7495// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007496// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007497// | | |
7498// | | SubDelReq |
7499// | |------------->|
7500// | | |
7501// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007502// | |<-------------| Ongoing transaction not found.
7503// | | |
7504// | [SUBS DELETE] |
7505// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007506//
7507//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007508
Anssi Mannila51122392021-05-25 11:51:31 +03007509func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007510
7511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7512 Counter{cRestSubReqFromXapp, 1},
7513 Counter{cRestSubRespToXapp, 1},
7514 Counter{cSubReqToE2, 1},
7515 Counter{cSubReqTimerExpiry, 2},
7516 Counter{cSubReReqToE2, 1},
7517 Counter{cSubRespFromE2, 1},
7518 Counter{cSubFailFromE2, 1},
7519 Counter{cRestSubFailNotifToXapp, 1},
7520 Counter{cRestSubDelReqFromXapp, 1},
7521 Counter{cRestSubDelRespToXapp, 1},
7522 Counter{cSubDelReqToE2, 1},
7523 Counter{cSubDelReqTimerExpiry, 2},
7524 Counter{cSubDelReReqToE2, 1},
7525 Counter{cSubDelRespFromE2, 2},
7526 })
7527
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007528 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007529
7530 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007531 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007532 restSubId := xappConn1.SendRESTSubsReq(t, params)
7533
7534 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7535
7536 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7537 // No transaction exist for this response which will result resending original request
7538 e2termConn1.SendSubsResp(t, crereq, cremsg)
7539
7540 _, cremsg = e2termConn1.RecvSubsReq(t)
7541
Markku Virtanen55d2a282021-06-04 14:46:56 +03007542 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007543
7544 // Subscription already created in E2 Node.
7545 fparams := &teststube2ap.E2StubSubsFailParams{}
7546 fparams.Set(crereq)
7547 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7548 e2termConn1.SendSubsFail(t, fparams, cremsg)
7549
7550 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7551 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7552
7553 // Resending happens because there no transaction
7554 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7555 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7556
7557 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007558 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007559
Anssi Mannilab43397e2021-11-16 12:06:16 +02007560 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7561
Anssi Mannila51122392021-05-25 11:51:31 +03007562 // Wait that subs is cleaned
7563 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7564
7565 xappConn1.TestMsgChanEmpty(t)
7566 e2termConn1.TestMsgChanEmpty(t)
7567 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007568 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007569 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007570}
7571
7572//-----------------------------------------------------------------------------
7573// TestRESTUnpackSubscriptionFailureDecodeFail
7574//
7575// stub stub
7576// +-------+ +---------+ +---------+
7577// | xapp | | submgr | | e2term |
7578// +-------+ +---------+ +---------+
7579// | | |
7580// | RestSubReq | |
7581// |---------------->| |
7582// | | |
7583// | RESTSubResp | |
7584// |<----------------| |
7585// | | |
7586// | | SubReq |
7587// | |------------->|
7588// | | |
7589// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007590// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007591// | | |
7592// | | SubReq |
7593// | |------------->|
7594// | | |
7595// | | SubFail | Duplicated action
7596// | |<-------------|
7597// | RESTNotif (fail)| |
7598// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007599// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007600// | [SUBS DELETE] |
7601// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007602//
7603//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007604
Anssi Mannila51122392021-05-25 11:51:31 +03007605func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007606
7607 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7608 Counter{cRestSubReqFromXapp, 1},
7609 Counter{cRestSubRespToXapp, 1},
7610 Counter{cSubReqToE2, 1},
7611 Counter{cSubReqTimerExpiry, 1},
7612 Counter{cSubReReqToE2, 1},
7613 Counter{cSubFailFromE2, 2},
7614 Counter{cRestSubFailNotifToXapp, 1},
7615 Counter{cRestSubDelReqFromXapp, 1},
7616 Counter{cRestSubDelRespToXapp, 1},
7617 })
7618
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007619 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007620
7621 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007622 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007623 restSubId := xappConn1.SendRESTSubsReq(t, params)
7624
7625 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7626
7627 // Decode of this response fails which will result resending original request
7628 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7629
7630 _, cremsg = e2termConn1.RecvSubsReq(t)
7631
Markku Virtanen55d2a282021-06-04 14:46:56 +03007632 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007633
7634 // Subscription already created in E2 Node.
7635 fparams := &teststube2ap.E2StubSubsFailParams{}
7636 fparams.Set(crereq)
7637 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7638 e2termConn1.SendSubsFail(t, fparams, cremsg)
7639
Anssi Mannila51122392021-05-25 11:51:31 +03007640 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007641 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007642
Anssi Mannilab43397e2021-11-16 12:06:16 +02007643 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7644
Anssi Mannila51122392021-05-25 11:51:31 +03007645 // Wait that subs is cleaned
7646 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7647
7648 xappConn1.TestMsgChanEmpty(t)
7649 e2termConn1.TestMsgChanEmpty(t)
7650 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007651 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007652 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007653}
7654
7655//-----------------------------------------------------------------------------
7656// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7657//
7658// stub stub
7659// +-------+ +---------+ +---------+
7660// | xapp | | submgr | | e2term |
7661// +-------+ +---------+ +---------+
7662// | | |
7663// | RestSubReq | |
7664// |---------------->| |
7665// | | |
7666// | RESTSubResp | |
7667// |<----------------| |
7668// | | |
7669// | | SubReq |
7670// | |------------->|
7671// | | |
7672// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007673// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007674// | | |
7675// | | SubReq |
7676// | |------------->|
7677// | | |
7678// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007679// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007680// | RESTNotif (fail)| |
7681// |<----------------| |
7682// | | SubDelReq |
7683// | |------------->|
7684// | | |
7685// | | SubDelResp |
7686// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007687// | | |
7688// | [SUBS DELETE] |
7689// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007690//
7691//-----------------------------------------------------------------------------
7692func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007693
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007694 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007695
Anssi Mannila21782182021-12-10 10:56:02 +02007696 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7697 Counter{cRestSubReqFromXapp, 1},
7698 Counter{cRestSubRespToXapp, 1},
7699 Counter{cSubReqToE2, 1},
7700 Counter{cSubReqTimerExpiry, 2},
7701 Counter{cSubReReqToE2, 1},
7702 Counter{cSubFailFromE2, 2},
7703 Counter{cRestSubFailNotifToXapp, 1},
7704 Counter{cRestSubDelReqFromXapp, 1},
7705 Counter{cRestSubDelRespToXapp, 1},
7706 Counter{cSubDelReqToE2, 1},
7707 Counter{cSubDelRespFromE2, 1},
7708 })
7709
Anssi Mannila51122392021-05-25 11:51:31 +03007710 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007711 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007712 restSubId := xappConn1.SendRESTSubsReq(t, params)
7713
7714 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7715
Anssi Mannila21782182021-12-10 10:56:02 +02007716 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007717 fparams := &teststube2ap.E2StubSubsFailParams{}
7718 fparams.Set(crereq)
7719 fparams.Fail.RequestId.InstanceId = 0
7720 e2termConn1.SendSubsFail(t, fparams, cremsg)
7721
7722 _, cremsg = e2termConn1.RecvSubsReq(t)
7723
Markku Virtanen55d2a282021-06-04 14:46:56 +03007724 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007725
Anssi Mannila21782182021-12-10 10:56:02 +02007726 // 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 +03007727 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7728 e2termConn1.SendSubsFail(t, fparams, cremsg)
7729
7730 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7731 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7732
7733 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007734 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007735
Anssi Mannilab43397e2021-11-16 12:06:16 +02007736 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7737
Anssi Mannila51122392021-05-25 11:51:31 +03007738 // Wait that subs is cleaned
7739 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7740
7741 xappConn1.TestMsgChanEmpty(t)
7742 e2termConn1.TestMsgChanEmpty(t)
7743 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007744 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007745 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007746}
7747
7748//-----------------------------------------------------------------------------
7749// TestRESTUnpackSubscriptionFailureNoTransaction
7750//
7751// stub stub
7752// +-------+ +---------+ +---------+
7753// | xapp | | submgr | | e2term |
7754// +-------+ +---------+ +---------+
7755// | | |
7756// | RestSubReq | |
7757// |---------------->| |
7758// | | |
7759// | RESTSubResp | |
7760// |<----------------| |
7761// | | |
7762// | | SubReq |
7763// | |------------->|
7764// | | |
7765// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007766// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007767// | | |
7768// | | SubReq |
7769// | |------------->|
7770// | | |
7771// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007772// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007773// | RESTNotif (fail)| |
7774// |<----------------| |
7775// | | SubDelReq |
7776// | |------------->|
7777// | | |
7778// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007779// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7780// | | |
7781// | | SubDelReq |
7782// | |------------->|
7783// | | |
7784// | | SubDelResp |
7785// | |<-------------| Ongoing transaction not found.
7786// | | |
7787// | [SUBS DELETE] |
7788// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007789//
7790//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007791
Anssi Mannila51122392021-05-25 11:51:31 +03007792func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007793
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007794 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007795
Anssi Mannila21782182021-12-10 10:56:02 +02007796 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7797 Counter{cRestSubReqFromXapp, 1},
7798 Counter{cRestSubRespToXapp, 1},
7799 Counter{cSubReqToE2, 1},
7800 Counter{cSubReqTimerExpiry, 2},
7801 Counter{cSubReReqToE2, 1},
7802 Counter{cSubFailFromE2, 2},
7803 Counter{cRestSubFailNotifToXapp, 1},
7804 Counter{cRestSubDelReqFromXapp, 1},
7805 Counter{cRestSubDelRespToXapp, 1},
7806 Counter{cSubDelReqToE2, 1},
7807 Counter{cSubDelReqTimerExpiry, 2},
7808 Counter{cSubDelReReqToE2, 1},
7809 Counter{cSubDelRespFromE2, 2},
7810 })
7811
Anssi Mannila51122392021-05-25 11:51:31 +03007812 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007813 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007814 restSubId := xappConn1.SendRESTSubsReq(t, params)
7815
7816 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7817
7818 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7819
7820 // No transaction exist for this response which will result resending original request
7821 fparams := &teststube2ap.E2StubSubsFailParams{}
7822 fparams.Set(crereq)
7823 e2termConn1.SendSubsFail(t, fparams, cremsg)
7824
7825 _, cremsg = e2termConn1.RecvSubsReq(t)
7826
Markku Virtanen55d2a282021-06-04 14:46:56 +03007827 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007828
7829 // Subscription already created in E2 Node.
7830 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7831 e2termConn1.SendSubsFail(t, fparams, cremsg)
7832
7833 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7834 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7835
7836 // Resending happens because there no transaction
7837 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7838 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7839
7840 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007841 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007842
Anssi Mannilab43397e2021-11-16 12:06:16 +02007843 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7844
Anssi Mannila51122392021-05-25 11:51:31 +03007845 // Wait that subs is cleaned
7846 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7847
7848 xappConn1.TestMsgChanEmpty(t)
7849 e2termConn1.TestMsgChanEmpty(t)
7850 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007851 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007852 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007853}
7854
7855//-----------------------------------------------------------------------------
7856// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7857//
7858// stub stub
7859// +-------+ +---------+ +---------+
7860// | xapp | | submgr | | e2term |
7861// +-------+ +---------+ +---------+
7862// | | |
7863// | [SUBS CREATE] |
7864// | | |
7865// | | |
7866// | RESTSubDelReq | |
7867// |---------------->| |
7868// | | |
7869// | RESTSubDelResp | |
7870// |<----------------| |
7871// | | |
7872// | | SubDelReq |
7873// | |------------->|
7874// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007875// | | SubDelResp | ASN.1 decode fails.
7876// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007877// | | |
7878// | | SubDelReq |
7879// | |------------->|
7880// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007881// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007882// | |<-------------|
7883// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007884// | [SUBS DELETE] |
7885// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007886//
7887//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007888
Anssi Mannila51122392021-05-25 11:51:31 +03007889func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007890
Anssi Mannila21782182021-12-10 10:56:02 +02007891 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7892 Counter{cRestSubReqFromXapp, 1},
7893 Counter{cRestSubRespToXapp, 1},
7894 Counter{cSubReqToE2, 1},
7895 Counter{cSubRespFromE2, 1},
7896 Counter{cRestSubNotifToXapp, 1},
7897 Counter{cRestSubDelReqFromXapp, 1},
7898 Counter{cRestSubDelRespToXapp, 1},
7899 Counter{cSubDelReqToE2, 1},
7900 Counter{cSubDelReqTimerExpiry, 1},
7901 Counter{cSubDelReReqToE2, 1},
7902 Counter{cSubDelFailFromE2, 1},
7903 Counter{cSubDelRespFromE2, 1},
7904 })
7905
Anssi Mannila51122392021-05-25 11:51:31 +03007906 // Req
7907 var params *teststube2ap.RESTSubsReqParams = nil
7908 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7909
7910 // Del
7911 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7912
7913 // E2t: Receive 1st SubsDelReq
7914 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7915
7916 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02007917 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03007918
7919 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7920 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7921
7922 // Subscription does not exist in in E2 Node.
7923 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7924
7925 // Wait that subs is cleaned
7926 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7927
7928 xappConn1.TestMsgChanEmpty(t)
7929 e2termConn1.TestMsgChanEmpty(t)
7930 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007931 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007932 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007933}
7934
7935//-----------------------------------------------------------------------------
7936// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
7937//
7938// stub stub
7939// +-------+ +---------+ +---------+
7940// | xapp | | submgr | | e2term |
7941// +-------+ +---------+ +---------+
7942// | | |
7943// | [SUBS CREATE] |
7944// | | |
7945// | | |
7946// | RESTSubDelReq | |
7947// |---------------->| |
7948// | | |
7949// | RESTSubDelResp | |
7950// |<----------------| |
7951// | | |
7952// | | SubDelReq |
7953// | |------------->|
7954// | | |
7955// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007956// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007957// | | |
7958// | | SubDelReq |
7959// | |------------->|
7960// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007961// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007962// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007963// | | |
7964// | [SUBS DELETE] |
7965// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007966//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007967
Anssi Mannila51122392021-05-25 11:51:31 +03007968func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007969
Anssi Mannila21782182021-12-10 10:56:02 +02007970 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7971 Counter{cRestSubReqFromXapp, 1},
7972 Counter{cRestSubRespToXapp, 1},
7973 Counter{cSubReqToE2, 1},
7974 Counter{cSubRespFromE2, 1},
7975 Counter{cRestSubNotifToXapp, 1},
7976 Counter{cRestSubDelReqFromXapp, 1},
7977 Counter{cRestSubDelRespToXapp, 1},
7978 Counter{cSubDelReqToE2, 1},
7979 Counter{cSubDelReqTimerExpiry, 1},
7980 Counter{cSubDelReReqToE2, 1},
7981 Counter{cSubDelRespFromE2, 1},
7982 Counter{cSubDelFailFromE2, 1},
7983 })
7984
Anssi Mannila51122392021-05-25 11:51:31 +03007985 // Req
7986 var params *teststube2ap.RESTSubsReqParams = nil
7987 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7988
7989 // Del
7990 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7991
7992 // E2t: Receive 1st SubsDelReq
7993 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7994
7995 // Unknown instanceId in this response which will result resending original request
7996 delreq.RequestId.InstanceId = 0
7997 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7998
7999 // E2t: Receive 2nd SubsDelReq
8000 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8001
8002 // Subscription does not exist in in E2 Node.
8003 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8004
8005 // Wait that subs is cleaned
8006 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8007
8008 xappConn1.TestMsgChanEmpty(t)
8009 e2termConn1.TestMsgChanEmpty(t)
8010 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008011 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008012 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008013}
8014
8015//-----------------------------------------------------------------------------
8016// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
8017//
8018// stub stub
8019// +-------+ +---------+ +---------+
8020// | xapp | | submgr | | e2term |
8021// +-------+ +---------+ +---------+
8022// | | |
8023// | [SUBS CREATE] |
8024// | | |
8025// | | |
8026// | RESTSubDelReq | |
8027// |---------------->| |
8028// | | |
8029// | RESTSubDelResp | |
8030// |<----------------| |
8031// | | |
8032// | | SubDelReq |
8033// | |------------->|
8034// | | |
8035// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008036// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008037// | | |
8038// | | SubDelReq |
8039// | |------------->|
8040// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008041// | | SubDelFail | Subscription does exist any more in E2 node
8042// | |<-------------| Ongoing transaction not found. This will result timer expiry
8043// | | |
8044// | [SUBS DELETE] |
8045// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008046//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008047
Anssi Mannila51122392021-05-25 11:51:31 +03008048func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008049
Anssi Mannila21782182021-12-10 10:56:02 +02008050 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8051 Counter{cRestSubReqFromXapp, 1},
8052 Counter{cRestSubRespToXapp, 1},
8053 Counter{cSubReqToE2, 1},
8054 Counter{cSubRespFromE2, 1},
8055 Counter{cRestSubNotifToXapp, 1},
8056 Counter{cRestSubDelReqFromXapp, 1},
8057 Counter{cRestSubDelRespToXapp, 1},
8058 Counter{cSubDelReqToE2, 1},
8059 Counter{cSubDelReqTimerExpiry, 2},
8060 Counter{cSubDelReReqToE2, 1},
8061 Counter{cSubDelRespFromE2, 1},
8062 Counter{cSubDelFailFromE2, 1},
8063 })
8064
Anssi Mannila51122392021-05-25 11:51:31 +03008065 // Req
8066 var params *teststube2ap.RESTSubsReqParams = nil
8067 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8068
8069 // Del
8070 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8071
8072 // E2t: Receive 1st SubsDelReq
8073 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8074
8075 mainCtrl.MakeTransactionNil(t, e2SubsId)
8076
8077 // No transaction exist for this response which will result resending original request
8078 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8079
8080 // E2t: Receive 2nd SubsDelReq
8081 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8082
8083 // Subscription does not exist in in E2 Node.
8084 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8085
8086 // Wait that subs is cleaned
8087 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8088
8089 xappConn1.TestMsgChanEmpty(t)
8090 e2termConn1.TestMsgChanEmpty(t)
8091 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008092 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008093 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008094}
8095
8096//-----------------------------------------------------------------------------
8097// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
8098//
8099// stub stub
8100// +-------+ +---------+ +---------+
8101// | xapp | | submgr | | e2term |
8102// +-------+ +---------+ +---------+
8103// | | |
8104// | [SUBS CREATE] |
8105// | | |
8106// | | |
8107// | RESTSubDelReq | |
8108// |---------------->| |
8109// | | |
8110// | RESTSubDelResp | |
8111// |<----------------| |
8112// | | |
8113// | | SubDelReq |
8114// | |------------->|
8115// | | |
8116// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02008117// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008118// | | |
8119// | | SubDelReq |
8120// | |------------->|
8121// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008122// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008123// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008124// | | |
8125// | [SUBS DELETE] |
8126// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008127//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008128
Anssi Mannila51122392021-05-25 11:51:31 +03008129func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008130
Anssi Mannila21782182021-12-10 10:56:02 +02008131 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8132 Counter{cRestSubReqFromXapp, 1},
8133 Counter{cRestSubRespToXapp, 1},
8134 Counter{cSubReqToE2, 1},
8135 Counter{cSubRespFromE2, 1},
8136 Counter{cRestSubNotifToXapp, 1},
8137 Counter{cRestSubDelReqFromXapp, 1},
8138 Counter{cRestSubDelRespToXapp, 1},
8139 Counter{cSubDelReqToE2, 1},
8140 Counter{cSubDelReqTimerExpiry, 1},
8141 Counter{cSubDelReReqToE2, 1},
8142 Counter{cSubDelFailFromE2, 2},
8143 })
8144
Anssi Mannila51122392021-05-25 11:51:31 +03008145 // Req
8146 var params *teststube2ap.RESTSubsReqParams = nil
8147 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8148
8149 // Del
8150 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8151
8152 // E2t: Receive 1st SubsDelReq
8153 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8154
8155 // Decode of this response fails which will result resending original request
8156 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
8157
8158 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8159 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8160
8161 // Subscription does not exist in in E2 Node.
8162 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8163
8164 // Wait that subs is cleaned
8165 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8166
8167 xappConn1.TestMsgChanEmpty(t)
8168 e2termConn1.TestMsgChanEmpty(t)
8169 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008170 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008171 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008172}
8173
8174//-----------------------------------------------------------------------------
8175// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8176//
8177// stub stub
8178// +-------+ +---------+ +---------+
8179// | xapp | | submgr | | e2term |
8180// +-------+ +---------+ +---------+
8181// | | |
8182// | [SUBS CREATE] |
8183// | | |
8184// | | |
8185// | RESTSubDelReq | |
8186// |---------------->| |
8187// | | |
8188// | RESTSubDelResp | |
8189// |<----------------| |
8190// | | |
8191// | | SubDelReq |
8192// | |------------->|
8193// | | |
8194// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008195// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008196// | | |
8197// | | SubDelReq |
8198// | |------------->|
8199// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008200// | | SubDelFail | Subscription does exist any more in E2 node
8201// | |<-------------| No valid subscription found with subIds [0].
8202// | | |
8203// | [SUBS DELETE] |
8204// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008205//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008206
Anssi Mannila51122392021-05-25 11:51:31 +03008207func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008208
Anssi Mannila21782182021-12-10 10:56:02 +02008209 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8210 Counter{cRestSubReqFromXapp, 1},
8211 Counter{cRestSubRespToXapp, 1},
8212 Counter{cSubReqToE2, 1},
8213 Counter{cSubRespFromE2, 1},
8214 Counter{cRestSubNotifToXapp, 1},
8215 Counter{cRestSubDelReqFromXapp, 1},
8216 Counter{cRestSubDelRespToXapp, 1},
8217 Counter{cSubDelReqToE2, 1},
8218 Counter{cSubDelReqTimerExpiry, 1},
8219 Counter{cSubDelReReqToE2, 1},
8220 Counter{cSubDelFailFromE2, 2},
8221 })
8222
Anssi Mannila51122392021-05-25 11:51:31 +03008223 // Req
8224 var params *teststube2ap.RESTSubsReqParams = nil
8225 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8226
8227 // Del
8228 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8229
8230 // E2t: Receive 1st SubsDelReq
8231 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8232
Anssi Mannila21782182021-12-10 10:56:02 +02008233 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008234 delreq.RequestId.InstanceId = 0
8235 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8236
8237 // E2t: Receive 2nd SubsDelReq
8238 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8239
Anssi Mannila21782182021-12-10 10:56:02 +02008240 // 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 +03008241 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8242
8243 // Wait that subs is cleaned
8244 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8245
8246 xappConn1.TestMsgChanEmpty(t)
8247 e2termConn1.TestMsgChanEmpty(t)
8248 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008249 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008250 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008251}
8252
8253//-----------------------------------------------------------------------------
8254// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8255//
8256// stub stub
8257// +-------+ +---------+ +---------+
8258// | xapp | | submgr | | e2term |
8259// +-------+ +---------+ +---------+
8260// | | |
8261// | [SUBS CREATE] |
8262// | | |
8263// | | |
8264// | RESTSubDelReq | |
8265// |---------------->| |
8266// | | |
8267// | RESTSubDelResp | |
8268// |<----------------| |
8269// | | |
8270// | | SubDelReq |
8271// | |------------->|
8272// | | |
8273// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008274// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008275// | | |
8276// | | SubDelReq |
8277// | |------------->|
8278// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008279// | | SubDelFail | Subscription does exist any more in E2 node
8280// | |<-------------| Ongoing transaction not found. This will result timer expiry
8281// | | |
8282// | [SUBS DELETE] |
8283// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008284//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008285
Anssi Mannila51122392021-05-25 11:51:31 +03008286func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008287
Anssi Mannila21782182021-12-10 10:56:02 +02008288 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8289 Counter{cRestSubReqFromXapp, 1},
8290 Counter{cRestSubRespToXapp, 1},
8291 Counter{cSubReqToE2, 1},
8292 Counter{cSubRespFromE2, 1},
8293 Counter{cRestSubNotifToXapp, 1},
8294 Counter{cRestSubDelReqFromXapp, 1},
8295 Counter{cRestSubDelRespToXapp, 1},
8296 Counter{cSubDelReqToE2, 1},
8297 Counter{cSubDelReqTimerExpiry, 2},
8298 Counter{cSubDelReReqToE2, 1},
8299 Counter{cSubDelFailFromE2, 2},
8300 })
8301
Anssi Mannila51122392021-05-25 11:51:31 +03008302 // Req
8303 var params *teststube2ap.RESTSubsReqParams = nil
8304 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8305
8306 // Del
8307 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8308
8309 // E2t: Receive 1st SubsDelReq
8310 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8311
8312 mainCtrl.MakeTransactionNil(t, e2SubsId)
8313
8314 // No transaction exist for this response which will result resending original request
8315 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8316
8317 // E2t: Receive 2nd SubsDelReq
8318 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8319
8320 // Subscription does not exist in in E2 Node.
8321 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8322
8323 // Wait that subs is cleaned
8324 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8325
8326 xappConn1.TestMsgChanEmpty(t)
8327 e2termConn1.TestMsgChanEmpty(t)
8328 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008329 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008330 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008331}
8332
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008333//-----------------------------------------------------------------------------
8334// TestRESTSubReqFailAsn1PackSubReqError
8335//
8336// stub stub
8337// +-------+ +---------+ +---------+
8338// | xapp | | submgr | | e2term |
8339// +-------+ +---------+ +---------+
8340// | | |
8341// | RESTSubReq | |
8342// |---------------->| |
8343// | | |
8344// | RESTSubResp | |
8345// |<----------------| |
8346// | | |
8347// | ASN.1 encode fails |
8348// | | |
8349// | | SubDelReq |
8350// | |------------->|
8351// | | |
8352// | | SubDelFail |
8353// | |<-------------|
8354// | | |
8355// | RESTNotif | |
8356// | unsuccess | |
8357// |<----------------| |
8358// | | |
8359// | [SUBS DELETE] |
8360// | | |
8361//
8362//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008363
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008364func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8365
8366 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008367 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008368 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008369 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008370 Counter{cRestSubDelReqFromXapp, 1},
8371 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008372 })
8373
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008374 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008375
8376 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008377 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008378 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8379
8380 // Req
8381 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008382 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008383
8384 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008385 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008386
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008387 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008388 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008389
8390 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008391
8392 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8393
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008394 // Wait that subs is cleaned
8395 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008396 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008397 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008398}
8399
Anssi Mannila27385172021-12-22 09:41:54 +02008400//-----------------------------------------------------------------------------
8401// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8402//
8403// stub stub
8404// +-------+ +---------+ +---------+
8405// | xapp | | submgr | | e2term |
8406// +-------+ +---------+ +---------+
8407// | | |
8408// | RESTSubReq | |
8409// |---------------->| |
8410// | | |
8411// | RESTSubResp | |
8412// |<----------------| |
8413// | | SubReq |
8414// | |------------->|
8415// | | |
8416// | | SubResp |
8417// | |<-------------|
8418// | | |
8419// | RESTNotif | |
8420// |<----------------| |
8421// | | |
8422// | RESTSubReq | | Policy modification
8423// |---------------->| |
8424// | | |
8425// | RESTSubResp | |
8426// |<----------------| |
8427// | | SubReq |
8428// | |------------->|
8429// | | |
8430// | | |
8431// | RESTNotif(Unsuccessful) | E2 timeout
8432// |<----------------| |
8433// | | |
8434// | RESTSubDelReq | |
8435// |---------------->| |
8436// | | |
8437// | | SubDelReq |
8438// | |------------->|
8439// | | |
8440// | | SubDelResp |
8441// | |<-------------|
8442// | | |
8443// | RESTSubDelResp | |
8444// |<----------------| |
8445//
8446//-----------------------------------------------------------------------------
8447
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008448func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008449
8450 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8451 Counter{cRestSubReqFromXapp, 2},
8452 Counter{cRestSubRespToXapp, 2},
8453 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008454 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008455 Counter{cSubRespFromE2, 1},
8456 Counter{cRestSubNotifToXapp, 1},
8457 Counter{cRestSubFailNotifToXapp, 1},
8458 Counter{cRestSubDelReqFromXapp, 1},
8459 Counter{cSubDelReqToE2, 1},
8460 Counter{cSubDelRespFromE2, 1},
8461 Counter{cRestSubDelRespToXapp, 1},
8462 })
8463
8464 const e2Timeout int64 = 1
8465 const e2RetryCount int64 = 0
8466 const routingNeeded bool = false
8467
8468 // Req1
8469 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8470 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8471
8472 // Subs Create
8473 restSubId := xappConn1.SendRESTSubsReq(t, params)
8474 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8475
8476 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8477 xappConn1.ExpectRESTNotification(t, restSubId)
8478 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8479 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8480 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8481
8482 // Policy change
8483 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8484 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8485 params.SetSubscriptionID(&restSubId)
8486 params.SetTimeToWait("w200ms")
8487 restSubId = xappConn1.SendRESTSubsReq(t, params)
8488 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8489
8490 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8491 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008492 // SubsResp is missing, e2SubsId will be 0
8493 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8494 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008495
8496 // Del
8497 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8498 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8499 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8500
8501 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008502 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008503 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008504}
8505
8506//-----------------------------------------------------------------------------
8507// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8508//
8509// stub stub
8510// +-------+ +---------+ +---------+
8511// | xapp | | submgr | | e2term |
8512// +-------+ +---------+ +---------+
8513// | | |
8514// | RESTSubReq | |
8515// |---------------->| |
8516// | | |
8517// | RESTSubResp | |
8518// |<----------------| |
8519// | | SubReq |
8520// | |------------->|
8521// | | |
8522// | | SubResp |
8523// | |<-------------|
8524// | | |
8525// | RESTNotif | |
8526// |<----------------| |
8527// | | |
8528// | RESTSubReq | |
8529// |---------------->| |
8530// | | |
8531// | RESTSubResp | |
8532// |<----------------| |
8533// | | SubReq |
8534// | |------------->|
8535// | |
8536// | Submgr restart |
8537// | | |
8538// | RESTSubDelReq | |
8539// |---------------->| |
8540// | | |
8541// | | SubDelReq |
8542// | |------------->|
8543// | | |
8544// | | SubDelResp |
8545// | |<-------------|
8546// | | |
8547// | RESTSubDelResp | |
8548// |<----------------| |
8549//
8550//-----------------------------------------------------------------------------
8551
8552func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008553
8554 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8555 Counter{cRestSubReqFromXapp, 2},
8556 Counter{cRestSubRespToXapp, 2},
8557 Counter{cSubReqToE2, 2},
8558 Counter{cSubRespFromE2, 1},
8559 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008560 Counter{cRestSubDelReqFromXapp, 1},
8561 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008562 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008563 Counter{cRestSubDelRespToXapp, 1},
8564 })
8565
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008566 const e2Timeout int64 = 1
8567 const e2RetryCount int64 = 0
8568 const routingNeeded bool = false
8569
8570 // Req1
8571 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8572 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8573 // Create subscription
8574 restSubId := xappConn1.SendRESTSubsReq(t, params)
8575 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8576
8577 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8578 xappConn1.ExpectRESTNotification(t, restSubId)
8579 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8580 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8581 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8582
8583 // Check subscription
8584 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8585
8586 // Policy change
8587 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8588 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8589 params.SetSubscriptionID(&restSubId)
8590 params.SetTimeToWait("w200ms")
8591 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8592 restSubId = xappConn1.SendRESTSubsReq(t, params)
8593 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8594
8595 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8596 mainCtrl.SetResetTestFlag(t, false)
8597
8598 // SubsResp is missing due to submgr restart
8599
8600 mainCtrl.SimulateRestart(t)
8601 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8602
Anssi Mannila54838ed2021-11-19 11:25:01 +02008603 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8604 // That needs to be completed before successful subscription query is possible
8605 <-time.After(time.Second * 1)
8606
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008607 // Check subscription
8608 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8609
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008610 // Delete subscription
8611 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8612 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8613 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8614
8615 //Wait that subs is cleaned
8616 waitSubsCleanup(t, e2SubsId, 10)
8617
8618 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008619 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008620}
8621
archaggeafbf95f2021-04-14 08:54:05 +03008622////////////////////////////////////////////////////////////////////////////////////
8623// Services for UT cases
8624////////////////////////////////////////////////////////////////////////////////////
8625const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008626const host string = "localhost"
8627
8628func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8629 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008630 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008631 }
8632 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008633 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008634
8635 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8636 fromXappConn.ExpectRESTNotification(t, restSubId)
8637 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8638 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008639 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008640
8641 return restSubId, e2SubsId
8642}
8643
8644func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8645
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008646 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008647 if meid != "" {
8648 params.SetMeid(meid)
8649 }
8650 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8651 restSubId := xappConn2.SendRESTSubsReq(t, params)
8652 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008653 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008654 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008655 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008656
8657 return restSubId, e2SubsId
8658}
8659
8660func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008661
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008662 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008663 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008664 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008665
8666 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8667 xappConn1.ExpectRESTNotification(t, restSubId)
8668 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8669 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008670 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008671
8672 return restSubId, e2SubsId
8673}
8674
8675func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008676 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008677 restSubId := xappConn1.SendRESTSubsReq(t, params)
8678
8679 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8680 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8681 fparams1.Set(crereq1)
8682 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8683
8684 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8685 xappConn1.ExpectRESTNotification(t, restSubId)
8686 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8687 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008688 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008689
8690 return restSubId, e2SubsId
8691}
8692
8693func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8694 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8695 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8696 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8697}
8698
8699func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8700 xappConn1.SendRESTSubsDelReq(t, restSubId)
8701 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8702 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8703}
8704
8705func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8706 xappConn2.SendRESTSubsDelReq(t, restSubId)
8707 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8708 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8709}
8710
8711func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8712 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008713 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8714 assert.Equal(t, meid, resp[0].Meid)
8715 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008716}
8717
8718func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8719 //Wait that subs is cleaned
8720 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8721
8722 xappConn1.TestMsgChanEmpty(t)
8723 xappConn2.TestMsgChanEmpty(t)
8724 e2termConn1.TestMsgChanEmpty(t)
8725 mainCtrl.wait_registry_empty(t, timeout)
8726}
8727
8728func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8729
8730 var e2SubsId []uint32
8731
8732 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008733 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008734 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8735 fromXappConn.ExpectRESTNotification(t, restSubId)
8736 toE2termConn.SendSubsResp(t, crereq, cremsg)
8737 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8738 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008739 xapp.Logger.Debug("TEST: %v", e2SubsId)
8740 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008741 <-time.After(100 * time.Millisecond)
8742 }
8743 return e2SubsId
8744}
8745
8746func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8747
8748 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008749 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008750 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8751 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8752 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008753 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008754 <-time.After(100 * time.Millisecond)
8755 }
8756
8757 // Wait that subs is cleaned
8758 for i := 0; i < len(e2SubsIds); i++ {
8759 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8760 }
8761
8762}