blob: 79eccd2efffea041626e16e3e379b5b692e0a44b [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030023 //"os"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000024 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020025 "testing"
26 "time"
27
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030030 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020031 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020032 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020034)
35
Markku Virtanenac8bde42021-05-25 09:54:42 +000036func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030037 // The effect of this call shall endure though the UT suite!
38 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000039 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000040 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
41
Anssi Mannila3d80b722021-11-12 13:17:15 +020042 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000043 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030044 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000045
Markku Virtanenac8bde42021-05-25 09:54:42 +000046}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030047func TestRanStatusChangeViaSDLNotification(t *testing.T) {
48
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020049 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
50 Counter{cE2StateChangedToUp, 3},
51 })
52
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030053 // Current UT test cases use these ran names
54 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
55 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
56 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
57
58 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
59 mainCtrl.c.e2IfState.SubscribeChannels()
60
61 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
62 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
63 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020064
65 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030066}
67
68//-----------------------------------------------------------------------------
69// TestRESTSubReqAfterE2ConnBreak
70//
71// stub stub
72// +-------+ +---------+ +---------+
73// | xapp | | submgr | | e2term |
74// +-------+ +---------+ +---------+
75// | | |
76// | [E2 Conn. DOWN] |
77// | | |
78// | RESTSubReq | |
79// |---------------->| |
80// | RESTSubFail | |
81// |<----------------| |
82// | | |
83//
84//-----------------------------------------------------------------------------
85
86func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
87 CaseBegin("TestRESTSubReqAfterE2ConnBreak")
88
89 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
90 Counter{cRestSubReqFromXapp, 1},
91 Counter{cRestReqRejDueE2Down, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020092 Counter{cE2StateChangedToDown, 1},
93 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030094 })
95
96 // E2 disconnect after E2term has received response
97 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
98 // Req
99 const subReqCount int = 1
100 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
101 xappConn1.SendRESTSubsReq(t, params)
102
103 // Restore E2 connection for following test cases
104 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
105
Anssi Mannilab43397e2021-11-16 12:06:16 +0200106 mainCtrl.VerifyAllClean(t)
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200107 mainCtrl.VerifyCounterValues(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +0200108 //os.Exit(0)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300109}
110
111//-----------------------------------------------------------------------------
112// TestRESTSubReqE2ConnBreak
113//
114// stub stub
115// +-------+ +---------+ +---------+
116// | xapp | | submgr | | e2term |
117// +-------+ +---------+ +---------+
118// | | |
119// | RESTSubReq | |
120// |---------------->| |
121// | RESTSubResp | |
122// |<----------------| |
123// | | SubReq |
124// | |------------->|
125// | | SubResp |
126// | |<-------------|
127// | | |
128// | [E2 Conn. DOWN] |
129// | [Int. SUBS DELETE] |
130// | | |
131// | RESTNotif(unsuccessful) |
132// |<----------------| |
133// | | |
134// | | |
135//
136//-----------------------------------------------------------------------------
137func TestRESTSubReqE2ConnBreak(t *testing.T) {
138 CaseBegin("TestRESTSubReqE2ConnBreak")
139
140 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
141 Counter{cRestSubReqFromXapp, 1},
142 Counter{cRestSubRespToXapp, 1},
143 Counter{cSubReqToE2, 1},
144 Counter{cSubRespFromE2, 1},
145 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200146 Counter{cE2StateChangedToDown, 1},
147 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300148 })
149
150 // Req
151 const subReqCount int = 1
152 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
153 restSubId := xappConn1.SendRESTSubsReq(t, params)
154
155 crereq, cremsg := e2termConn1.RecvSubsReq(t)
156 xappConn1.ExpectRESTNotification(t, restSubId)
157
158 // E2 disconnect after E2term has received response
159 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
160
161 e2termConn1.SendSubsResp(t, crereq, cremsg)
162 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
163
164 <-time.After(time.Second * 1)
165 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
166 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
167
168 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
169 if err != nil {
170 xapp.Logger.Error("%v", err)
171 } else {
172 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
173 assert.Equal(t, 0, len(register))
174 }
175
176 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
177 if err != nil {
178 xapp.Logger.Error("%v", err)
179 } else {
180 assert.Equal(t, 0, len(restSubscriptions))
181 }
182
183 // Restore E2 connection for following test cases
184 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
185
186 // Wait that subs is cleaned
187 waitSubsCleanup(t, e2SubsId, 10)
188 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200189 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300190}
191
192//-----------------------------------------------------------------------------
193// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
194//
195// stub stub
196// +-------+ +---------+ +---------+
197// | xapp | | submgr | | e2term |
198// +-------+ +---------+ +---------+
199// | | |
200// | [SUBS CREATE] |
201// | | |
202// | [E2 Conn. DOWN] |
203// | | |
204// | RESTSubDelReq | |
205// |---------------->| |
206// | | |
207// | RESTSubDelResp | |
208// |<----------------| |
209// | | |
210// | [No valid subscription found] |
211// | | |
212//
213//-----------------------------------------------------------------------------
214func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
215 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
216
217 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
218 Counter{cRestSubReqFromXapp, 1},
219 Counter{cRestSubRespToXapp, 1},
220 Counter{cSubReqToE2, 1},
221 Counter{cSubRespFromE2, 1},
222 Counter{cRestSubNotifToXapp, 1},
223 Counter{cRestSubDelReqFromXapp, 1},
224 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200225 Counter{cE2StateChangedToDown, 1},
226 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300227 })
228
229 // Req
230 var params *teststube2ap.RESTSubsReqParams = nil
231 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
232
233 // E2 disconnect after E2term has received response
234 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
235
236 // Del
237 xappConn1.SendRESTSubsDelReq(t, &restSubId)
238
239 <-time.After(time.Second * 1)
240 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
241 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
242
243 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
244 if err != nil {
245 xapp.Logger.Error("%v", err)
246 } else {
247 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
248 assert.Equal(t, 0, len(register))
249 }
250
251 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
252 if err != nil {
253 xapp.Logger.Error("%v", err)
254 } else {
255 assert.Equal(t, 0, len(restSubscriptions))
256 }
257
258 // Restore E2 connection for following test cases
259 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
260
261 // Wait that subs is cleaned
262 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
263
264 xappConn1.TestMsgChanEmpty(t)
265 e2termConn1.TestMsgChanEmpty(t)
266 mainCtrl.wait_registry_empty(t, 10)
267 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200268 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300269}
270
271//-----------------------------------------------------------------------------
272// TestRESTOtherE2ConnectionChanges
273//
274
275// stub stub
276// +-------+ +---------+ +---------+
277// | xapp | | submgr | | e2term |
278// +-------+ +---------+ +---------+
279// | | |
280// | [SUBS CREATE] |
281// | | |
282// | [E2 CONNECTED_SETUP_FAILED] |
283// | [E2 CONNECTING] |
284// | [E2 SHUTTING_DOWN] |
285// | [E2 SHUT_DOWN] |
286// | | |
287// | [SUBS DELETE] |
288// | | |
289//
290//-----------------------------------------------------------------------------
291func TestRESTOtherE2ConnectionChanges(t *testing.T) {
292 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
293
294 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
295 Counter{cRestSubReqFromXapp, 1},
296 Counter{cRestSubRespToXapp, 1},
297 Counter{cSubReqToE2, 1},
298 Counter{cSubRespFromE2, 1},
299 Counter{cRestSubNotifToXapp, 1},
300 Counter{cRestSubDelReqFromXapp, 1},
301 Counter{cSubDelReqToE2, 1},
302 Counter{cSubDelRespFromE2, 1},
303 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200304 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300305 })
306
307 // Req
308 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
309 restSubId := xappConn1.SendRESTSubsReq(t, params)
310
311 crereq, cremsg := e2termConn1.RecvSubsReq(t)
312 xappConn1.ExpectRESTNotification(t, restSubId)
313 e2termConn1.SendSubsResp(t, crereq, cremsg)
314 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
315
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200316 // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300317 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
318 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
319 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
320 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
321
322 // Del
323 xappConn1.SendRESTSubsDelReq(t, &restSubId)
324 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
325 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
326
327 // Restore E2 connection for following test cases
328 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
329
330 // Wait that subs is cleaned
331 waitSubsCleanup(t, e2SubsId, 10)
332 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200333 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300334}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000335
336//-----------------------------------------------------------------------------
337// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
338//
339// stub stub stub
340// +-------+ +---------+ +---------+ +---------+
341// | xapp | | submgr | | e2term | | rtmgr |
342// +-------+ +---------+ +---------+ +---------+
343// | | | |
344// | RESTSubReq | | |
345// |---------------->| | |
346// | | RouteCreate | |
347// | |--------------------------->| // The order of these events may vary
348// | | | |
349// | RESTSubResp | | | // The order of these events may vary
350// |<----------------| | |
351// | | RouteResponse| |
352// | |<---------------------------| // The order of these events may vary
353// | | | |
354// | | SubReq | |
355// | |------------->| | // The order of these events may vary
356// | | | |
357// | | SubResp | |
358// | |<-------------| |
359// | RESTNotif1 | | |
360// |<----------------| | |
361// | | | |
362// | RESTSubDelReq | | |
363// |---------------->| | |
364// | | SubDelReq | |
365// | |------------->| |
366// | | | |
367// | RESTSubDelResp| | |
368// |<----------------| | |
369// | | | |
370// | | SubDelResp | |
371// | |<-------------| |
372// | | | |
373// | | | |
374//
375//-----------------------------------------------------------------------------
376func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000377
378 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
379
380 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
381
382 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200383 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000384}
385
Juha Hyttinenfa015662020-01-24 10:05:18 +0200386//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000387// TestRESTSubReqAndE1apDeleteReqPackingError
388//
389// stub stub stub
390// +-------+ +---------+ +---------+ +---------+
391// | xapp | | submgr | | e2term | | rtmgr |
392// +-------+ +---------+ +---------+ +---------+
393// | | | |
394// | RESTSubReq | | |
395// |---------------->| | |
396// | | RouteCreate | |
397// | |--------------------------->| // The order of these events may vary
398// | | | |
399// | RESTSubResp | | | // The order of these events may vary
400// |<----------------| | |
401// | | RouteResponse| |
402// | |<---------------------------| // The order of these events may vary
403// | | | |
404// | | SubReq | |
405// | |------------->| | // The order of these events may vary
406// | | | |
407// | | SubResp | |
408// | |<-------------| |
409// | RESTNotif1 | | |
410// |<----------------| | |
411// | | | |
412// | RESTSubDelReq | | |
413// |---------------->| | |
414// | | | |
415// | RESTSubDelResp| | |
416// |<----------------| | |
417// | | | |
418// | | | |
419//
420//-----------------------------------------------------------------------------
421func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
422
423 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
424
425 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
426 xappConn1.SendRESTSubsDelReq(t, &restSubId)
427 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
428
429 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200430 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000431}
432
433//-----------------------------------------------------------------------------
434// TestRESTSubReqAndE1apDeleteRespUnpackingError
435//
436// stub stub stub
437// +-------+ +---------+ +---------+ +---------+
438// | xapp | | submgr | | e2term | | rtmgr |
439// +-------+ +---------+ +---------+ +---------+
440// | | | |
441// | RESTSubReq | | |
442// |---------------->| | |
443// | | RouteCreate | |
444// | |--------------------------->| // The order of these events may vary
445// | | | |
446// | RESTSubResp | | | // The order of these events may vary
447// |<----------------| | |
448// | | RouteResponse| |
449// | |<---------------------------| // The order of these events may vary
450// | | | |
451// | | SubReq | |
452// | |------------->| | // The order of these events may vary
453// | | | |
454// | | SubResp | |
455// | |<-------------| |
456// | RESTNotif1 | | |
457// |<----------------| | |
458// | | | |
459// | RESTSubDelReq | | |
460// |---------------->| | |
461// | | SubDelReq | |
462// | |------------->| |
463// | | | |
464// | RESTSubDelResp| | |
465// |<----------------| | | // The order of these events may vary
466// | | | |
467// | | SubDelResp | |
468// | |<-------------| | // 1.st NOK
469// | | | |
470// | | SubDelReq | |
471// | |------------->| |
472// | | | |
473// | | SubDelResp | |
474// | |<-------------| | // 2.nd NOK
475//
476//-----------------------------------------------------------------------------
477
478func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
479
480 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
481
482 xappConn1.SendRESTSubsDelReq(t, &restSubId)
483 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
484 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
485 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
486
487 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
488 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
489
490 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
491
492 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200493 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000494}
495
496//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200497// TestSubReqAndRouteNok
498//
499// stub stub
500// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200501// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200502// +-------+ +---------+ +---------+
503// | | |
504// | SubReq | |
505// |------------->| |
506// | | |
507// | | RouteCreate |
508// | |------------->|
509// | | |
510// | | RouteCreate |
511// | | status:400 |
512// | |<-------------|
513// | | |
514// | [SUBS INT DELETE] |
515// | | |
516//
517//-----------------------------------------------------------------------------
518
519func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200520 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200521
Anssi Mannila4abf1802021-01-28 13:06:46 +0200522 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200523 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
524 Counter{cSubReqFromXapp, 1},
525 Counter{cRouteCreateFail, 1},
526 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200527
Juha Hyttinenfa015662020-01-24 10:05:18 +0200528 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300529 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200530 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200531 waiter.WaitResult(t)
532
533 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200534 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200535
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200536 xappConn1.TestMsgChanEmpty(t)
537 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200538 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200539 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200540
541 <-time.After(1 * time.Second)
542 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200543}
544
545//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200546// TestSubReqAndRouteUpdateNok
547
548// stub stub
549// +-------+ +-------+ +---------+ +---------+
550// | xapp2 | | xapp1 | | submgr | | rtmgr |
551// +-------+ +-------+ +---------+ +---------+
552// | | | |
553// | [SUBS CREATE] | |
554// | | | |
555// | | | |
556// | | | |
557// | SubReq (mergeable) | |
558// |--------------------------->| | |
559// | | | |
560// | | | RouteUpdate |
561// | | |------------->|
562// | | | |
563// | | | RouteUpdate |
564// | | | status:400 |
565// | | |<-------------|
566// | | | |
567// | [SUBS INT DELETE] | |
568// | | | |
569// | | | |
570// | [SUBS DELETE] | |
571// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300572
Anssi Mannila4abf1802021-01-28 13:06:46 +0200573func TestSubReqAndRouteUpdateNok(t *testing.T) {
574 CaseBegin("TestSubReqAndRouteUpdateNok")
575
576 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200577 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
578 Counter{cSubReqFromXapp, 2},
579 Counter{cSubReqToE2, 1},
580 Counter{cSubRespFromE2, 1},
581 Counter{cSubRespToXapp, 1},
582 Counter{cRouteCreateUpdateFail, 1},
583 Counter{cSubDelReqFromXapp, 1},
584 Counter{cSubDelReqToE2, 1},
585 Counter{cSubDelRespFromE2, 1},
586 Counter{cSubDelRespToXapp, 1},
587 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200588
589 cretrans := xappConn1.SendSubsReq(t, nil, nil)
590 crereq, cremsg := e2termConn1.RecvSubsReq(t)
591 e2termConn1.SendSubsResp(t, crereq, cremsg)
592 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
593
594 resp, _ := xapp.Subscription.QuerySubscriptions()
595 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
596 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300597 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200598
599 waiter := rtmgrHttp.AllocNextEvent(false)
600 newSubsId := mainCtrl.get_registry_next_subid(t)
601 xappConn2.SendSubsReq(t, nil, nil)
602 waiter.WaitResult(t)
603
604 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
605 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
606
607 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
608 xappConn1.RecvSubsDelResp(t, deltrans)
609
610 //Wait that subs is cleaned
611 mainCtrl.wait_subs_clean(t, newSubsId, 10)
612 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
613
614 xappConn1.TestMsgChanEmpty(t)
615 xappConn2.TestMsgChanEmpty(t)
616 e2termConn1.TestMsgChanEmpty(t)
617 mainCtrl.wait_registry_empty(t, 10)
618
619 mainCtrl.VerifyCounterValues(t)
620}
621
622//-----------------------------------------------------------------------------
623// TestSubDelReqAndRouteDeleteNok
624//
625// stub stub
626// +-------+ +---------+ +---------+ +---------+
627// | xapp | | submgr | | e2term | | rtmgr |
628// +-------+ +---------+ +---------+ +---------+
629// | | | |
630// | [SUBS CREATE] | |
631// | | | |
632// | | | |
633// | | | |
634// | SubDelReq | | |
635// |------------->| | |
636// | | SubDelReq | |
637// | |------------->| |
638// | | SubDelRsp | |
639// | |<-------------| |
640// | SubDelRsp | | |
641// |<-------------| | |
642// | | RouteDelete | |
643// | |---------------------------->|
644// | | | |
645// | | RouteDelete | |
646// | | status:400 | |
647// | |<----------------------------|
648// | | | |
649func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
650 CaseBegin("TestSubDelReqAndRouteDeleteNok")
651
652 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200653 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
654 Counter{cSubReqFromXapp, 1},
655 Counter{cSubReqToE2, 1},
656 Counter{cSubRespFromE2, 1},
657 Counter{cSubRespToXapp, 1},
658 Counter{cSubDelReqFromXapp, 1},
659 Counter{cRouteDeleteFail, 1},
660 Counter{cSubDelReqToE2, 1},
661 Counter{cSubDelRespFromE2, 1},
662 Counter{cSubDelRespToXapp, 1},
663 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200664
665 cretrans := xappConn1.SendSubsReq(t, nil, nil)
666 crereq, cremsg := e2termConn1.RecvSubsReq(t)
667 e2termConn1.SendSubsResp(t, crereq, cremsg)
668 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
669
670 resp, _ := xapp.Subscription.QuerySubscriptions()
671 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
672 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300673 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200674
675 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
676 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
677
678 waiter := rtmgrHttp.AllocNextEvent(false)
679 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
680 waiter.WaitResult(t)
681
682 xappConn1.RecvSubsDelResp(t, deltrans)
683
684 //Wait that subs is cleaned
685 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
686
687 xappConn1.TestMsgChanEmpty(t)
688 xappConn2.TestMsgChanEmpty(t)
689 e2termConn1.TestMsgChanEmpty(t)
690 mainCtrl.wait_registry_empty(t, 10)
691
692 mainCtrl.VerifyCounterValues(t)
693}
694
695//-----------------------------------------------------------------------------
696// TestSubMergeDelAndRouteUpdateNok
697// stub stub
698// +-------+ +-------+ +---------+ +---------+
699// | xapp2 | | xapp1 | | submgr | | e2term |
700// +-------+ +-------+ +---------+ +---------+
701// | | | |
702// | | | |
703// | | | |
704// | | SubReq1 | |
705// | |------------->| |
706// | | | |
707// | | | SubReq1 |
708// | | |------------->|
709// | | | SubResp1 |
710// | | |<-------------|
711// | | SubResp1 | |
712// | |<-------------| |
713// | | | |
714// | SubReq2 | |
715// |--------------------------->| |
716// | | | |
717// | SubResp2 | |
718// |<---------------------------| |
719// | | | |
720// | | SubDelReq 1 | |
721// | |------------->| |
722// | | | RouteUpdate |
723// | | |-----> rtmgr |
724// | | | |
725// | | | RouteUpdate |
726// | | | status:400 |
727// | | |<----- rtmgr |
728// | | | |
729// | | SubDelResp 1 | |
730// | |<-------------| |
731// | | | |
732// | SubDelReq 2 | |
733// |--------------------------->| |
734// | | | |
735// | | | SubDelReq 2 |
736// | | |------------->|
737// | | | |
738// | | | SubDelReq 2 |
739// | | |------------->|
740// | | | |
741// | SubDelResp 2 | |
742// |<---------------------------| |
743//
744//-----------------------------------------------------------------------------
745func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
746 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
747
748 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
750 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200751 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200752 Counter{cSubReqToE2, 1},
753 Counter{cSubRespFromE2, 1},
754 Counter{cSubRespToXapp, 2},
755 Counter{cSubDelReqFromXapp, 2},
756 Counter{cRouteDeleteUpdateFail, 1},
757 Counter{cSubDelReqToE2, 1},
758 Counter{cSubDelRespFromE2, 1},
759 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200760 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200761 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200762
763 //Req1
764 rparams1 := &teststube2ap.E2StubSubsReqParams{}
765 rparams1.Init()
766 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
767 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
768 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
769 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
770
771 //Req2
772 rparams2 := &teststube2ap.E2StubSubsReqParams{}
773 rparams2.Init()
774 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
775 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
776
777 resp, _ := xapp.Subscription.QuerySubscriptions()
778 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
779 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300780 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200781
782 //Del1
783 waiter := rtmgrHttp.AllocNextEvent(false)
784 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
785 waiter.WaitResult(t)
786
787 xappConn1.RecvSubsDelResp(t, deltrans1)
788
789 //Del2
790 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
791 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
792 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
793 xappConn2.RecvSubsDelResp(t, deltrans2)
794 //Wait that subs is cleaned
795 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
796
797 xappConn1.TestMsgChanEmpty(t)
798 xappConn2.TestMsgChanEmpty(t)
799 e2termConn1.TestMsgChanEmpty(t)
800 mainCtrl.wait_registry_empty(t, 10)
801
802 mainCtrl.VerifyCounterValues(t)
803}
804
805//-----------------------------------------------------------------------------
806
807//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200808// TestSubReqAndSubDelOk
809//
810// stub stub
811// +-------+ +---------+ +---------+
812// | xapp | | submgr | | e2term |
813// +-------+ +---------+ +---------+
814// | | |
815// | SubReq | |
816// |------------->| |
817// | | |
818// | | SubReq |
819// | |------------->|
820// | | |
821// | | SubResp |
822// | |<-------------|
823// | | |
824// | SubResp | |
825// |<-------------| |
826// | | |
827// | | |
828// | SubDelReq | |
829// |------------->| |
830// | | |
831// | | SubDelReq |
832// | |------------->|
833// | | |
834// | | SubDelResp |
835// | |<-------------|
836// | | |
837// | SubDelResp | |
838// |<-------------| |
839//
840//-----------------------------------------------------------------------------
841func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200842 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
Anssi Mannila4abf1802021-01-28 13:06:46 +0200844 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200845 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
846 Counter{cSubReqFromXapp, 1},
847 Counter{cSubReqToE2, 1},
848 Counter{cSubRespFromE2, 1},
849 Counter{cSubRespToXapp, 1},
850 Counter{cSubDelReqFromXapp, 1},
851 Counter{cSubDelReqToE2, 1},
852 Counter{cSubDelRespFromE2, 1},
853 Counter{cSubDelRespToXapp, 1},
854 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200855
856 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200857 crereq, cremsg := e2termConn1.RecvSubsReq(t)
858 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200859 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200860
861 resp, _ := xapp.Subscription.QuerySubscriptions()
862 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
863 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300864 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200865
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200866 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200867 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200868
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200869 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200870 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200871
872 //Wait that subs is cleaned
873 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
874
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200875 xappConn1.TestMsgChanEmpty(t)
876 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200877 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200878 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200879
880 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200881}
882
883//-----------------------------------------------------------------------------
884// TestSubReqRetransmission
885//
886// stub stub
887// +-------+ +---------+ +---------+
888// | xapp | | submgr | | e2term |
889// +-------+ +---------+ +---------+
890// | | |
891// | SubReq | |
892// |------------->| |
893// | | |
894// | | SubReq |
895// | |------------->|
896// | | |
897// | SubReq | |
898// | (retrans) | |
899// |------------->| |
900// | | |
901// | | SubResp |
902// | |<-------------|
903// | | |
904// | SubResp | |
905// |<-------------| |
906// | | |
907// | [SUBS DELETE] |
908// | | |
909//
910//-----------------------------------------------------------------------------
911func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200912 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200913
914 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200915 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200916 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
921
Juha Hyttinen1683f912020-04-17 10:39:57 +0300922 // hack as there is no real way to see has message be handled.
923 // Previuos counter check just tells that is has been received by submgr
924 // --> artificial delay
925 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200926 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200927 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200928
929 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200930 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200931 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
932 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200933 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200934
935 //Wait that subs is cleaned
936 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
937
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200938 xappConn1.TestMsgChanEmpty(t)
939 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200940 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200941 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200942}
943
944//-----------------------------------------------------------------------------
945// TestSubDelReqRetransmission
946//
947// stub stub
948// +-------+ +---------+ +---------+
949// | xapp | | submgr | | e2term |
950// +-------+ +---------+ +---------+
951// | | |
952// | [SUBS CREATE] |
953// | | |
954// | | |
955// | SubDelReq | |
956// |------------->| |
957// | | |
958// | | SubDelReq |
959// | |------------->|
960// | | |
961// | SubDelReq | |
962// | (same sub) | |
963// | (same xid) | |
964// |------------->| |
965// | | |
966// | | SubDelResp |
967// | |<-------------|
968// | | |
969// | SubDelResp | |
970// |<-------------| |
971//
972//-----------------------------------------------------------------------------
973func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200974 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200975
976 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200977 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200978 crereq, cremsg := e2termConn1.RecvSubsReq(t)
979 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200980 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200981
982 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200983 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200984 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200985
986 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200987 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200988 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
989
Juha Hyttinen1683f912020-04-17 10:39:57 +0300990 // hack as there is no real way to see has message be handled.
991 // Previuos counter check just tells that is has been received by submgr
992 // --> artificial delay
993 <-time.After(1 * time.Second)
994
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200995 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200996 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200997
998 //Wait that subs is cleaned
999 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1000
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001001 xappConn1.TestMsgChanEmpty(t)
1002 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001003 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001004 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005}
1006
1007//-----------------------------------------------------------------------------
1008// TestSubDelReqCollision
1009//
1010// stub stub
1011// +-------+ +---------+ +---------+
1012// | xapp | | submgr | | e2term |
1013// +-------+ +---------+ +---------+
1014// | | |
1015// | [SUBS CREATE] |
1016// | | |
1017// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001018// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001019// |------------->| |
1020// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001021// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001022// | |------------->|
1023// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001024// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001025// | (same sub) | |
1026// | (diff xid) | |
1027// |------------->| |
1028// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001029// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001030// | |<-------------|
1031// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001032// | SubDelResp 1 | |
1033// |<-------------| |
1034// | | |
1035// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001036// |<-------------| |
1037//
1038//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001039
Juha Hyttinenfa015662020-01-24 10:05:18 +02001040func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001041 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001042
1043 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001044 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001045 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1046 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001047 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001048
1049 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001050 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001051 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001052
Juha Hyttinen3944a222020-01-24 11:51:46 +02001053 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001054 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001055 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1056 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001057 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1058
Juha Hyttinen1683f912020-04-17 10:39:57 +03001059 // hack as there is no real way to see has message be handled.
1060 // Previuos counter check just tells that is has been received by submgr
1061 // --> artificial delay
1062 <-time.After(1 * time.Second)
1063
Juha Hyttinen3944a222020-01-24 11:51:46 +02001064 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001065 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001066
1067 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001068 xappConn1.RecvSubsDelResp(t, nil)
1069 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001070
1071 //Wait that subs is cleaned
1072 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1073
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001074 xappConn1.TestMsgChanEmpty(t)
1075 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001076 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001077 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001078}
1079
1080//-----------------------------------------------------------------------------
1081// TestSubReqAndSubDelOkTwoParallel
1082//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001083// stub stub stub
1084// +-------+ +-------+ +---------+ +---------+
1085// | xapp | | xapp | | submgr | | e2term |
1086// +-------+ +-------+ +---------+ +---------+
1087// | | | |
1088// | | | |
1089// | | | |
1090// | | SubReq1 | |
1091// | |------------->| |
1092// | | | |
1093// | | | SubReq1 |
1094// | | |------------->|
1095// | | | |
1096// | SubReq2 | |
1097// |------------------------>| |
1098// | | | |
1099// | | | SubReq2 |
1100// | | |------------->|
1101// | | | |
1102// | | | SubResp1 |
1103// | | |<-------------|
1104// | | SubResp1 | |
1105// | |<-------------| |
1106// | | | |
1107// | | | SubResp2 |
1108// | | |<-------------|
1109// | SubResp2 | |
1110// |<------------------------| |
1111// | | | |
1112// | | [SUBS 1 DELETE] |
1113// | | | |
1114// | | [SUBS 2 DELETE] |
1115// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001116//
1117//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001118
Juha Hyttinenfa015662020-01-24 10:05:18 +02001119func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001120 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001121
1122 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001124 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001125 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001126 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001127
1128 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001129 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001130 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001131
1132 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1133 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1134 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1135
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001137 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001138
1139 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001140 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001141 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001142
1143 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001144 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001148 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001149 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1150 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001151 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152 //Wait that subs is cleaned
1153 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1154
1155 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001156 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001157 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1158 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001159 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001160 //Wait that subs is cleaned
1161 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1162
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001163 xappConn1.TestMsgChanEmpty(t)
1164 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001165 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001166 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001167}
1168
1169//-----------------------------------------------------------------------------
1170// TestSameSubsDiffRan
1171// Same subscription to different RANs
1172//
1173// stub stub
1174// +-------+ +---------+ +---------+
1175// | xapp | | submgr | | e2term |
1176// +-------+ +---------+ +---------+
1177// | | |
1178// | | |
1179// | | |
1180// | SubReq(r1) | |
1181// |------------->| |
1182// | | |
1183// | | SubReq(r1) |
1184// | |------------->|
1185// | | |
1186// | | SubResp(r1) |
1187// | |<-------------|
1188// | | |
1189// | SubResp(r1) | |
1190// |<-------------| |
1191// | | |
1192// | SubReq(r2) | |
1193// |------------->| |
1194// | | |
1195// | | SubReq(r2) |
1196// | |------------->|
1197// | | |
1198// | | SubResp(r2) |
1199// | |<-------------|
1200// | | |
1201// | SubResp(r2) | |
1202// |<-------------| |
1203// | | |
1204// | [SUBS r1 DELETE] |
1205// | | |
1206// | [SUBS r2 DELETE] |
1207// | | |
1208//
1209//-----------------------------------------------------------------------------
1210func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212
1213 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001214 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1215 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001216 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1217 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001219
1220 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001221 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1222 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001223 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1224 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001225 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001226
1227 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001228 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1229 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001230 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1231 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001232 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001233 //Wait that subs is cleaned
1234 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1235
1236 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001237 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1238 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001239 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1240 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001241 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001242 //Wait that subs is cleaned
1243 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1244
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001245 xappConn1.TestMsgChanEmpty(t)
1246 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001247 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001248 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001249}
1250
1251//-----------------------------------------------------------------------------
1252// TestSubReqRetryInSubmgr
1253//
1254// stub stub
1255// +-------+ +---------+ +---------+
1256// | xapp | | submgr | | e2term |
1257// +-------+ +---------+ +---------+
1258// | | |
1259// | SubReq | |
1260// |------------->| |
1261// | | |
1262// | | SubReq |
1263// | |------------->|
1264// | | |
1265// | | |
1266// | | SubReq |
1267// | |------------->|
1268// | | |
1269// | | SubResp |
1270// | |<-------------|
1271// | | |
1272// | SubResp | |
1273// |<-------------| |
1274// | | |
1275// | [SUBS DELETE] |
1276// | | |
1277//
1278//-----------------------------------------------------------------------------
1279
1280func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001281 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001282
1283 // Init counter check
1284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1285 Counter{cSubReqFromXapp, 1},
1286 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001287 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001288 Counter{cSubReReqToE2, 1},
1289 Counter{cSubRespFromE2, 1},
1290 Counter{cSubRespToXapp, 1},
1291 Counter{cSubDelReqFromXapp, 1},
1292 Counter{cSubDelReqToE2, 1},
1293 Counter{cSubDelRespFromE2, 1},
1294 Counter{cSubDelRespToXapp, 1},
1295 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001296
1297 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001298 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001299
1300 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001301 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001302
1303 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001304 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1305 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001306
1307 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001308 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001309
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001310 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001311 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1312 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001313 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001314
1315 // Wait that subs is cleaned
1316 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1317
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 xappConn1.TestMsgChanEmpty(t)
1319 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001320 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001321 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001322
1323 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001324}
1325
1326//-----------------------------------------------------------------------------
1327// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1328//
1329// stub stub
1330// +-------+ +---------+ +---------+
1331// | xapp | | submgr | | e2term |
1332// +-------+ +---------+ +---------+
1333// | | |
1334// | SubReq | |
1335// |------------->| |
1336// | | |
1337// | | SubReq |
1338// | |------------->|
1339// | | |
1340// | | |
1341// | | SubReq |
1342// | |------------->|
1343// | | |
1344// | | SubDelReq |
1345// | |------------->|
1346// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001347// | | SubDelResp |
1348// | |<-------------|
1349// | | |
1350//
1351//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001352func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001353 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001354
1355 // Init counter check
1356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1357 Counter{cSubReqFromXapp, 1},
1358 Counter{cSubReqToE2, 1},
1359 Counter{cSubReReqToE2, 1},
1360 Counter{cSubReqTimerExpiry, 2},
1361 Counter{cSubDelReqToE2, 1},
1362 Counter{cSubDelRespFromE2, 1},
1363 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001364
1365 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001366 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001367
1368 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001369 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001370
1371 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001372 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001373
1374 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001375 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1376 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001377
1378 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001379 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001380
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001381 xappConn1.TestMsgChanEmpty(t)
1382 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001383 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001384 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001385
1386 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001387}
1388
1389//-----------------------------------------------------------------------------
1390// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1391//
1392// stub stub
1393// +-------+ +---------+ +---------+
1394// | xapp | | submgr | | e2term |
1395// +-------+ +---------+ +---------+
1396// | | |
1397// | SubReq | |
1398// |------------->| |
1399// | | |
1400// | | SubReq |
1401// | |------------->|
1402// | | |
1403// | | |
1404// | | SubReq |
1405// | |------------->|
1406// | | |
1407// | | SubDelReq |
1408// | |------------->|
1409// | | |
1410// | | |
1411// | | SubDelReq |
1412// | |------------->|
1413// | | |
1414// | | |
1415//
1416//-----------------------------------------------------------------------------
1417
1418func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001419 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001420
1421 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1422 Counter{cSubReqFromXapp, 1},
1423 Counter{cSubReqToE2, 1},
1424 Counter{cSubReReqToE2, 1},
1425 Counter{cSubReqTimerExpiry, 2},
1426 Counter{cSubDelReqToE2, 1},
1427 Counter{cSubDelReReqToE2, 1},
1428 Counter{cSubDelReqTimerExpiry, 2},
1429 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001430
1431 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001432 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001433
1434 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001435 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001436
1437 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001438 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001439
1440 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001441 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001442
1443 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001444 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001445
1446 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001447 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001448
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001449 xappConn1.TestMsgChanEmpty(t)
1450 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001451 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001452 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001453
1454 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001455}
1456
1457//-----------------------------------------------------------------------------
1458// TestSubReqSubFailRespInSubmgr
1459//
1460// stub stub
1461// +-------+ +---------+ +---------+
1462// | xapp | | submgr | | e2term |
1463// +-------+ +---------+ +---------+
1464// | | |
1465// | SubReq | |
1466// |------------->| |
1467// | | |
1468// | | SubReq |
1469// | |------------->|
1470// | | |
1471// | | SubFail |
1472// | |<-------------|
1473// | | |
1474// | SubFail | |
1475// |<-------------| |
1476// | | |
1477//
1478//-----------------------------------------------------------------------------
1479
1480func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001482
1483 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1484 Counter{cSubReqFromXapp, 1},
1485 Counter{cSubReqToE2, 1},
1486 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001487 Counter{cSubFailToXapp, 1},
1488 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001489
1490 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001491 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001492
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001493 // E2t: Receive SubsReq and send SubsFail (first)
1494 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1495 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1496 fparams1.Set(crereq1)
1497 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1498
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001499 // Xapp: Receive SubsFail
1500 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1501
1502 // Wait that subs is cleaned
1503 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1504
1505 xappConn1.TestMsgChanEmpty(t)
1506 xappConn2.TestMsgChanEmpty(t)
1507 e2termConn1.TestMsgChanEmpty(t)
1508 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001509
1510 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001511}
1512
1513//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001514// TestSubDelReqRetryInSubmgr
1515//
1516// stub stub
1517// +-------+ +---------+ +---------+
1518// | xapp | | submgr | | e2term |
1519// +-------+ +---------+ +---------+
1520// | | |
1521// | [SUBS CREATE] |
1522// | | |
1523// | | |
1524// | SubDelReq | |
1525// |------------->| |
1526// | | |
1527// | | SubDelReq |
1528// | |------------->|
1529// | | |
1530// | | SubDelReq |
1531// | |------------->|
1532// | | |
1533// | | SubDelResp |
1534// | |<-------------|
1535// | | |
1536// | SubDelResp | |
1537// |<-------------| |
1538//
1539//-----------------------------------------------------------------------------
1540
1541func TestSubDelReqRetryInSubmgr(t *testing.T) {
1542
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001543 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001544
1545 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001546 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001547 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1548 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001549 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001550
1551 // Subs Delete
1552 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001553 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001554
1555 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001556 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001557
1558 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001559 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001561
1562 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001563 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001564
1565 // Wait that subs is cleaned
1566 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1567
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001568 xappConn1.TestMsgChanEmpty(t)
1569 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001570 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001571 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001572}
1573
1574//-----------------------------------------------------------------------------
1575// TestSubDelReqTwoRetriesNoRespInSubmgr
1576//
1577// stub stub
1578// +-------+ +---------+ +---------+
1579// | xapp | | submgr | | e2term |
1580// +-------+ +---------+ +---------+
1581// | | |
1582// | [SUBS CREATE] |
1583// | | |
1584// | | |
1585// | SubDelReq | |
1586// |------------->| |
1587// | | |
1588// | | SubDelReq |
1589// | |------------->|
1590// | | |
1591// | | SubDelReq |
1592// | |------------->|
1593// | | |
1594// | | |
1595// | SubDelResp | |
1596// |<-------------| |
1597//
1598//-----------------------------------------------------------------------------
1599
1600func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1601
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001602 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001603
1604 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001605 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001606 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1607 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001608 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001609
1610 // Subs Delete
1611 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001612 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001613
1614 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001615 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001616
1617 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001618 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001619
1620 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001621 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001622
1623 // Wait that subs is cleaned
1624 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1625
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001626 xappConn1.TestMsgChanEmpty(t)
1627 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001628 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001629 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001630}
1631
1632//-----------------------------------------------------------------------------
1633// TestSubDelReqSubDelFailRespInSubmgr
1634//
1635// stub stub
1636// +-------+ +---------+ +---------+
1637// | xapp | | submgr | | e2term |
1638// +-------+ +---------+ +---------+
1639// | | |
1640// | [SUBS CREATE] |
1641// | | |
1642// | | |
1643// | SubDelReq | |
1644// |------------->| |
1645// | | |
1646// | | SubDelReq |
1647// | |------------->|
1648// | | |
1649// | | SubDelFail |
1650// | |<-------------|
1651// | | |
1652// | SubDelResp | |
1653// |<-------------| |
1654// | | |
1655//
1656//-----------------------------------------------------------------------------
1657
1658func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001659 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001660
1661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1662 Counter{cSubReqFromXapp, 1},
1663 Counter{cSubReqToE2, 1},
1664 Counter{cSubRespFromE2, 1},
1665 Counter{cSubRespToXapp, 1},
1666 Counter{cSubDelReqFromXapp, 1},
1667 Counter{cSubDelReqToE2, 1},
1668 Counter{cSubDelFailFromE2, 1},
1669 Counter{cSubDelRespToXapp, 1},
1670 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001671
1672 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001673 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001674 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1675 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001676 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001677
1678 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001679 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001680
1681 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001682 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1683 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001684
1685 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001686 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001687
1688 // Wait that subs is cleaned
1689 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1690
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001691 xappConn1.TestMsgChanEmpty(t)
1692 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001693 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001694 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001695
1696 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001697}
1698
1699//-----------------------------------------------------------------------------
1700// TestSubReqAndSubDelOkSameAction
1701//
1702// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001703// +-------+ +-------+ +---------+ +---------+
1704// | xapp2 | | xapp1 | | submgr | | e2term |
1705// +-------+ +-------+ +---------+ +---------+
1706// | | | |
1707// | | | |
1708// | | | |
1709// | | SubReq1 | |
1710// | |------------->| |
1711// | | | |
1712// | | | SubReq1 |
1713// | | |------------->|
1714// | | | SubResp1 |
1715// | | |<-------------|
1716// | | SubResp1 | |
1717// | |<-------------| |
1718// | | | |
1719// | SubReq2 | |
1720// |--------------------------->| |
1721// | | | |
1722// | SubResp2 | |
1723// |<---------------------------| |
1724// | | | |
1725// | | SubDelReq 1 | |
1726// | |------------->| |
1727// | | | |
1728// | | SubDelResp 1 | |
1729// | |<-------------| |
1730// | | | |
1731// | SubDelReq 2 | |
1732// |--------------------------->| |
1733// | | | |
1734// | | | SubDelReq 2 |
1735// | | |------------->|
1736// | | | |
1737// | | | SubDelReq 2 |
1738// | | |------------->|
1739// | | | |
1740// | SubDelResp 2 | |
1741// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001742//
1743//-----------------------------------------------------------------------------
1744func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001745 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001746
Anssi Mannila4abf1802021-01-28 13:06:46 +02001747 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001748 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1749 Counter{cSubReqFromXapp, 2},
1750 Counter{cSubReqToE2, 1},
1751 Counter{cSubRespFromE2, 1},
1752 Counter{cSubRespToXapp, 2},
1753 Counter{cMergedSubscriptions, 1},
1754 Counter{cUnmergedSubscriptions, 1},
1755 Counter{cSubDelReqFromXapp, 2},
1756 Counter{cSubDelReqToE2, 1},
1757 Counter{cSubDelRespFromE2, 1},
1758 Counter{cSubDelRespToXapp, 2},
1759 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001760
Juha Hyttinen3944a222020-01-24 11:51:46 +02001761 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001762 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001763 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001764 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001765 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1766 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001767 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001768
1769 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001770 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001771 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001773 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001774
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001775 resp, _ := xapp.Subscription.QuerySubscriptions()
1776 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1777 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001778 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001779
Juha Hyttinen3944a222020-01-24 11:51:46 +02001780 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001781 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001782 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001783
1784 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001785 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001786 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1787 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001788 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001789 //Wait that subs is cleaned
1790 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1791
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001792 xappConn1.TestMsgChanEmpty(t)
1793 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001794 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001795 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001796
1797 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001798}
1799
1800//-----------------------------------------------------------------------------
1801// TestSubReqAndSubDelOkSameActionParallel
1802//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001803// stub stub stub
1804// +-------+ +-------+ +---------+ +---------+
1805// | xapp2 | | xapp1 | | submgr | | e2term |
1806// +-------+ +-------+ +---------+ +---------+
1807// | | | |
1808// | | | |
1809// | | | |
1810// | | SubReq1 | |
1811// | |------------->| |
1812// | | | |
1813// | | | SubReq1 |
1814// | | |------------->|
1815// | SubReq2 | |
1816// |--------------------------->| |
1817// | | | SubResp1 |
1818// | | |<-------------|
1819// | | SubResp1 | |
1820// | |<-------------| |
1821// | | | |
1822// | SubResp2 | |
1823// |<---------------------------| |
1824// | | | |
1825// | | SubDelReq 1 | |
1826// | |------------->| |
1827// | | | |
1828// | | SubDelResp 1 | |
1829// | |<-------------| |
1830// | | | |
1831// | SubDelReq 2 | |
1832// |--------------------------->| |
1833// | | | |
1834// | | | SubDelReq 2 |
1835// | | |------------->|
1836// | | | |
1837// | | | SubDelReq 2 |
1838// | | |------------->|
1839// | | | |
1840// | SubDelResp 2 | |
1841// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001842//
1843//-----------------------------------------------------------------------------
1844func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001845 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001846
1847 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001848 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001849 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001850 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001851 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001852
1853 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001854 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001855 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001856 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001857
1858 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001859 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001860 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001861
1862 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001863 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001864
1865 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001866 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1867 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001868
1869 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001870 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001871 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1872 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001873 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001874
1875 //Wait that subs is cleaned
1876 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1877
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001878 xappConn1.TestMsgChanEmpty(t)
1879 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001880 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001881 mainCtrl.wait_registry_empty(t, 10)
1882}
1883
1884//-----------------------------------------------------------------------------
1885// TestSubReqAndSubDelNokSameActionParallel
1886//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001887// stub stub stub
1888// +-------+ +-------+ +---------+ +---------+
1889// | xapp2 | | xapp1 | | submgr | | e2term |
1890// +-------+ +-------+ +---------+ +---------+
1891// | | | |
1892// | | | |
1893// | | | |
1894// | | SubReq1 | |
1895// | |------------->| |
1896// | | | |
1897// | | | SubReq1 |
1898// | | |------------->|
1899// | SubReq2 | |
1900// |--------------------------->| |
1901// | | | SubFail1 |
1902// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001903// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001904// | | SubFail1 | |
1905// | |<-------------| |
1906// | | | |
1907// | SubFail2 | |
1908// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001909//
1910//-----------------------------------------------------------------------------
1911func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001912 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001913
1914 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001915 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001916 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001917 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001918
1919 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001920 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001921
1922 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001923 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001924 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001925 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001926 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001927 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001928
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001929 // E2t: send SubsFail (first)
1930 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1931 fparams1.Set(crereq1)
1932 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1933
Juha Hyttinen3944a222020-01-24 11:51:46 +02001934 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001935 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001936 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001937 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001938
1939 //Wait that subs is cleaned
1940 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1941
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001942 xappConn1.TestMsgChanEmpty(t)
1943 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001944 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001945 mainCtrl.wait_registry_empty(t, 10)
1946}
1947
1948//-----------------------------------------------------------------------------
1949// TestSubReqAndSubDelNoAnswerSameActionParallel
1950//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001951// stub stub stub
1952// +-------+ +-------+ +---------+ +---------+
1953// | xapp2 | | xapp1 | | submgr | | e2term |
1954// +-------+ +-------+ +---------+ +---------+
1955// | | | |
1956// | | | |
1957// | | | |
1958// | | SubReq1 | |
1959// | |------------->| |
1960// | | | |
1961// | | | SubReq1 |
1962// | | |------------->|
1963// | | SubReq2 | |
1964// |--------------------------->| |
1965// | | | |
1966// | | | SubReq1 |
1967// | | |------------->|
1968// | | | |
1969// | | | |
1970// | | | SubDelReq |
1971// | | |------------->|
1972// | | | |
1973// | | | SubDelResp |
1974// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001975//
1976//-----------------------------------------------------------------------------
1977func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001978 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001979
1980 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001981 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001982 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001983 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001984
Juha Hyttinen1683f912020-04-17 10:39:57 +03001985 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001986
1987 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001988 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001989 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001990 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001991 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001992 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001993
1994 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001995 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001996
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001997 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1998 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001999
2000 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002001 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002002
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002003 xappConn1.TestMsgChanEmpty(t)
2004 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002005 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002006 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002007}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002008
2009//----------------------------- Policy cases ---------------------------------
2010//-----------------------------------------------------------------------------
2011// TestSubReqPolicyAndSubDelOk
2012//
2013// stub stub
2014// +-------+ +---------+ +---------+
2015// | xapp | | submgr | | e2term |
2016// +-------+ +---------+ +---------+
2017// | | |
2018// | SubReq | |
2019// |------------->| |
2020// | | |
2021// | | SubReq |
2022// | |------------->|
2023// | | |
2024// | | SubResp |
2025// | |<-------------|
2026// | | |
2027// | SubResp | |
2028// |<-------------| |
2029// | | |
2030// | | |
2031// | SubDelReq | |
2032// |------------->| |
2033// | | |
2034// | | SubDelReq |
2035// | |------------->|
2036// | | |
2037// | | SubDelResp |
2038// | |<-------------|
2039// | | |
2040// | SubDelResp | |
2041// |<-------------| |
2042//
2043//-----------------------------------------------------------------------------
2044func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2045 CaseBegin("TestSubReqAndSubDelOk")
2046
2047 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2048 rparams1.Init()
2049 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2050 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2051
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002052 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2053 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002054 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2055 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002056 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002057
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002058 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002059 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002060
2061 //Wait that subs is cleaned
2062 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2063
2064 xappConn1.TestMsgChanEmpty(t)
2065 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002066 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002067 mainCtrl.wait_registry_empty(t, 10)
2068}
2069
2070//-----------------------------------------------------------------------------
2071// TestSubReqPolicyChangeAndSubDelOk
2072//
2073// stub stub
2074// +-------+ +---------+ +---------+
2075// | xapp | | submgr | | e2term |
2076// +-------+ +---------+ +---------+
2077// | | |
2078// | SubReq | |
2079// |------------->| |
2080// | | |
2081// | | SubReq |
2082// | |------------->|
2083// | | |
2084// | | SubResp |
2085// | |<-------------|
2086// | | |
2087// | SubResp | |
2088// |<-------------| |
2089// | | |
2090// | SubReq | |
2091// |------------->| |
2092// | | |
2093// | | SubReq |
2094// | |------------->|
2095// | | |
2096// | | SubResp |
2097// | |<-------------|
2098// | | |
2099// | SubResp | |
2100// |<-------------| |
2101// | | |
2102// | SubDelReq | |
2103// |------------->| |
2104// | | |
2105// | | SubDelReq |
2106// | |------------->|
2107// | | |
2108// | | SubDelResp |
2109// | |<-------------|
2110// | | |
2111// | SubDelResp | |
2112// |<-------------| |
2113//
2114//-----------------------------------------------------------------------------
2115
2116func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2117 CaseBegin("TestSubReqAndSubDelOk")
2118
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002119 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2120 rparams1.Init()
2121 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2122 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002123
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002124 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2125 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002126 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2127
2128 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002129 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002130 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2131 xappConn1.SendSubsReq(t, rparams1, cretrans)
2132
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002133 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2134 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002135 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2136 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002138
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002139 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002140 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002141
2142 //Wait that subs is cleaned
2143 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2144
2145 xappConn1.TestMsgChanEmpty(t)
2146 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002147 e2termConn1.TestMsgChanEmpty(t)
2148 mainCtrl.wait_registry_empty(t, 10)
2149}
2150
2151//-----------------------------------------------------------------------------
2152// TestSubReqAndSubDelOkTwoE2termParallel
2153//
2154// stub stub stub
2155// +-------+ +---------+ +---------+ +---------+
2156// | xapp | | submgr | | e2term1 | | e2term2 |
2157// +-------+ +---------+ +---------+ +---------+
2158// | | | |
2159// | | | |
2160// | | | |
2161// | SubReq1 | | |
2162// |------------->| | |
2163// | | | |
2164// | | SubReq1 | |
2165// | |------------->| |
2166// | | | |
2167// | SubReq2 | | |
2168// |------------->| | |
2169// | | | |
2170// | | SubReq2 | |
2171// | |---------------------------->|
2172// | | | |
2173// | | SubResp1 | |
2174// | |<-------------| |
2175// | SubResp1 | | |
2176// |<-------------| | |
2177// | | SubResp2 | |
2178// | |<----------------------------|
2179// | SubResp2 | | |
2180// |<-------------| | |
2181// | | | |
2182// | [SUBS 1 DELETE] | |
2183// | | | |
2184// | [SUBS 2 DELETE] | |
2185// | | | |
2186//
2187//-----------------------------------------------------------------------------
2188func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2189 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2190
2191 //Req1
2192 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2193 xappConn1.SendSubsReq(t, nil, cretrans1)
2194 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2195
2196 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2197 xappConn1.SendSubsReq(t, nil, cretrans2)
2198 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2199
2200 //Resp1
2201 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2202 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2203
2204 //Resp2
2205 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2206 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2207
2208 //Del1
2209 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2212 xappConn1.RecvSubsDelResp(t, deltrans1)
2213 //Wait that subs is cleaned
2214 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2215
2216 //Del2
2217 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2218 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2219 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2220 xappConn1.RecvSubsDelResp(t, deltrans2)
2221 //Wait that subs is cleaned
2222 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2223
2224 xappConn1.TestMsgChanEmpty(t)
2225 xappConn2.TestMsgChanEmpty(t)
2226 e2termConn1.TestMsgChanEmpty(t)
2227 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002228 mainCtrl.wait_registry_empty(t, 10)
2229}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002230
2231//-----------------------------------------------------------------------------
2232// TestSubReqInsertAndSubDelOk
2233//
2234// stub stub
2235// +-------+ +---------+ +---------+
2236// | xapp | | submgr | | e2term |
2237// +-------+ +---------+ +---------+
2238// | | |
2239// | SubReq | |
2240// |------------->| |
2241// | | |
2242// | | SubReq |
2243// | |------------->|
2244// | | |
2245// | | SubResp |
2246// | |<-------------|
2247// | | |
2248// | SubResp | |
2249// |<-------------| |
2250// | | |
2251// | | |
2252// | SubDelReq | |
2253// |------------->| |
2254// | | |
2255// | | SubDelReq |
2256// | |------------->|
2257// | | |
2258// | | SubDelResp |
2259// | |<-------------|
2260// | | |
2261// | SubDelResp | |
2262// |<-------------| |
2263//
2264//-----------------------------------------------------------------------------
2265func TestSubReqInsertAndSubDelOk(t *testing.T) {
2266 CaseBegin("TestInsertSubReqAndSubDelOk")
2267
2268 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2269 rparams1.Init()
2270 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2271 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2272
2273 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2274 e2termConn1.SendSubsResp(t, crereq, cremsg)
2275 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2276 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2277 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2278
2279 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2280 xappConn1.RecvSubsDelResp(t, deltrans)
2281
2282 //Wait that subs is cleaned
2283 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2284
2285 xappConn1.TestMsgChanEmpty(t)
2286 xappConn2.TestMsgChanEmpty(t)
2287 e2termConn1.TestMsgChanEmpty(t)
2288 mainCtrl.wait_registry_empty(t, 10)
2289}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002290
2291//-----------------------------------------------------------------------------
2292// TestSubReqRetransmissionWithSameSubIdDiffXid
2293//
2294// This case simulates case where xApp restarts and starts sending same
2295// subscription requests which have already subscribed successfully
2296
2297// stub stub
2298// +-------+ +---------+ +---------+
2299// | xapp | | submgr | | e2term |
2300// +-------+ +---------+ +---------+
2301// | | |
2302// | SubReq | |
2303// |------------->| |
2304// | | |
2305// | | SubReq |
2306// | |------------->|
2307// | | |
2308// | | SubResp |
2309// | |<-------------|
2310// | | |
2311// | SubResp | |
2312// |<-------------| |
2313// | | |
2314// | xApp restart | |
2315// | | |
2316// | SubReq | |
2317// | (retrans with same xApp generated subid but diff xid)
2318// |------------->| |
2319// | | |
2320// | SubResp | |
2321// |<-------------| |
2322// | | |
2323// | [SUBS DELETE] |
2324// | | |
2325//
2326//-----------------------------------------------------------------------------
2327func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2328 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2329
2330 //Subs Create
2331 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2332 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2333 e2termConn1.SendSubsResp(t, crereq, cremsg)
2334 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2335
2336 // xApp restart here
2337 // --> artificial delay
2338 <-time.After(1 * time.Second)
2339
2340 //Subs Create
2341 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2342 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2343
2344 //Subs Delete
2345 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2346 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2347 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2348 xappConn1.RecvSubsDelResp(t, deltrans)
2349
2350 //Wait that subs is cleaned
2351 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2352
2353 xappConn1.TestMsgChanEmpty(t)
2354 xappConn2.TestMsgChanEmpty(t)
2355 e2termConn1.TestMsgChanEmpty(t)
2356 mainCtrl.wait_registry_empty(t, 10)
2357}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002358
2359//-----------------------------------------------------------------------------
2360// TestSubReqNokAndSubDelOkWithRestartInMiddle
2361//
2362// stub stub
2363// +-------+ +---------+ +---------+
2364// | xapp | | submgr | | e2term |
2365// +-------+ +---------+ +---------+
2366// | | |
2367// | SubReq | |
2368// |------------->| |
2369// | | |
2370// | | SubReq |
2371// | |------------->|
2372// | | |
2373// | | SubResp |
2374// | <----|
2375// | |
2376// | Submgr restart |
2377// | |
2378// | | |
2379// | | SubDelReq |
2380// | |------------->|
2381// | | |
2382// | | SubDelResp |
2383// | |<-------------|
2384// | | |
2385//
2386//-----------------------------------------------------------------------------
2387
2388func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2389 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2390
Anssi Mannilac92b4212020-12-07 14:59:34 +02002391 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2392 xappConn1.SendSubsReq(t, nil, nil)
2393 e2termConn1.RecvSubsReq(t)
2394 mainCtrl.SetResetTestFlag(t, false)
2395
2396 resp, _ := xapp.Subscription.QuerySubscriptions()
2397 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002398 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002399 e2SubsId := uint32(resp[0].SubscriptionID)
2400 t.Logf("e2SubsId = %v", e2SubsId)
2401
archaggeafbf95f2021-04-14 08:54:05 +03002402 mainCtrl.SimulateRestart(t)
2403 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002404
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002405 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002406 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2407 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2408
2409 // Wait that subs is cleaned
2410 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2411
2412 xappConn1.TestMsgChanEmpty(t)
2413 xappConn2.TestMsgChanEmpty(t)
2414 e2termConn1.TestMsgChanEmpty(t)
2415 mainCtrl.wait_registry_empty(t, 10)
2416}
2417
2418//-----------------------------------------------------------------------------
2419// TestSubReqAndSubDelOkWithRestartInMiddle
2420//
2421// stub stub
2422// +-------+ +---------+ +---------+
2423// | xapp | | submgr | | e2term |
2424// +-------+ +---------+ +---------+
2425// | | |
2426// | SubReq | |
2427// |------------->| |
2428// | | |
2429// | | SubReq |
2430// | |------------->|
2431// | | |
2432// | | SubResp |
2433// | |<-------------|
2434// | | |
2435// | SubResp | |
2436// |<-------------| |
2437// | | |
2438// | |
2439// | Submgr restart |
2440// | |
2441// | SubDelReq | |
2442// |------------->| |
2443// | | |
2444// | | SubDelReq |
2445// | |------------->|
2446// | | |
2447// | | SubDelResp |
2448// | |<-------------|
2449// | | |
2450// | SubDelResp | |
2451// |<-------------| |
2452//
2453//-----------------------------------------------------------------------------
2454
2455func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2456 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2457
2458 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2459 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2460 e2termConn1.SendSubsResp(t, crereq, cremsg)
2461 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2462
2463 // Check subscription
2464 resp, _ := xapp.Subscription.QuerySubscriptions()
2465 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2466 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002467 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002468
2469 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002470 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002471
Anssi Mannila54838ed2021-11-19 11:25:01 +02002472 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2473 // That needs to be completed before successful subscription query is possible
2474 <-time.After(time.Second * 1)
2475
Anssi Mannilac92b4212020-12-07 14:59:34 +02002476 // Check that subscription is restored correctly after restart
2477 resp, _ = xapp.Subscription.QuerySubscriptions()
2478 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2479 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002480 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002481
2482 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2483 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2484 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2485 xappConn1.RecvSubsDelResp(t, deltrans)
2486
2487 //Wait that subs is cleaned
2488 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2489
2490 xappConn1.TestMsgChanEmpty(t)
2491 xappConn2.TestMsgChanEmpty(t)
2492 e2termConn1.TestMsgChanEmpty(t)
2493 mainCtrl.wait_registry_empty(t, 10)
2494}
2495
2496//-----------------------------------------------------------------------------
2497// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2498//
2499// stub stub
2500// +-------+ +-------+ +---------+ +---------+
2501// | xapp2 | | xapp1 | | submgr | | e2term |
2502// +-------+ +-------+ +---------+ +---------+
2503// | | | |
2504// | | | |
2505// | | | |
2506// | | SubReq1 | |
2507// | |------------->| |
2508// | | | |
2509// | | | SubReq1 |
2510// | | |------------->|
2511// | | | SubResp1 |
2512// | | |<-------------|
2513// | | SubResp1 | |
2514// | |<-------------| |
2515// | | | |
2516// | |
2517// | submgr restart |
2518// | |
2519// | | | |
2520// | | | |
2521// | SubReq2 | |
2522// |--------------------------->| |
2523// | | | |
2524// | SubResp2 | |
2525// |<---------------------------| |
2526// | | | |
2527// | | SubDelReq 1 | |
2528// | |------------->| |
2529// | | | |
2530// | | SubDelResp 1 | |
2531// | |<-------------| |
2532// | | | |
2533// | | | |
2534// | |
2535// | submgr restart |
2536// | |
2537// | | | |
2538// | SubDelReq 2 | |
2539// |--------------------------->| |
2540// | | | |
2541// | | | SubDelReq 2 |
2542// | | |------------->|
2543// | | | |
2544// | | | SubDelReq 2 |
2545// | | |------------->|
2546// | | | |
2547// | SubDelResp 2 | |
2548// |<---------------------------| |
2549//
2550//-----------------------------------------------------------------------------
2551
2552func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2553 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2554
2555 //Req1
2556 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2557 rparams1.Init()
2558 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2559 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2560 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2561 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2562
2563 //Req2
2564 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2565 rparams2.Init()
2566 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2567 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2568
2569 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002570 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002571 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2572 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002573 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002574
2575 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002576 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002577
Anssi Mannila54838ed2021-11-19 11:25:01 +02002578 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2579 // That needs to be completed before successful subscription query is possible
2580 <-time.After(time.Second * 1)
2581
Anssi Mannilac92b4212020-12-07 14:59:34 +02002582 // Check that subscription is restored correctly after restart
2583 resp, _ = xapp.Subscription.QuerySubscriptions()
2584 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2585 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002586 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002587
2588 //Del1
2589 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2590 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2591 xappConn1.RecvSubsDelResp(t, deltrans1)
2592 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2593
2594 mainCtrl.SimulateRestart(t)
2595 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2596
Anssi Mannila54838ed2021-11-19 11:25:01 +02002597 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2598 // Submgr need be ready before successful subscription deletion is possible
2599 <-time.After(time.Second * 1)
2600
Anssi Mannilac92b4212020-12-07 14:59:34 +02002601 //Del2
2602 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2603 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2604
2605 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2606 xappConn2.RecvSubsDelResp(t, deltrans2)
2607
2608 //Wait that subs is cleaned
2609 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2610
2611 xappConn1.TestMsgChanEmpty(t)
2612 xappConn2.TestMsgChanEmpty(t)
2613 e2termConn1.TestMsgChanEmpty(t)
2614 mainCtrl.wait_registry_empty(t, 10)
2615}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002616
archaggeafbf95f2021-04-14 08:54:05 +03002617//*****************************************************************************
2618// REST interface test cases
2619//*****************************************************************************
2620
Anssi Mannila47518ae2021-04-16 09:27:07 +03002621//-----------------------------------------------------------------------------
2622// Test debug GET and POST requests
2623//
2624// curl
2625// +-------+ +---------+
2626// | user | | submgr |
2627// +-------+ +---------+
2628// | |
2629// | GET/POST Req |
2630// |------------->|
2631// | Resp |
2632// |<-------------|
2633// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002634func TestGetSubscriptions(t *testing.T) {
2635
2636 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2637}
2638
2639func TestGetSymptomData(t *testing.T) {
2640
2641 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2642}
2643
2644func TestPostdeleteSubId(t *testing.T) {
2645
2646 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2647}
2648
2649func TestPostEmptyDb(t *testing.T) {
2650
2651 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2652}
archaggeafbf95f2021-04-14 08:54:05 +03002653
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002654func TestGetRestSubscriptions(t *testing.T) {
2655
2656 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2657}
2658
archaggeafbf95f2021-04-14 08:54:05 +03002659//-----------------------------------------------------------------------------
2660// TestRESTSubReqAndRouteNok
2661//
2662// stub stub
2663// +-------+ +---------+ +---------+
2664// | xapp | | submgr | | rtmgr |
2665// +-------+ +---------+ +---------+
2666// | | |
2667// | RESTSubReq | |
2668// |---------------->| |
2669// | | |
2670// | RESTSubResp | |
2671// |<----------------| |
2672// | | RouteCreate |
2673// | |------------->|
2674// | | |
2675// | | RouteCreate |
2676// | | status:400 |
2677// | |(Bad request) |
2678// | |<-------------|
2679// | RESTNotif | |
2680// |<----------------| |
2681// | | |
2682// | [SUBS INT DELETE] |
2683// | | |
2684// | RESTSubDelReq | |
2685// |---------------->| |
2686// | RESTSubDelResp | |
2687// |<----------------| |
2688//
2689//-----------------------------------------------------------------------------
2690func TestRESTSubReqAndRouteNok(t *testing.T) {
2691 CaseBegin("TestRESTSubReqAndRouteNok")
2692
2693 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002694 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002695 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002696 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002697 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002698 Counter{cRestSubDelReqFromXapp, 1},
2699 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002700 })
2701
2702 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002703
Markku Virtanenda34eec2021-05-20 08:22:04 +00002704 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2705 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002706 newSubsId := mainCtrl.get_registry_next_subid(t)
2707
2708 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002709 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002710 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002711 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002712 waiter.WaitResult(t)
2713
archaggeafbf95f2021-04-14 08:54:05 +03002714 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002715 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002716
2717 // Del
2718 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2719
2720 // Wait that subs is cleaned
2721 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2722 waitSubsCleanup(t, e2SubsId, 10)
2723 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002724 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002725}
2726
2727func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2728 CaseBegin("TestSubReqAndRouteUpdateNok")
2729
2730 //Init counter check
2731 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002732 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002733 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002734 Counter{cSubReqToE2, 1},
2735 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002736 Counter{cRestSubNotifToXapp, 1},
2737 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002738 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002739 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002740 Counter{cSubDelReqToE2, 1},
2741 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002742 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002743 })
2744
2745 var params *teststube2ap.RESTSubsReqParams = nil
2746
2747 //Subs Create
2748 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2749
2750 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2751
2752 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2753 waiter := rtmgrHttp.AllocNextEvent(false)
2754 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002755 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002756 params.SetMeid("RAN_NAME_1")
2757 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002758 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002759 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002760 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03002761 xappConn2.WaitRESTNotification(t, restSubId2)
2762
2763 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2764
2765 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002766 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03002767
2768 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2769 //Wait that subs is cleaned
2770 waitSubsCleanup(t, e2SubsId, 10)
2771
2772 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002773 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002774}
2775
2776func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2777 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2778
2779 // Init counter check
2780 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002781 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002782 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002783 Counter{cSubReqToE2, 1},
2784 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002785 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002786 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002787 Counter{cRouteDeleteFail, 1},
2788 Counter{cSubDelReqToE2, 1},
2789 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002790 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002791 })
2792
2793 var params *teststube2ap.RESTSubsReqParams = nil
2794
2795 //Subs Create
2796 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2797
2798 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2799
2800 waiter := rtmgrHttp.AllocNextEvent(false)
2801 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2802 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2803 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2804 waiter.WaitResult(t)
2805
2806 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002807 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002808 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002809}
2810
2811func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2812 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2813
2814 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002815 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002816 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002817 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002818 Counter{cSubReqToE2, 1},
2819 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002820 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002821 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002822 Counter{cRouteDeleteUpdateFail, 1},
2823 Counter{cSubDelReqToE2, 1},
2824 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002825 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002826 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002827 })
2828
2829 var params *teststube2ap.RESTSubsReqParams = nil
2830
2831 //Subs Create
2832 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2833
2834 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2835 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2836
2837 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2838
2839 //Del1, this shall fail on rtmgr side
2840 waiter := rtmgrHttp.AllocNextEvent(false)
2841 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2842 waiter.WaitResult(t)
2843
2844 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2845
2846 //Del2
2847 deleteXapp2Subscription(t, &restSubId2)
2848
2849 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002850 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002851 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002852}
2853
2854//-----------------------------------------------------------------------------
2855// TestRESTSubReqRetransmission
2856//
2857// stub stub
2858// +-------+ +---------+ +---------+
2859// | xapp | | submgr | | e2term |
2860// +-------+ +---------+ +---------+
2861// | | |
2862// | RESTSubReq1 | |
2863// |---------------->| |
2864// | | |
2865// | RESTSubResp | |
2866// |<----------------| |
2867// | | SubReq1 |
2868// | |------------->|
2869// | | |
2870// | RESTSubReq2 | |
2871// | (retrans) | |
2872// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002873// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002874// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002875// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002876// | | SubResp1 |
2877// | |<-------------|
2878// | RESTNotif1 | |
2879// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002880// | | |
2881// | [SUBS DELETE] |
2882// | | |
2883//
2884//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002885
archaggeafbf95f2021-04-14 08:54:05 +03002886func TestRESTSubReqRetransmission(t *testing.T) {
2887 CaseBegin("TestRESTSubReqRetransmission")
2888
2889 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002890 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002891 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002892 Counter{cSubReqToE2, 1},
2893 Counter{cSubRespFromE2, 1},
2894 Counter{cRestSubNotifToXapp, 1},
2895 Counter{cRestSubDelReqFromXapp, 1},
2896 Counter{cSubDelReqToE2, 1},
2897 Counter{cSubDelRespFromE2, 1},
2898 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002899 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002900 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002901 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2902 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2903
2904 // Subs Create
2905 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002906
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002907 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002908 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002909
Anssi Mannilab43397e2021-11-16 12:06:16 +02002910 xappConn1.SendRESTSubsReq(t, params)
2911 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03002912
Anssi Mannilab43397e2021-11-16 12:06:16 +02002913 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03002914
2915 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02002916 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03002917 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2918 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002919
Anssi Mannilab43397e2021-11-16 12:06:16 +02002920 e2SubsId := <-xappConn1.ListedRESTNotifications
2921
2922 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002923
2924 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02002925 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002926 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2927 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2928
Anssi Mannilab43397e2021-11-16 12:06:16 +02002929 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002930
2931 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002932 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002933}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002934
Markku Virtanen42723e22021-06-15 10:09:23 +03002935//-----------------------------------------------------------------------------
2936// stub stub stub
2937// +-------+ +---------+ +---------+ +---------+
2938// | xapp | | submgr | | e2term | | rtmgr |
2939// +-------+ +---------+ +---------+ +---------+
2940// | | | |
2941// | RESTSubReq | | |
2942// |---------------->| | |
2943// | RESTSubResp | | |
2944// |<----------------| | |
2945// | | RouteCreate | |
2946// | |--------------------------->|
2947// | | RouteResponse| |
2948// | |<---------------------------| // The order of these events may vary
2949// | | SubReq | |
2950// | |------------->| | // The order of these events may vary
2951// | | SubResp | |
2952// | |<-------------| |
2953// | RESTNotif1 | | |
2954// |<----------------| | |
2955// | RESTSubReq | | |
2956// | [RETRANS1] | | |
2957// |---------------->| | |
2958// | RESTNotif1 | | |
2959// |<----------------| | |
2960// | RESTSubReq | | |
2961// | [RETRANS2] | | |
2962// |---------------->| | |
2963// | RESTNotif1 | | |
2964// |<----------------| | |
2965// | RESTSubDelReq | | |
2966// |---------------->| | |
2967// | | SubDelReq | |
2968// | |------------->| |
2969// | RESTSubDelResp| | |
2970// |<----------------| | |
2971// | | SubDelResp | |
2972// | |<-------------| |
2973// | | | |
2974//
2975//-----------------------------------------------------------------------------
2976
2977func TestRESTSubReqRetransmissionV2(t *testing.T) {
2978 CaseBegin("TestRESTSubReqRetransmissionV2")
2979
2980 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2981 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002982 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03002983 Counter{cRestSubRespToXapp, 3},
2984 Counter{cSubReqToE2, 1},
2985 Counter{cSubRespFromE2, 1},
2986 Counter{cRestSubNotifToXapp, 3},
2987 Counter{cRestSubDelReqFromXapp, 1},
2988 Counter{cSubDelReqToE2, 1},
2989 Counter{cSubDelRespFromE2, 1},
2990 Counter{cRestSubDelRespToXapp, 1},
2991 })
2992
2993 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2994
2995 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2996
2997 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2998
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02002999 mainCtrl.WaitOngoingRequestMapEmpty()
3000
Markku Virtanen42723e22021-06-15 10:09:23 +03003001 //1.st resend
3002 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3003
3004 assert.Equal(t, restSubId_resend, restSubId)
3005
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003006 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003007
3008 //2.nd resend
3009 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3010
3011 assert.Equal(t, restSubId_resend2, restSubId)
3012
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003013 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003014
3015 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3016
3017 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003018 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003019 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003020}
3021
3022//-----------------------------------------------------------------------------
3023// stub stub stub
3024// +-------+ +---------+ +---------+ +---------+
3025// | xapp | | submgr | | e2term | | rtmgr |
3026// +-------+ +---------+ +---------+ +---------+
3027// | | | |
3028// | RESTSubReq | | |
3029// |---------------->| | |
3030// | RESTSubResp | | |
3031// |<----------------| | |
3032// | | RouteCreate | |
3033// | |--------------------------->|
3034// | | RouteResponse| |
3035// | |<---------------------------| // The order of these events may vary
3036// | | SubReq | |
3037// | |------------->| | // The order of these events may vary
3038// | | SubResp | |
3039// | |<-------------| |
3040// | RESTNotif1 | | |
3041// |<----------------| | |
3042// | RESTSubReq | | |
3043// | [RETRANS, with RESTsubsId] | |
3044// |---------------->| | |
3045// | RESTNotif1 | | |
3046// |<----------------| | |
3047// | RESTSubReq | | |
3048// | [RETRANS, without RESTsubsId] | |
3049// |---------------->| | |
3050// | RESTNotif1 | | |
3051// |<----------------| | |
3052// | RESTSubDelReq | | |
3053// |---------------->| | |
3054// | | SubDelReq | |
3055// | |------------->| |
3056// | RESTSubDelResp| | |
3057// |<----------------| | |
3058// | | SubDelResp | |
3059// | |<-------------| |
3060// | | | |
3061//
3062//-----------------------------------------------------------------------------
3063func TestRESTSubReqRetransmissionV3(t *testing.T) {
3064 CaseBegin("TestRESTSubReqRetransmissionV3")
3065
3066 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3067 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003068 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003069 Counter{cRestSubRespToXapp, 3},
3070 Counter{cSubReqToE2, 1},
3071 Counter{cSubRespFromE2, 1},
3072 Counter{cRestSubNotifToXapp, 3},
3073 Counter{cRestSubDelReqFromXapp, 1},
3074 Counter{cSubDelReqToE2, 1},
3075 Counter{cSubDelRespFromE2, 1},
3076 Counter{cRestSubDelRespToXapp, 1},
3077 })
3078
3079 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3080
3081 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3082
3083 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3084
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003085 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003086
3087 //1.st resend with subscription ID
3088 params.SetSubscriptionID(&restSubId)
3089 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3090
3091 assert.Equal(t, restSubId_resend, restSubId)
3092
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003093 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003094
3095 //2.nd resend without subscription ID (faking app restart)
3096 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3097 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3098
3099 assert.Equal(t, restSubId_resend2, restSubId)
3100
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003101 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003102
3103 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3104
3105 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003106 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003107 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003108}
3109
3110//-----------------------------------------------------------------------------
3111// stub stub stub
3112// +-------+ +---------+ +---------+ +---------+
3113// | xapp | | submgr | | e2term | | rtmgr |
3114// +-------+ +---------+ +---------+ +---------+
3115// | | | |
3116// | RESTSubReq | | |
3117// |---------------->| | |
3118// | RESTSubResp | | |
3119// |<----------------| | |
3120// | | RouteCreate | |
3121// | |--------------------------->|
3122// | | RouteResponse| |
3123// | |<---------------------------|
3124// | | SubReq | |
3125// | |------------->| |
3126// | | SubResp | |
3127// | |<-------------| |
3128// | RESTNotif1 | | |
3129// |<----------------| | |
3130// | RESTSubReq | | |
3131// | [with RestSUbsId + one additional e2 subDetail]
3132// |---------------->| | |
3133// | RESTNotif1 | | |
3134// | [for initial e2 subDetail] | |
3135// |<----------------| | |
3136// | | RouteCreate | |
3137// | |--------------------------->|
3138// | | RouteResponse| |
3139// | |<---------------------------|
3140// | | SubReq | |
3141// | |------------->| |
3142// | | SubResp | |
3143// | |<-------------| |
3144// | RESTNotif1 | | |
3145// |<----------------| | |
3146// | RESTSubReq | | |
3147// | [with RESTsubsId initial request] |
3148// |---------------->| | |
3149// | RESTNotif1 | | |
3150// |<----------------| | |
3151// | RESTSubDelReq | | |
3152// |---------------->| | |
3153// | RESTSubDelResp| | |
3154// |<----------------| | |
3155// | | SubDelReq | |
3156// | |------------->| |
3157// | | SubDelResp | |
3158// | |<-------------| |
3159// | | SubDelReq | |
3160// | |------------->| |
3161// | | SubDelResp | |
3162// | |<-------------| |
3163// | | | |
3164//
3165//-----------------------------------------------------------------------------
3166
3167func TestRESTSubReqRetransmissionV4(t *testing.T) {
3168 CaseBegin("TestRESTSubReqRetransmissionV4")
3169
3170 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3171 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003172 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003173 Counter{cRestSubRespToXapp, 3},
3174 Counter{cSubReqToE2, 2},
3175 Counter{cSubRespFromE2, 2},
3176 Counter{cRestSubNotifToXapp, 4},
3177 Counter{cRestSubDelReqFromXapp, 1},
3178 Counter{cSubDelReqToE2, 2},
3179 Counter{cSubDelRespFromE2, 2},
3180 Counter{cRestSubDelRespToXapp, 1},
3181 })
3182
3183 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3184
3185 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3186
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003187 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003188
3189 // Send modified requst, this time with e2 subscriptions.
3190 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3191 params2.SetSubscriptionID(&restSubId)
3192
3193 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003194 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003195 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3196 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003197 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3198 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003199
3200 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3201
Markku Virtanen2b512b62021-07-30 12:04:00 +00003202 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003203 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3204 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3205 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3206 assert.NotEqual(t, e2SubsId2, 0)
3207
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003208 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003209
3210 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3211 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3212 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003213 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003214 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3215 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3216 assert.Equal(t, restSubId_resend, restSubId_resend2)
3217
Markku Virtanen2b512b62021-07-30 12:04:00 +00003218 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3219 assert.Equal(t, e2SubsId, e2SubsId1)
3220
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003221 mainCtrl.WaitOngoingRequestMapEmpty()
3222
Markku Virtanen42723e22021-06-15 10:09:23 +03003223 // Delete both e2 subscriptions
3224 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3225 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3226 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3227
3228 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003229 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003230 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003231}
3232
3233//-----------------------------------------------------------------------------
3234// stub stub stub
3235// +-------+ +---------+ +---------+ +---------+
3236// | xapp | | submgr | | e2term | | rtmgr |
3237// +-------+ +---------+ +---------+ +---------+
3238// | | | |
3239// | RESTSubReq | | |
3240// |---------------->| | |
3241// | RESTSubResp | | |
3242// |<----------------| | |
3243// | | RouteCreate | |
3244// | |--------------------------->|
3245// | | RouteResponse| |
3246// | |<---------------------------|
3247// | | SubReq | |
3248// | |------------->| |
3249// | | SubResp | |
3250// | |<-------------| |
3251// | RESTNotif1 | | |
3252// |<----------------| | |
3253// | RESTSubReq | | |
3254// | [with RestSUbsId + one additional e2 subDetail]
3255// |---------------->| | |
3256// | RESTNotif1 | | |
3257// | [for initial e2 subDetail] | |
3258// |<----------------| | |
3259// | | RouteCreate | |
3260// | |--------------------------->|
3261// | | RouteResponse| |
3262// | |<---------------------------|
3263// | | SubReq | |
3264// | |------------->| |
3265// | | SubResp | |
3266// | |<-------------| |
3267// | RESTNotif1 | | |
3268// |<----------------| | |
3269// | RESTSubReq | | |
3270// | [without RESTsubsId initial request] |
3271// |---------------->| | |
3272// | RESTNotif1 | | |
3273// |<----------------| | |
3274// | RESTSubDelReq | | |
3275// |---------------->| | |
3276// | RESTSubDelResp| | |
3277// |<----------------| | |
3278// | | SubDelReq | |
3279// | |------------->| |
3280// | | SubDelResp | |
3281// | |<-------------| |
3282// | | SubDelReq | |
3283// | |------------->| |
3284// | | SubDelResp | |
3285// | |<-------------| |
3286// | | | |
3287//
3288//-----------------------------------------------------------------------------
3289
3290func TestRESTSubReqRetransmissionV5(t *testing.T) {
3291 CaseBegin("TestRESTSubReqRetransmissionV5")
3292
3293 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3294 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003295 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003296 Counter{cRestSubRespToXapp, 3},
3297 Counter{cSubReqToE2, 2},
3298 Counter{cSubRespFromE2, 2},
3299 Counter{cRestSubNotifToXapp, 4},
3300 Counter{cRestSubDelReqFromXapp, 1},
3301 Counter{cSubDelReqToE2, 2},
3302 Counter{cSubDelRespFromE2, 2},
3303 Counter{cRestSubDelRespToXapp, 1},
3304 })
3305
3306 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3307
3308 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3309
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003310 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003311
3312 // Send modified requst, this time with e2 subscriptions.
3313 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3314 params2.SetSubscriptionID(&restSubId)
3315
3316 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003317 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003318 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3319 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3320
Markku Virtanen2b512b62021-07-30 12:04:00 +00003321 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3322 assert.Equal(t, e2SubsId, e2SubsId1)
3323 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3324 xappConn1.DecrementRequestCount()
3325
Markku Virtanen42723e22021-06-15 10:09:23 +03003326 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3327
3328 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3329 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3330 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3331 assert.NotEqual(t, e2SubsId2, 0)
3332
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003333 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003334
3335 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3336 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003337 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003338 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3339 // md5sum shall find the original request
3340 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3341 assert.Equal(t, restSubId_resend, restSubId_resend2)
3342
Markku Virtanen2b512b62021-07-30 12:04:00 +00003343 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3344 assert.Equal(t, e2SubsId, e2SubsId1)
3345
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003346 mainCtrl.WaitOngoingRequestMapEmpty()
3347
Markku Virtanen42723e22021-06-15 10:09:23 +03003348 // Delete both e2 subscriptions
3349 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3350 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3351 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3352
3353 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003354 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003355 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003356}
3357
3358//-----------------------------------------------------------------------------
3359// stub stub stub
3360// +-------+ +---------+ +---------+ +---------+
3361// | xapp | | submgr | | e2term | | rtmgr |
3362// +-------+ +---------+ +---------+ +---------+
3363// | | | |
3364// | RESTSubReq | | |
3365// |---------------->| | |
3366// | RESTSubResp | | |
3367// |<----------------| | |
3368// | | RouteCreate | |
3369// | |--------------------------->|
3370// | | RouteResponse| |
3371// | |<---------------------------|
3372// | | SubReq | |
3373// | |------------->| |
3374// | | SubResp | |
3375// | |<-------------| |
3376// | RESTNotif1 | | |
3377// |<----------------| | |
3378// | RESTSubReq | | |
3379// | [with RestSUbsId + one additional e2 subDetail]
3380// |---------------->| | |
3381// | RESTNotif1 | | |
3382// | [for initial e2 subDetail] | |
3383// |<----------------| | |
3384// | | RouteCreate | |
3385// | |--------------------------->|
3386// | | RouteResponse| |
3387// | |<---------------------------|
3388// | | SubReq | |
3389// | |------------->| |
3390// | | SubResp | |
3391// | |<-------------| |
3392// | RESTNotif1 | | |
3393// |<----------------| | |
3394// | RESTSubDelReq | | |
3395// |---------------->| | |
3396// | RESTSubDelResp| | |
3397// |<----------------| | |
3398// | | SubDelReq | |
3399// | |------------->| |
3400// | | SubDelResp | |
3401// | |<-------------| |
3402// | | SubDelReq | |
3403// | |------------->| |
3404// | | SubDelResp | |
3405// | |<-------------| |
3406// | RESTSubReq | | |
3407// | [with RESTsubsId initial request] |
3408// |---------------->| | |
3409// | RESTSubResp | | |
3410// |<----------------| | |
3411// | | RouteCreate | |
3412// | |--------------------------->|
3413// | | RouteResponse| |
3414// | |<---------------------------|
3415// | | SubReq | |
3416// | |------------->| |
3417// | | SubResp | |
3418// | |<-------------| |
3419// | RESTNotif1 | | |
3420// |<----------------| | |
3421// | | | |
3422//
3423//-----------------------------------------------------------------------------
3424func TestRESTSubReqRetransmissionV6(t *testing.T) {
3425 CaseBegin("TestRESTSubReqRetransmissionV6")
3426
3427 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3428 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003429 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003430 Counter{cRestSubRespToXapp, 3},
3431 Counter{cSubReqToE2, 3},
3432 Counter{cSubRespFromE2, 3},
3433 Counter{cRestSubNotifToXapp, 4},
3434 Counter{cRestSubDelReqFromXapp, 2},
3435 Counter{cSubDelReqToE2, 3},
3436 Counter{cSubDelRespFromE2, 3},
3437 Counter{cRestSubDelRespToXapp, 2},
3438 })
3439
3440 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3441
3442 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3443
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003444 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003445
3446 // Send modified requst, this time with e2 subscriptions.
3447 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3448 params2.SetSubscriptionID(&restSubId)
3449
3450 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003451 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003452 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3453 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3454
Markku Virtanen2b512b62021-07-30 12:04:00 +00003455 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3456 assert.Equal(t, e2SubsId, e2SubsId1)
3457
Markku Virtanen42723e22021-06-15 10:09:23 +03003458 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3459
3460 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3461 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3462 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3463 assert.NotEqual(t, e2SubsId2, 0)
3464
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003465 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003466
3467 // Delete both e2 subscriptions
3468 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3469 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3470 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3471
3472 waitSubsCleanup(t, e2SubsId, 10)
3473
3474 // Resend the original request, we shall find it's previous md5sum/restsubs
3475 // but the restsubscription has been already removed. This shall trigger a
3476 // fresh create.
3477 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3478
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003479 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003480
3481 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3482
3483 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003484 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003485 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003486}
3487
archaggeafbf95f2021-04-14 08:54:05 +03003488func TestRESTSubDelReqRetransmission(t *testing.T) {
3489 CaseBegin("TestRESTSubDelReqRetransmission")
3490
3491 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003492 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003493 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003494 Counter{cSubReqToE2, 1},
3495 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003496 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003497 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003498 Counter{cSubDelReqToE2, 1},
3499 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003500 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003501 })
3502
3503 var params *teststube2ap.RESTSubsReqParams = nil
3504
3505 //Subs Create
3506 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3507
3508 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3509
3510 //Subs Delete
3511 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3512 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3513
3514 seqBef := mainCtrl.get_msgcounter(t)
3515 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3516 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3517
3518 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3519
3520 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003521 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003522 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003523}
3524
3525//-----------------------------------------------------------------------------
3526// TestRESTSubReqDelReq
3527//
3528// stub stub
3529// +-------+ +---------+ +---------+
3530// | xapp | | submgr | | e2term |
3531// +-------+ +---------+ +---------+
3532// | | |
3533// | RESTSubReq | |
3534// |---------------->| |
3535// | | |
3536// | RESTSubResp | |
3537// |<----------------| |
3538// | | SubReq |
3539// | |------------->|
3540// | RESTSubDelReq | |
3541// |---------------->| |
3542// | RESTSubDelResp | |
3543// | unsuccess | |
3544// |<----------------| |
3545// | | SubResp |
3546// | |<-------------|
3547// | RESTNotif1 | |
3548// |<----------------| |
3549// | | |
3550// | [SUBS DELETE] |
3551// | | |
3552//
3553//-----------------------------------------------------------------------------
3554func TestRESTSubReqDelReq(t *testing.T) {
3555 CaseBegin("TestRESTSubReqDelReq")
3556
3557 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003558 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003559 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003560 Counter{cSubReqToE2, 1},
3561 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003562 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003563 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003564 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003565 Counter{cSubDelReqToE2, 1},
3566 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003567 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003568 })
3569
3570 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003571
3572 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003573 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003574 restSubId := xappConn1.SendRESTSubsReq(t, params)
3575
3576 // Del. This will fail as processing of the subscription
3577 // is still ongoing in submgr. Deletion is not allowed before
3578 // subscription creation has been completed.
3579 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3580 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3581 xappConn1.ExpectRESTNotification(t, restSubId)
3582 e2termConn1.SendSubsResp(t, crereq, cremsg)
3583 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3584
3585 // Retry del
3586 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3587
3588 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3589 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3590
3591 // Wait that subs is cleaned
3592 waitSubsCleanup(t, e2SubsId, 10)
3593 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003594 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003595}
3596
3597func TestRESTSubDelReqCollision(t *testing.T) {
3598 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3599}
3600
3601func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3602 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3603
3604 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003605 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003606 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003607 Counter{cSubReqToE2, 2},
3608 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003609 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003610 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003611 Counter{cSubDelReqToE2, 2},
3612 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003613 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003614 })
3615
3616 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003617 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003618 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003619 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003620
3621 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003622 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003623 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003624 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003625
3626 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3627 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3628
3629 //XappConn1 receives both of the responses
3630 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3631
3632 //Resp1
3633 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3634 //Resp2
3635 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3636
3637 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003638 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003639 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003640 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003641
3642 //Del1
3643 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3644 //Del2
3645 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3646
3647 //Wait that subs is cleaned
3648 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3649 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3650
3651 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003652 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003653}
3654
3655func TestRESTSameSubsDiffRan(t *testing.T) {
3656 CaseBegin("TestRESTSameSubsDiffRan")
3657
3658 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003659 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003660 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003661 Counter{cSubReqToE2, 2},
3662 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003663 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003664 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003665 Counter{cSubDelReqToE2, 2},
3666 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003667 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003668 })
3669
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003670 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003671 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003672 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003673
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003674 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003675 params.SetMeid("RAN_NAME_2")
3676 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003677 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003678
3679 //Del1
3680 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3681 //Del2
3682 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3683
3684 //Wait that subs is cleaned
3685 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3686 waitSubsCleanup(t, e2SubsId2, 10)
3687
3688 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003689 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003690}
3691
3692func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3693 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3694
3695 // Init counter check
3696 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003697 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003698 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003699 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003700 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003701 Counter{cSubReReqToE2, 1},
3702 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003703 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003704 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003705 Counter{cSubDelReqToE2, 1},
3706 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003707 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003708 })
3709
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003710 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003711 restSubId := xappConn1.SendRESTSubsReq(t, params)
3712
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003713 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003714
3715 // Catch the first message and ignore it
3716 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003717 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003718
3719 // The second request is being handled normally
3720 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3721 xappConn1.ExpectRESTNotification(t, restSubId)
3722 e2termConn1.SendSubsResp(t, crereq, cremsg)
3723 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3724
3725 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3726
3727 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3728
3729 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3730 //Wait that subs is cleaned
3731 waitSubsCleanup(t, e2SubsId, 10)
3732
3733 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003734 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003735}
3736
3737//-----------------------------------------------------------------------------
3738// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3739//
3740// stub stub
3741// +-------+ +---------+ +---------+
3742// | xapp | | submgr | | e2term |
3743// +-------+ +---------+ +---------+
3744// | | |
3745// | RESTSubReq | |
3746// |---------------->| |
3747// | | |
3748// | RESTSubResp | |
3749// |<----------------| |
3750// | | SubReq |
3751// | |------------->|
3752// | | |
3753// | | |
3754// | | SubReq |
3755// | |------------->|
3756// | | |
3757// | | SubDelReq |
3758// | |------------->|
3759// | | |
3760// | | |
3761// | | SubDelReq |
3762// | |------------->|
3763// | | |
3764// | | |
3765// | | SubDelResp |
3766// | |<-------------|
3767// | RESTNotif | |
3768// | unsuccess | |
3769// |<----------------| |
3770// | | |
3771// | [SUBS DELETE] |
3772// | | |
3773//
3774//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003775
archaggeafbf95f2021-04-14 08:54:05 +03003776func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3777 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3778
3779 // Init counter check
3780 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003781 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003782 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003783 Counter{cSubReqToE2, 1},
3784 Counter{cSubReReqToE2, 1},
3785 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003786 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003787 Counter{cSubDelReqToE2, 1},
3788 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003789 Counter{cRestSubDelReqFromXapp, 1},
3790 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003791 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003792
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003793 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003794 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003795 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003796
3797 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003798 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003799
3800 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003801 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003802
3803 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003804 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003805 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003806 xappConn1.WaitRESTNotification(t, restSubId)
3807
Anssi Mannilab43397e2021-11-16 12:06:16 +02003808 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3809
archaggeafbf95f2021-04-14 08:54:05 +03003810 // Wait that subs is cleaned
3811 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003812 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003813 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003814}
3815
3816func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3817 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3818
3819 // Init counter check
3820 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003821 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003822 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003823 Counter{cSubReqToE2, 1},
3824 Counter{cSubReReqToE2, 1},
3825 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003826 Counter{cSubDelReReqToE2, 1},
3827 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003828 Counter{cSubDelReqToE2, 1},
3829 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003830 Counter{cRestSubDelReqFromXapp, 1},
3831 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003832 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003833
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003834 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003835 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003836 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003837
3838 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003839 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003840
3841 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003842 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003843
3844 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003845 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003846
Markku Virtanen55d2a282021-06-04 14:46:56 +03003847 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003848 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003849 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003850
3851 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3852
Anssi Mannilab43397e2021-11-16 12:06:16 +02003853 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003854
Anssi Mannilab43397e2021-11-16 12:06:16 +02003855 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003856 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003857 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003858}
3859
3860//-----------------------------------------------------------------------------
3861// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3862//
3863// stub stub
3864// +-------+ +---------+ +---------+
3865// | xapp | | submgr | | e2term |
3866// +-------+ +---------+ +---------+
3867// | | |
3868// | RESTSubReq | |
3869// |---------------->| |
3870// | | |
3871// | RESTSubResp | |
3872// |<----------------| |
3873// | | SubReq |
3874// | |------------->|
3875// | | |
3876// | | |
3877// | | SubReq |
3878// | |------------->|
3879// | | |
3880// | | SubDelReq |
3881// | |------------->|
3882// | | |
3883// | | |
3884// | | SubDelReq |
3885// | |------------->|
3886// | | |
3887// | | |
3888// | | SubDelResp |
3889// | |<-------------|
3890// | RESTNotif | |
3891// | unsuccess | |
3892// |<----------------| |
3893// | | |
3894// | [SUBS DELETE] |
3895// | | |
3896//
3897//-----------------------------------------------------------------------------
3898func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3899 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3900
3901 // Init counter check
3902 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003903 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003904 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003905 Counter{cSubReqToE2, 1},
3906 Counter{cSubReReqToE2, 1},
3907 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003908 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003909 Counter{cSubDelReqToE2, 1},
3910 Counter{cSubDelReReqToE2, 1},
3911 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003912 Counter{cRestSubDelReqFromXapp, 1},
3913 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003914 })
3915
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003916 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003917 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003918 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003919
3920 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003921 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003922
3923 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003924 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003925
3926 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003927 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003928
Markku Virtanen55d2a282021-06-04 14:46:56 +03003929 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003930 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003931 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003932
3933 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3934
Anssi Mannilab43397e2021-11-16 12:06:16 +02003935 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003936
Anssi Mannilab43397e2021-11-16 12:06:16 +02003937 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003938 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003939 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003940}
3941
3942//-----------------------------------------------------------------------------
3943// TestRESTSubReqSubFailRespInSubmgr
3944//
3945// stub stub
3946// +-------+ +---------+ +---------+
3947// | xapp | | submgr | | e2term |
3948// +-------+ +---------+ +---------+
3949// | | |
3950// | RESTSubReq | |
3951// |---------------->| |
3952// | | |
3953// | RESTSubResp | |
3954// |<----------------| |
3955// | | SubReq |
3956// | |------------->|
3957// | | |
3958// | | SubFail |
3959// | |<-------------|
3960// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003961// | RESTNotif | |
3962// | unsuccess | |
3963// |<----------------| |
3964// | | |
3965// | [SUBS DELETE] |
3966// | | |
3967//
3968//-----------------------------------------------------------------------------
3969func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3970 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3971
3972 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003973 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003974 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003975 Counter{cSubReqToE2, 1},
3976 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003977 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003978 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003979 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003980 })
3981
3982 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003983 const e2Timeout int64 = 2
3984 const e2RetryCount int64 = 1
3985 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003986
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003987 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003988 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003989 restSubId := xappConn1.SendRESTSubsReq(t, params)
3990
3991 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3992 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3993 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003994 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003995 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3996
archaggeafbf95f2021-04-14 08:54:05 +03003997 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003998 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003999
4000 // REST subscription sill there to be deleted
4001 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4002
4003 // Wait that subs is cleaned
4004 waitSubsCleanup(t, e2SubsId, 10)
4005
4006 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004007 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004008}
4009
4010//-----------------------------------------------------------------------------
4011// TestRESTSubDelReqRetryInSubmgr
4012//
4013// stub stub
4014// +-------+ +---------+ +---------+
4015// | xapp | | submgr | | e2term |
4016// +-------+ +---------+ +---------+
4017// | | |
4018// | [SUBS CREATE] |
4019// | | |
4020// | | |
4021// | RESTSubDelReq | |
4022// |---------------->| |
4023// | | |
4024// | RESTSubDelResp | |
4025// |<----------------| |
4026// | | SubDelReq |
4027// | |------------->|
4028// | | |
4029// | | SubDelReq |
4030// | |------------->|
4031// | | |
4032// | | SubDelResp |
4033// | |<-------------|
4034// | | |
4035//
4036//-----------------------------------------------------------------------------
4037func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4038 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4039
4040 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004041 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004042 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004043 Counter{cSubReqToE2, 1},
4044 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004045 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004046 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004047 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004048 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004049 Counter{cSubDelReReqToE2, 1},
4050 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004051 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004052 })
4053 // Req
4054 var params *teststube2ap.RESTSubsReqParams = nil
4055 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4056
4057 // Del
4058 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4059
4060 // E2t: Receive 1st SubsDelReq
4061 e2termConn1.RecvSubsDelReq(t)
4062
4063 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4064 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4065 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4066
4067 //Wait that subs is cleaned
4068 waitSubsCleanup(t, e2SubsId, 10)
4069
4070 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004071 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004072}
4073
4074//-----------------------------------------------------------------------------
4075// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4076//
4077// stub stub
4078// +-------+ +---------+ +---------+
4079// | xapp | | submgr | | e2term |
4080// +-------+ +---------+ +---------+
4081// | | |
4082// | [SUBS CREATE] |
4083// | | |
4084// | | |
4085// | RESTSubDelReq | |
4086// |---------------->| |
4087// | | |
4088// | RESTSubDelResp | |
4089// |<----------------| |
4090// | | SubDelReq |
4091// | |------------->|
4092// | | |
4093// | | SubDelReq |
4094// | |------------->|
4095// | | |
4096// | | |
4097//
4098//-----------------------------------------------------------------------------
4099func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4100 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4101
4102 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004103 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004104 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004105 Counter{cSubReqToE2, 1},
4106 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004107 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004108 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004109 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004110 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004111 Counter{cSubDelReReqToE2, 1},
4112 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004113 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004114 })
4115
4116 // Req
4117 var params *teststube2ap.RESTSubsReqParams = nil
4118 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4119
4120 // Del
4121 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4122
4123 // E2t: Receive 1st SubsDelReq
4124 e2termConn1.RecvSubsDelReq(t)
4125
4126 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4127 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4128 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4129
4130 //Wait that subs is cleaned
4131 waitSubsCleanup(t, e2SubsId, 10)
4132
4133 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004134 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004135}
4136
4137//-----------------------------------------------------------------------------
4138// TestRESTSubDelReqSubDelFailRespInSubmgr
4139//
4140// stub stub
4141// +-------+ +---------+ +---------+
4142// | xapp | | submgr | | e2term |
4143// +-------+ +---------+ +---------+
4144// | | |
4145// | [SUBS CREATE] |
4146// | | |
4147// | | |
4148// | RESTSubDelReq | |
4149// |---------------->| |
4150// | | |
4151// | RESTSubDelResp | |
4152// |<----------------| |
4153// | | SubDelReq |
4154// | |------------->|
4155// | | |
4156// | | SubDelFail |
4157// | |<-------------|
4158// | | |
4159//
4160//-----------------------------------------------------------------------------
4161func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4162 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4163
4164 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004165 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004166 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004167 Counter{cSubReqToE2, 1},
4168 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004169 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004170 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004171 Counter{cSubDelReqToE2, 1},
4172 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004173 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004174 })
4175
4176 // Req
4177 var params *teststube2ap.RESTSubsReqParams = nil
4178 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4179
4180 // Del
4181 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4182
4183 // E2t: Send receive SubsDelReq and send SubsDelFail
4184 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4185 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4186
4187 //Wait that subs is cleaned
4188 waitSubsCleanup(t, e2SubsId, 10)
4189
4190 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004191 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004192}
4193
4194//-----------------------------------------------------------------------------
4195// TestRESTSubReqAndSubDelOkSameAction
4196//
4197// stub stub
4198// +-------+ +-------+ +---------+ +---------+
4199// | xapp2 | | xapp1 | | submgr | | e2term |
4200// +-------+ +-------+ +---------+ +---------+
4201// | | | |
4202// | | RESTSubReq1 | |
4203// | |---------------->| |
4204// | | | |
4205// | | RESTSubResp1 | |
4206// | |<----------------| |
4207// | | | |
4208// | | | SubReq1 |
4209// | | |------------->|
4210// | | | SubResp1 |
4211// | | |<-------------|
4212// | | RESTNotif1 | |
4213// | |<----------------| |
4214// | | | |
4215// | RESTSubReq2 | |
4216// |------------------------------>| |
4217// | | | |
4218// | RESTSubResp2 | |
4219// |<------------------------------| |
4220// | | | |
4221// | | RESTNotif2 | |
4222// |<------------------------------| |
4223// | | | |
4224// | | RESTSubDelReq1 | |
4225// | |---------------->| |
4226// | | | |
4227// | | RESTSubDelResp1 | |
4228// | |<----------------| |
4229// | | | |
4230// | RESTSubDelReq2 | |
4231// |------------------------------>| |
4232// | | | |
4233// | RESTSubDelResp2 | |
4234// |<------------------------------| |
4235// | | | |
4236// | | | SubDelReq2 |
4237// | | |------------->|
4238// | | | |
4239// | | | SubDelResp2 |
4240// | | |<-------------|
4241// | | | |
4242//
4243//-----------------------------------------------------------------------------
4244func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4245 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4246
4247 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004248 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004249 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004250 Counter{cSubReqToE2, 1},
4251 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004252 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004253 Counter{cMergedSubscriptions, 1},
4254 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004255 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004256 Counter{cSubDelReqToE2, 1},
4257 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004258 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004259 })
4260
4261 // Req1
4262 var params *teststube2ap.RESTSubsReqParams = nil
4263
4264 //Subs Create
4265 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4266 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4267
4268 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004269 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004270 params.SetMeid("RAN_NAME_1")
4271
4272 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004273 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004274 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004275 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004276 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004277 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004278 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004279 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004280
4281 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4282
4283 // Del1
4284 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4285
4286 // Del2
4287 deleteXapp2Subscription(t, &restSubId2)
4288
4289 //Wait that subs is cleaned
4290 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004291 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004292 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004293}
4294
4295//-----------------------------------------------------------------------------
4296// TestSubReqAndSubDelOkSameActionParallel
4297//
4298// stub stub stub
4299// +-------+ +-------+ +---------+ +---------+
4300// | xapp2 | | xapp1 | | submgr | | e2term |
4301// +-------+ +-------+ +---------+ +---------+
4302// | | | |
4303// | | | |
4304// | | | |
4305// | | SubReq1 | |
4306// | |------------->| |
4307// | | | |
4308// | | | SubReq1 |
4309// | | |------------->|
4310// | SubReq2 | |
4311// |--------------------------->| |
4312// | | | SubResp1 |
4313// | | |<-------------|
4314// | | SubResp1 | |
4315// | |<-------------| |
4316// | | | SubReq2 |
4317// | | |------------->|
4318// | | | |
4319// | | | SubResp2 |
4320// | | |<-------------|
4321// | SubResp2 | |
4322// |<---------------------------| |
4323// | | | |
4324// | | SubDelReq 1 | |
4325// | |------------->| |
4326// | | | |
4327// | | SubDelResp 1 | |
4328// | |<-------------| |
4329// | | | |
4330// | SubDelReq 2 | |
4331// |--------------------------->| |
4332// | | | |
4333// | | | SubDelReq 2 |
4334// | | |------------->|
4335// | | | |
4336// | | | SubDelReq 2 |
4337// | | |------------->|
4338// | | | |
4339// | SubDelResp 2 | |
4340// |<---------------------------| |
4341//
4342func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4343 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4344
4345 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004346 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004347 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004348 Counter{cSubReqToE2, 2},
4349 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004350 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004351 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004352 Counter{cSubDelReqToE2, 2},
4353 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004354 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004355 })
4356
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004357 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004358 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4359 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4360
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004361 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004362 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4363
4364 xappConn1.ExpectRESTNotification(t, restSubId1)
4365 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4366 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4367
4368 xappConn2.ExpectRESTNotification(t, restSubId2)
4369 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4370 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4371 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4372
4373 // Del1
4374 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4375 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4376 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4377 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4378
4379 // Del2
4380 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4381 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4382 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4383
4384 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004385 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004386 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004387}
4388
4389//-----------------------------------------------------------------------------
4390// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4391//
4392// stub stub stub
4393// +-------+ +-------+ +---------+ +---------+
4394// | xapp2 | | xapp1 | | submgr | | e2term |
4395// +-------+ +-------+ +---------+ +---------+
4396// | | | |
4397// | | | |
4398// | | | |
4399// | | RESTSubReq1 | |
4400// | |---------------->| |
4401// | | | |
4402// | | RESTSubResp1 | |
4403// | |<----------------| |
4404// | | | SubReq1 |
4405// | | |------------->|
4406// | RESTSubReq2 | |
4407// |------------------------------>| |
4408// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004409// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004410// |<------------------------------| |
4411// | | | SubReq1 |
4412// | | |------------->|
4413// | | | |
4414// | | | |
4415// | | | SubDelReq |
4416// | | |------------->|
4417// | | | |
4418// | | | SubDelResp |
4419// | | |<-------------|
4420// | | RESTNotif1 | |
4421// | | unsuccess | |
4422// | |<----------------| |
4423// | RESTNotif2 | |
4424// | | unsuccess | |
4425// |<------------------------------| |
4426// | | | |
4427// | | RESTSubDelReq1 | |
4428// | |---------------->| |
4429// | | | |
4430// | | RESTSubDelResp1 | |
4431// | |<----------------| |
4432// | | | |
4433// | RESTSubDelReq2 | |
4434// |------------------------------>| |
4435// | | | |
4436// | RESTSubDelResp2 | |
4437// |<------------------------------| |
4438//
4439//-----------------------------------------------------------------------------
4440func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4441 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4442
4443 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004444 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004445 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004446 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004447 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004448 Counter{cSubReqTimerExpiry, 2},
4449 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004450 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004451 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004452 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004453 Counter{cSubDelReqToE2, 1},
4454 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004455 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004456 })
archaggeafbf95f2021-04-14 08:54:05 +03004457 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004458
4459 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004460 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004461 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4462 crereq1, _ := e2termConn1.RecvSubsReq(t)
4463
4464 // Req2
4465 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004466 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004467 params2.SetMeid("RAN_NAME_1")
4468 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4469 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4470
4471 //Req1 (retransmitted)
4472 e2termConn1.RecvSubsReq(t)
4473
4474 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004475
4476 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004477 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4478
Markku Virtanenda34eec2021-05-20 08:22:04 +00004479 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004480 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004481 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004482 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004483
4484 // Del1
4485 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4486
4487 // Del2
4488 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4489
Markku Virtanenda34eec2021-05-20 08:22:04 +00004490 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4491
archaggeafbf95f2021-04-14 08:54:05 +03004492 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004493 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004494 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004495 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004496}
4497
4498//-----------------------------------------------------------------------------
4499// TestRESTSubReqAndSubDelNokSameActionParallel
4500//
4501// stub stub stub
4502// +-------+ +-------+ +---------+ +---------+
4503// | xapp2 | | xapp1 | | submgr | | e2term |
4504// +-------+ +-------+ +---------+ +---------+
4505// | | | |
4506// | | | |
4507// | | | |
4508// | | RESTSubReq1 | |
4509// | |---------------->| |
4510// | | | |
4511// | | RESTSubResp1 | |
4512// | |<----------------| |
4513// | | | SubReq1 |
4514// | | |------------->|
4515// | RESTSubReq2 | |
4516// |------------------------------>| |
4517// | | | |
4518// | RESTSubDelResp2 | |
4519// |<------------------------------| |
4520// | | | SubFail1 |
4521// | | |<-------------|
4522// | | | |
4523// | | RESTNotif1 | |
4524// | | unsuccess | |
4525// | |<----------------| |
4526// | RESTNotif2 | |
4527// | | unsuccess | |
4528// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004529// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004530// | | 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 +03004531// | |---------------->| |
4532// | | | |
4533// | | RESTSubDelResp1 | |
4534// | |<----------------| |
4535// | | | |
4536// | RESTSubDelReq2 | |
4537// |------------------------------>| |
4538// | | | |
4539// | RESTSubDelResp2 | |
4540// |<------------------------------| |
4541//
4542//-----------------------------------------------------------------------------
4543func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4544 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4545
4546 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004547 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004548 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004549 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004550 Counter{cSubReqToE2, 1},
4551 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004552 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004553 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004554 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004555 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004556 })
4557
4558 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004559
4560 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004561 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004562 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4563 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4564
4565 // Req2
4566 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004567 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004568 params2.SetMeid("RAN_NAME_1")
4569 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4570 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4571
4572 // E2t: send SubsFail (first)
4573 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4574 fparams1.Set(crereq1)
4575 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4576
archaggeafbf95f2021-04-14 08:54:05 +03004577 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004578 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004579 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004580 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004581 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004582
4583 // Del1
4584 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4585
4586 // Del2
4587 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4588
4589 //Wait that subs is cleaned
4590 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4591 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004592 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004593 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004594}
Anssi Mannila54838ed2021-11-19 11:25:01 +02004595
archaggeafbf95f2021-04-14 08:54:05 +03004596func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4597 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4598
4599 // Init counter check
4600 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004601 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004602 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004603 Counter{cSubReqToE2, 1},
4604 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004605 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004606 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004607 Counter{cSubDelReqToE2, 1},
4608 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004609 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004610 })
4611
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004612 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004613 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004614 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004615
4616 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4617 xappConn1.ExpectRESTNotification(t, restSubId)
4618 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4619 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004620 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004621
4622 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4623 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4624 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4625
4626 // Wait that subs is cleaned
4627 waitSubsCleanup(t, e2SubsId, 10)
4628 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004629 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004630}
4631
4632//-----------------------------------------------------------------------------
4633// TestRESTSubReqPolicyChangeAndSubDelOk
4634//
4635// stub stub
4636// +-------+ +---------+ +---------+
4637// | xapp | | submgr | | e2term |
4638// +-------+ +---------+ +---------+
4639// | | |
4640// | RESTSubReq | |
4641// |---------------->| |
4642// | | |
4643// | RESTSubResp | |
4644// |<----------------| |
4645// | | SubReq |
4646// | |------------->|
4647// | | |
4648// | | SubResp |
4649// | |<-------------|
4650// | | |
4651// | RESTNotif | |
4652// |<----------------| |
4653// | | |
4654// | RESTSubReq | |
4655// |---------------->| |
4656// | | |
4657// | RESTSubResp | |
4658// |<----------------| |
4659// | | SubReq |
4660// | |------------->|
4661// | | |
4662// | | SubResp |
4663// | |<-------------|
4664// | | |
4665// | RESTNotif | |
4666// |<----------------| |
4667// | | |
4668// | RESTSubDelReq | |
4669// |---------------->| |
4670// | | |
4671// | | SubDelReq |
4672// | |------------->|
4673// | | |
4674// | | SubDelResp |
4675// | |<-------------|
4676// | | |
4677// | RESTSubDelResp | |
4678// |<----------------| |
4679//
4680//-----------------------------------------------------------------------------
4681func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4682 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4683
4684 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004685 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004686 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004687 Counter{cSubReqToE2, 2},
4688 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004689 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004690 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004691 Counter{cSubDelReqToE2, 1},
4692 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004693 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004694 })
4695
4696 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004697 const e2Timeout int64 = 1
4698 const e2RetryCount int64 = 0
4699 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004700
4701 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004702 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004703 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004704 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4705
4706 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004707 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004708
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004709 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004710 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004711 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004712 params.SetTimeToWait("w200ms")
4713 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4714
4715 // Del
4716 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4717
4718 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4719 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4720
4721 // Wait that subs is cleaned
4722 waitSubsCleanup(t, e2SubsId, 10)
4723 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004724 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004725}
4726
4727//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004728// TestRESTSubReqPolicyChangeNOk
4729//
4730// stub stub
4731// +-------+ +---------+ +---------+
4732// | xapp | | submgr | | e2term |
4733// +-------+ +---------+ +---------+
4734// | | |
4735// | RESTSubReq | |
4736// |---------------->| |
4737// | | |
4738// | RESTSubResp | |
4739// |<----------------| |
4740// | | SubReq |
4741// | |------------->|
4742// | | |
4743// | | SubResp |
4744// | |<-------------|
4745// | | |
4746// | RESTNotif | |
4747// |<----------------| |
4748// | | |
4749// | RESTSubReq | |
4750// |---------------->| |
4751// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004752// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004753// | | |
4754// | RESTSubDelReq | |
4755// |---------------->| |
4756// | | |
4757// | | SubDelReq |
4758// | |------------->|
4759// | | |
4760// | | SubDelResp |
4761// | |<-------------|
4762// | | |
4763// | RESTSubDelResp | |
4764// |<----------------| |
4765//
4766//-----------------------------------------------------------------------------
4767func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4768 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4769
4770 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4771 Counter{cRestSubReqFromXapp, 2},
4772 Counter{cRestSubRespToXapp, 1},
4773 Counter{cSubReqToE2, 1},
4774 Counter{cSubRespFromE2, 1},
4775 Counter{cRestSubNotifToXapp, 1},
4776 Counter{cRestSubFailToXapp, 1},
4777 Counter{cRestSubDelReqFromXapp, 1},
4778 Counter{cSubDelReqToE2, 1},
4779 Counter{cSubDelRespFromE2, 1},
4780 Counter{cRestSubDelRespToXapp, 1},
4781 })
4782
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004783 // Req
4784 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4785 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4786
4787 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004788 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4789
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004790 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004791 params.SetSubscriptionID(&restSubIdUpd)
4792 params.SetTimeToWait("w200ms")
4793
4794 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4795 assert.Equal(t, restSubId2, "")
4796
4797 // Del
4798 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4799
4800 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4801 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4802
4803 // Wait that subs is cleaned
4804 waitSubsCleanup(t, e2SubsId, 10)
4805 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004806 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004807}
4808
4809//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004810// TestRESTSubReqAndSubDelOkTwoE2termParallel
4811//
4812// stub stub stub
4813// +-------+ +---------+ +---------+ +---------+
4814// | xapp | | submgr | | e2term1 | | e2term2 |
4815// +-------+ +---------+ +---------+ +---------+
4816// | | | |
4817// | | | |
4818// | | | |
4819// | RESTSubReq1 | | |
4820// |---------------->| | |
4821// | | | |
4822// | RESTSubResp1 | | |
4823// |<----------------| | |
4824// | | SubReq1 | |
4825// | |------------->| |
4826// | | | |
4827// | RESTSubReq2 | | |
4828// |---------------->| | |
4829// | | | |
4830// | RESTSubResp2 | | |
4831// |<----------------| | |
4832// | | SubReq2 | |
4833// | |---------------------------->|
4834// | | | |
4835// | | SubResp1 | |
4836// | |<-------------| |
4837// | RESTNotif1 | | |
4838// |<----------------| | |
4839// | | SubResp2 | |
4840// | |<----------------------------|
4841// | RESTNotif2 | | |
4842// |<----------------| | |
4843// | | | |
4844// | [SUBS 1 DELETE] | |
4845// | | | |
4846// | [SUBS 2 DELETE] | |
4847// | | | |
4848//
4849//-----------------------------------------------------------------------------
4850func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4851 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4852
4853 // Init counter check
4854 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004855 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004856 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004857 Counter{cSubReqToE2, 2},
4858 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004859 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004860 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004861 Counter{cSubDelReqToE2, 2},
4862 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004863 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004864 })
4865
4866 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004867
4868 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004869 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004870 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4871 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4872
4873 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004874 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004875 params.SetMeid("RAN_NAME_11")
4876 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4877 // would not work as notification would not be received
4878 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4879 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4880
4881 // Resp1
4882 xappConn1.ExpectRESTNotification(t, restSubId1)
4883 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4884 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004885 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004886
4887 // Resp2
4888 xappConn2.ExpectRESTNotification(t, restSubId2)
4889 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4890 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004891 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004892
4893 // Delete1
4894 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4895 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4896 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4897
4898 // Wait that subs is cleaned
4899 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4900
4901 // Delete2
4902 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4903 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4904 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4905
4906 // Wait that subs is cleaned
4907 waitSubsCleanup(t, e2SubsId2, 10)
4908
4909 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004910 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004911}
4912
4913//-----------------------------------------------------------------------------
4914// TestRESTSubReqAsn1EncodeFail
4915//
4916// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4917// stub stub
4918// +-------+ +---------+ +---------+
4919// | xapp | | submgr | | e2term |
4920// +-------+ +---------+ +---------+
4921// | | |
4922// | RESTSubReq | |
4923// |---------------->| |
4924// | | |
4925// | RESTSubResp | |
4926// |<----------------| |
4927// | RESTSubDelReq | |
4928// |---------------->| |
4929// | RESTSubDelResp | |
4930// | unsuccess | |
4931// |<----------------| |
4932// | | |
4933//
4934//-----------------------------------------------------------------------------
4935func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4936 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4937
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004938 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004939
4940}
4941
4942//-----------------------------------------------------------------------------
4943// TestRESTSubReqInsertAndSubDelOk
4944//
4945// stub stub
4946// +-------+ +---------+ +---------+
4947// | xapp | | submgr | | e2term |
4948// +-------+ +---------+ +---------+
4949// | | |
4950// | RestSubReq | |
4951// |---------------->| |
4952// | | |
4953// | RESTSubResp | |
4954// |<----------------| |
4955// | | |
4956// | | SubReq |
4957// | |------------->|
4958// | | |
4959// | | SubResp |
4960// | |<-------------|
4961// | RESTNotif | |
4962// |<----------------| |
4963// | ... | ... |
4964// | | |
4965// | RESTSubDelReq | |
4966// |---------------->| |
4967// | | |
4968// | | SubDelReq |
4969// | |------------->|
4970// | | |
4971// | | SubDelResp |
4972// | |<-------------|
4973// | | |
4974// | RESTSubDelResp| |
4975// |<----------------| |
4976//
4977//-----------------------------------------------------------------------------
4978func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4979 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4980
4981 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004982 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004983 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004984 Counter{cSubReqToE2, 1},
4985 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004986 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004987 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004988 Counter{cSubDelReqToE2, 1},
4989 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004990 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004991 })
4992
4993 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004994
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004995 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004996 params.SetSubActionTypes("insert")
4997
4998 // Req
4999 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5000
5001 // Del
5002 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5003
5004 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5005 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5006
5007 // Wait that subs is cleaned
5008 waitSubsCleanup(t, e2SubsId, 10)
5009 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005010 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005011}
5012
5013//-----------------------------------------------------------------------------
5014// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5015//
5016// stub stub
5017// +-------+ +---------+ +---------+
5018// | xapp | | submgr | | e2term |
5019// +-------+ +---------+ +---------+
5020// | | |
5021// | RESTSubReq | |
5022// |------------->| |
5023// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005024// | RESTSubResp | |
5025// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005026// | | SubReq |
5027// | |------------->|
5028// | | |
5029// | | SubResp |
5030// | <----|
5031// | |
5032// | Submgr restart |
5033// | |
5034// | | |
5035// | | SubDelReq |
5036// | |------------->|
5037// | | |
5038// | | SubDelResp |
5039// | |<-------------|
5040// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005041// | RESTNotif | |
5042// | unsuccess | |
5043// |<-------------| |
5044// | | |
5045// | RESTSubDelReq| |
5046// |------------->| |
5047// | | |
5048// |RESTSubDelResp| |
5049// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005050//
5051//-----------------------------------------------------------------------------
5052func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5053 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5054
5055 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005056 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005057 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005058 Counter{cSubReqToE2, 1},
5059 Counter{cSubDelReqFromXapp, 1},
5060 Counter{cSubDelReqToE2, 1},
5061 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005062 Counter{cRestSubDelReqFromXapp, 1},
5063 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005064 })
5065
5066 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005067
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005068 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005069
5070 //Req
5071 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5072 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005073 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005074
5075 e2termConn1.RecvSubsReq(t)
5076
5077 mainCtrl.SetResetTestFlag(t, false)
5078
5079 mainCtrl.SimulateRestart(t)
5080 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5081
Anssi Mannilab43397e2021-11-16 12:06:16 +02005082 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005083 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5084 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5085
Anssi Mannilab43397e2021-11-16 12:06:16 +02005086 //Del
5087 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5088
archaggeafbf95f2021-04-14 08:54:05 +03005089 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005090 e2termConn1.TestMsgChanEmpty(t)
5091 mainCtrl.wait_registry_empty(t, 10)
5092
5093 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005094 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005095}
5096
5097//-----------------------------------------------------------------------------
5098// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5099//
5100// stub stub
5101// +-------+ +---------+ +---------+
5102// | xapp | | submgr | | e2term |
5103// +-------+ +---------+ +---------+
5104// | | |
5105// | RESTSubReq | |
5106// |---------------->| |
5107// | | |
5108// | RESTSubResp | |
5109// |<----------------| |
5110// | | SubReq |
5111// | |------------->|
5112// | | |
5113// | | SubResp |
5114// | |<-------------|
5115// | | |
5116// | RESTNotif | |
5117// |<----------------| |
5118// | | |
5119// | |
5120// | Submgr restart |
5121// | | |
5122// | RESTSubDelReq | |
5123// |---------------->| |
5124// | | |
5125// | | SubDelReq |
5126// | |------------->|
5127// | | |
5128// | | SubDelResp |
5129// | |<-------------|
5130// | | |
5131// | RESTSubDelResp | |
5132// |<----------------| |
5133//
5134//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005135
archaggeafbf95f2021-04-14 08:54:05 +03005136func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5137 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5138
5139 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005140 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005141 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005142 Counter{cSubReqToE2, 1},
5143 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005144 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005145 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005146 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005147 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005148 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005149 })
archaggeafbf95f2021-04-14 08:54:05 +03005150
5151 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005152 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005153 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005154 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005155
5156 // Check subscription
5157 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5158
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005159 mainCtrl.SimulateRestart(t)
5160 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005161
Anssi Mannila54838ed2021-11-19 11:25:01 +02005162 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5163 // That needs to be completed before successful subscription query is possible
5164 <-time.After(time.Second * 1)
5165
archaggeafbf95f2021-04-14 08:54:05 +03005166 // Check subscription
5167 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5168
5169 // Delete subscription
5170 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5171
5172 //Wait that subs is cleaned
5173 waitSubsCleanup(t, e2SubsId, 10)
5174
5175 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005176 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005177}
5178
5179//-----------------------------------------------------------------------------
5180// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5181//
5182// stub stub
5183// +-------+ +-------+ +---------+ +---------+
5184// | xapp2 | | xapp1 | | submgr | | e2term |
5185// +-------+ +-------+ +---------+ +---------+
5186// | | | |
5187// | | RESTSubReq1 | |
5188// | |---------------->| |
5189// | | | |
5190// | | RESTSubResp1 | |
5191// | |<----------------| |
5192// | | | |
5193// | | | SubReq1 |
5194// | | |------------->|
5195// | | | SubResp1 |
5196// | | |<-------------|
5197// | | RESTNotif1 | |
5198// | |<----------------| |
5199// | | | |
5200// | RESTSubReq2 | |
5201// |------------------------------>| |
5202// | | | |
5203// | RESTSubResp2 | |
5204// |<------------------------------| |
5205// | | | |
5206// | | RESTNotif2 | |
5207// |<------------------------------| |
5208// | | | |
5209// | | Submgr restart |
5210// | | | |
5211// | | RESTSubDelReq1 | |
5212// | |---------------->| |
5213// | | | |
5214// | | RESTSubDelResp1 | |
5215// | |<----------------| |
5216// | | | |
5217// | | Submgr restart |
5218// | | | |
5219// | RESTSubDelReq2 | |
5220// |------------------------------>| |
5221// | | | |
5222// | RESTSubDelResp2 | |
5223// |<------------------------------| |
5224// | | | |
5225// | | | SubDelReq2 |
5226// | | |------------->|
5227// | | | |
5228// | | | SubDelResp2 |
5229// | | |<-------------|
5230// | | | |
5231//
5232//-----------------------------------------------------------------------------
5233func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5234 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5235
5236 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005237 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005238 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005239 Counter{cSubReqToE2, 1},
5240 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005241 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005242 Counter{cMergedSubscriptions, 1},
5243 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005244 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005245 Counter{cSubDelReqToE2, 1},
5246 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005247 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005248 })
5249
archaggeafbf95f2021-04-14 08:54:05 +03005250 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005251 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005252 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005253 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005254
5255 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005256 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005257 params.SetMeid("RAN_NAME_1")
5258 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005259 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005260 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005261 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005262 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005263 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005264
5265 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5266
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005267 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005268 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5269
5270 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5271 // That needs to be completed before successful subscription delete is possible
5272 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005273
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005274 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03005275 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02005276 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005277 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02005278
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005279 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005280 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5281
5282 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5283 // That needs to be completed before successful subscription query is possible
5284 <-time.After(time.Second * 1)
5285
archaggeafbf95f2021-04-14 08:54:05 +03005286 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5287
5288 // Delete subscription 2
5289 deleteXapp2Subscription(t, &restSubId2)
5290
5291 //Wait that subs is cleaned
5292 waitSubsCleanup(t, e2SubsId2, 10)
5293
5294 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005295 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005296}
5297
5298//-----------------------------------------------------------------------------
5299// TestRESTReportSubReqAndSubDelOk
5300//
5301// stub stub
5302// +-------+ +---------+ +---------+
5303// | xapp | | submgr | | e2term |
5304// +-------+ +---------+ +---------+
5305// | | |
5306// | RestSubReq | |
5307// |---------------->| |
5308// | | |
5309// | RESTSubResp | |
5310// |<----------------| |
5311// | | |
5312// | | SubReq |
5313// | |------------->|
5314// | | |
5315// | | SubResp |
5316// | |<-------------|
5317// | RESTNotif | |
5318// |<----------------| |
5319// | | SubReq |
5320// | |------------->|
5321// | | |
5322// | | SubResp |
5323// | |<-------------|
5324// | RESTNotif | |
5325// |<----------------| |
5326// | ... | ... |
5327// | | |
5328// | | |
5329// | RESTSubDelReq | |
5330// |---------------->| |
5331// | | |
5332// | | SubDelReq |
5333// | |------------->|
5334// | | |
5335// | | SubDelResp |
5336// | |<-------------|
5337// | | |
5338// | RESTSubDelResp| |
5339// |<----------------| |
5340//
5341//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005342
archaggeafbf95f2021-04-14 08:54:05 +03005343func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5344 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005345 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005346 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005347 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005348}
5349
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005350func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005351 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005352
5353 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005354 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005355 restSubId := xappConn1.SendRESTSubsReq(t, params)
5356
5357 var e2SubsId []uint32
5358 for i := 0; i < subReqCount; i++ {
5359 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5360 xappConn1.ExpectRESTNotification(t, restSubId)
5361
5362 e2termConn1.SendSubsResp(t, crereq, cremsg)
5363 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005364 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005365 e2SubsId = append(e2SubsId, instanceId)
5366 resp, _ := xapp.Subscription.QuerySubscriptions()
5367 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5368 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5369 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5370
5371 }
5372
5373 // Del
5374 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5375
5376 for i := 0; i < subReqCount; i++ {
5377 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5378 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5379 }
5380
5381 // Wait that subs is cleaned
5382 for i := 0; i < subReqCount; i++ {
5383 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5384 }
5385
5386 xappConn1.TestMsgChanEmpty(t)
5387 e2termConn1.TestMsgChanEmpty(t)
5388 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005389 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005390}
5391
5392/*
Anssi Mannila54838ed2021-11-19 11:25:01 +02005393func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { was in comments already
archaggeafbf95f2021-04-14 08:54:05 +03005394 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5395
5396 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005397 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005398 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005399
5400 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005401 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005402 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005403}
5404*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005405func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005406 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005407
5408 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005409 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005410 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005411
5412 var e2SubsId []uint32
5413 for i := 0; i < subReqCount; i++ {
5414 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5415 xappConn1.ExpectRESTNotification(t, restSubId)
5416 e2termConn1.SendSubsResp(t, crereq, cremsg)
5417 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005418 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005419 e2SubsId = append(e2SubsId, instanceId)
5420 }
5421
5422 // Del
5423 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5424
5425 for i := 0; i < subReqCount; i++ {
5426 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5427 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5428 }
5429
5430 // Wait that subs is cleaned
5431 for i := 0; i < subReqCount; i++ {
5432 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5433 }
5434 xappConn1.TestMsgChanEmpty(t)
5435 e2termConn1.TestMsgChanEmpty(t)
5436 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005437 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005438}
5439
archaggeafbf95f2021-04-14 08:54:05 +03005440func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5441
archaggeafbf95f2021-04-14 08:54:05 +03005442 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005443 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005444 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005445 Counter{cSubReqToE2, 2},
5446 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005447 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005448 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005449 Counter{cSubDelReqToE2, 2},
5450 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005451 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005452 })
5453
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005454 const subReqCount int = 2
5455
archaggeafbf95f2021-04-14 08:54:05 +03005456 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005457 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005458 restSubId := xappConn1.SendRESTSubsReq(t, params)
5459 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5460
5461 assert.Equal(t, len(e2SubsIds), 2)
5462
5463 // Del
5464 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5465 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5466
5467 xappConn1.TestMsgChanEmpty(t)
5468 e2termConn1.TestMsgChanEmpty(t)
5469 mainCtrl.wait_registry_empty(t, 10)
5470
5471 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005472 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005473}
archaggeafbf95f2021-04-14 08:54:05 +03005474func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5475
archaggeafbf95f2021-04-14 08:54:05 +03005476 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005477 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005478 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005479 Counter{cSubReqToE2, 19},
5480 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005481 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005482 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005483 Counter{cSubDelReqToE2, 19},
5484 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005485 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005486 })
5487
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005488 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005489 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005490 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005491 restSubId := xappConn1.SendRESTSubsReq(t, params)
5492 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5493
5494 assert.Equal(t, len(e2SubsIds), 19)
5495
5496 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5497 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5498
5499 xappConn1.TestMsgChanEmpty(t)
5500 e2termConn1.TestMsgChanEmpty(t)
5501 mainCtrl.wait_registry_empty(t, 10)
5502
5503 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005504 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005505}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005506
archaggeafbf95f2021-04-14 08:54:05 +03005507func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5508
5509 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005510
5511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005512 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005513 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005514 Counter{cSubReqToE2, uint64(subReqCount)},
5515 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005516 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005517 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005518 Counter{cSubDelReqToE2, uint64(subReqCount)},
5519 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005520 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005521 })
5522
5523 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005524 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005525 restSubId := xappConn1.SendRESTSubsReq(t, params)
5526 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5527
5528 assert.Equal(t, len(e2SubsIds), subReqCount)
5529
5530 // Del
5531 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5532 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5533
5534 xappConn1.TestMsgChanEmpty(t)
5535 e2termConn1.TestMsgChanEmpty(t)
5536 mainCtrl.wait_registry_empty(t, 10)
5537
5538 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005539 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005540}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005541
archaggeafbf95f2021-04-14 08:54:05 +03005542func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5543
5544 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005545
5546 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005547 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005548 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005549 Counter{cSubReqToE2, uint64(subReqCount)},
5550 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005551 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005552 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005553 Counter{cSubDelReqToE2, uint64(subReqCount)},
5554 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005555 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005556 })
5557
5558 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005559 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005560 restSubId := xappConn1.SendRESTSubsReq(t, params)
5561 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5562
5563 assert.Equal(t, len(e2SubsIds), subReqCount)
5564
5565 // Del
5566 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5567 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5568
5569 xappConn1.TestMsgChanEmpty(t)
5570 e2termConn1.TestMsgChanEmpty(t)
5571 mainCtrl.wait_registry_empty(t, 10)
5572
5573 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005574 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005575}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005576
archaggeafbf95f2021-04-14 08:54:05 +03005577func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5578
5579 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005580
5581 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005582 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005583 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005584 Counter{cSubReqToE2, uint64(subReqCount)},
5585 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005586 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005587 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005588 Counter{cSubDelReqToE2, uint64(subReqCount)},
5589 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005590 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005591 })
5592
5593 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005594 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005595 restSubId := xappConn1.SendRESTSubsReq(t, params)
5596 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5597
5598 assert.Equal(t, len(e2SubsIds), subReqCount)
5599
5600 // Del
5601 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5602 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5603
5604 xappConn1.TestMsgChanEmpty(t)
5605 e2termConn1.TestMsgChanEmpty(t)
5606 mainCtrl.wait_registry_empty(t, 10)
5607
5608 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005609 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005610}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005611
5612func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5613 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5614
5615 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005616 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005617 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005618 Counter{cSubReqToE2, 2},
5619 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005620 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005621 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005622 Counter{cSubDelReqToE2, 2},
5623 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005624 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005625 })
5626
5627 // Req1
5628 var params *teststube2ap.RESTSubsReqParams = nil
5629
5630 //Subs Create
5631 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005632 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005633
5634 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5635
5636 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005637 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005638 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005639 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005640 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5641
5642 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005643 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005644 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5645 xappConn2.ExpectRESTNotification(t, restSubId2)
5646 e2termConn1.SendSubsResp(t, crereq, cremsg)
5647 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5648
5649 deleteXapp1Subscription(t, &restSubId1)
5650 deleteXapp2Subscription(t, &restSubId2)
5651
5652 waitSubsCleanup(t, e2SubsId1, 10)
5653 waitSubsCleanup(t, e2SubsId2, 10)
5654
5655 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005656 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005657}
5658
5659func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5660 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5661
5662 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005663 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005664 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005665 Counter{cSubReqToE2, 2},
5666 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005667 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005668 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005669 Counter{cSubDelReqToE2, 2},
5670 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005671 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005672 })
5673
5674 // Req1
5675 var params *teststube2ap.RESTSubsReqParams = nil
5676
5677 //Subs Create
5678 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005679 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005680
5681 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5682
5683 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005684 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005685 params.SetMeid("RAN_NAME_1")
5686
5687 actionId := int64(1)
5688 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005689 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005690 subsequestActionType := "continue"
5691 timeToWait := "w10ms"
5692 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5693
5694 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005695 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005696 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5697 xappConn2.ExpectRESTNotification(t, restSubId2)
5698 e2termConn1.SendSubsResp(t, crereq, cremsg)
5699 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5700
5701 deleteXapp1Subscription(t, &restSubId1)
5702 deleteXapp2Subscription(t, &restSubId2)
5703
5704 waitSubsCleanup(t, e2SubsId1, 10)
5705 waitSubsCleanup(t, e2SubsId2, 10)
5706
5707 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005708 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005709}
5710
5711func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5712 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5713
5714 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005715 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005716 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005717 Counter{cSubReqToE2, 2},
5718 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005719 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005720 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005721 Counter{cSubDelReqToE2, 2},
5722 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005723 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005724 })
5725
5726 // Req1
5727 var params *teststube2ap.RESTSubsReqParams = nil
5728
5729 //Subs Create
5730 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005731 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005732
5733 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5734
5735 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005736 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005737 params.SetMeid("RAN_NAME_1")
5738 params.SetSubActionIDs(int64(2))
5739
5740 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005741 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005742 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5743 xappConn2.ExpectRESTNotification(t, restSubId2)
5744 e2termConn1.SendSubsResp(t, crereq, cremsg)
5745 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5746
5747 deleteXapp1Subscription(t, &restSubId1)
5748 deleteXapp2Subscription(t, &restSubId2)
5749
5750 waitSubsCleanup(t, e2SubsId1, 10)
5751 waitSubsCleanup(t, e2SubsId2, 10)
5752
5753 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005754 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005755}
5756
5757func TestRESTSubReqDiffActionType(t *testing.T) {
5758 CaseBegin("TestRESTSubReqDiffActionType")
5759
5760 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005761 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005762 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005763 Counter{cSubReqToE2, 2},
5764 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005765 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005766 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005767 Counter{cSubDelReqToE2, 2},
5768 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005769 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005770 })
5771
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005772 const e2Timeout int64 = 2
5773 const e2RetryCount int64 = 2
5774 const routingNeeded bool = true
5775
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005776 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005777 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005778 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005779
5780 //Subs Create
5781 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005782 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005783
5784 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5785
5786 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005787 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005788 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005789 params.SetMeid("RAN_NAME_1")
5790
5791 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005792 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005793 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5794 xappConn2.ExpectRESTNotification(t, restSubId2)
5795 e2termConn1.SendSubsResp(t, crereq, cremsg)
5796 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5797
5798 deleteXapp1Subscription(t, &restSubId1)
5799 deleteXapp2Subscription(t, &restSubId2)
5800
5801 waitSubsCleanup(t, e2SubsId1, 10)
5802 waitSubsCleanup(t, e2SubsId2, 10)
5803
5804 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005805 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005806}
5807
5808func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5809 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5810
5811 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005812 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005813 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005814 Counter{cSubReqToE2, 2},
5815 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005816 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005817 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005818 Counter{cSubDelReqToE2, 2},
5819 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005820 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005821 })
5822
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005823 const e2Timeout int64 = 2
5824 const e2RetryCount int64 = 2
5825 const routingNeeded bool = true
5826
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005827 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005828 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005829 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005830
5831 //Subs Create
5832 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005833 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005834
5835 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5836
5837 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005838 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005839 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005840 params.SetMeid("RAN_NAME_1")
5841
5842 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005843 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005844 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5845 xappConn2.ExpectRESTNotification(t, restSubId2)
5846 e2termConn1.SendSubsResp(t, crereq, cremsg)
5847 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5848
5849 deleteXapp1Subscription(t, &restSubId1)
5850 deleteXapp2Subscription(t, &restSubId2)
5851
5852 waitSubsCleanup(t, e2SubsId1, 10)
5853 waitSubsCleanup(t, e2SubsId2, 10)
5854
5855 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005856 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005857}
5858
5859func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5860 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5861
5862 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005863 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005864 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005865 Counter{cSubReqToE2, 2},
5866 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005867 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005868 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005869 Counter{cSubDelReqToE2, 2},
5870 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005871 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005872 })
5873
5874 // Req1
5875 var params *teststube2ap.RESTSubsReqParams = nil
5876
5877 //Subs Create
5878 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005879 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005880
5881 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5882
5883 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005884 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005885 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005886 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005887 params.SetSubActionDefinition(actionDefinition)
5888
5889 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005890 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005891 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5892 xappConn2.ExpectRESTNotification(t, restSubId2)
5893 e2termConn1.SendSubsResp(t, crereq, cremsg)
5894 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5895
5896 deleteXapp1Subscription(t, &restSubId1)
5897 deleteXapp2Subscription(t, &restSubId2)
5898
5899 waitSubsCleanup(t, e2SubsId1, 10)
5900 waitSubsCleanup(t, e2SubsId2, 10)
5901
5902 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005903 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005904}
5905
5906func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5907 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5908
5909 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005910 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005911 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005912 Counter{cSubReqToE2, 2},
5913 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005914 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005915 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005916 Counter{cSubDelReqToE2, 2},
5917 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005918 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005919 })
5920
5921 // Req1
5922 var params *teststube2ap.RESTSubsReqParams = nil
5923
5924 //Subs Create
5925 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005926 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005927
5928 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5929
5930 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005931 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005932 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005933 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005934 params.SetSubActionDefinition(actionDefinition)
5935
5936 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005937 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005938 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5939 xappConn2.ExpectRESTNotification(t, restSubId2)
5940 e2termConn1.SendSubsResp(t, crereq, cremsg)
5941 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5942
5943 deleteXapp1Subscription(t, &restSubId1)
5944 deleteXapp2Subscription(t, &restSubId2)
5945
5946 waitSubsCleanup(t, e2SubsId1, 10)
5947 waitSubsCleanup(t, e2SubsId2, 10)
5948
5949 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005950 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005951}
5952
5953func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5954 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5955
5956 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005957 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005958 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005959 Counter{cSubReqToE2, 2},
5960 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005961 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005962 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005963 Counter{cSubDelReqToE2, 2},
5964 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005965 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005966 })
5967
5968 // Req1
5969 var params *teststube2ap.RESTSubsReqParams = nil
5970
5971 //Subs Create
5972 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005973 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005974
5975 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5976
5977 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005978 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005979 params.SetMeid("RAN_NAME_1")
5980 params.SetTimeToWait("w200ms")
5981 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005982 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005983 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5984 xappConn2.ExpectRESTNotification(t, restSubId2)
5985 e2termConn1.SendSubsResp(t, crereq, cremsg)
5986 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5987
5988 deleteXapp1Subscription(t, &restSubId1)
5989 deleteXapp2Subscription(t, &restSubId2)
5990
5991 waitSubsCleanup(t, e2SubsId1, 10)
5992 waitSubsCleanup(t, e2SubsId2, 10)
5993
5994 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005995 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005996}
5997
Anssi Mannila51122392021-05-25 11:51:31 +03005998//-----------------------------------------------------------------------------
5999// TestRESTUnpackSubscriptionResponseDecodeFail
6000//
6001// stub stub
6002// +-------+ +---------+ +---------+
6003// | xapp | | submgr | | e2term |
6004// +-------+ +---------+ +---------+
6005// | | |
6006// | RestSubReq | |
6007// |---------------->| |
6008// | | |
6009// | RESTSubResp | |
6010// |<----------------| |
6011// | | |
6012// | | SubReq |
6013// | |------------->|
6014// | | |
6015// | | SubResp | ASN.1 decode fails
6016// | |<-------------|
6017// | | |
6018// | | SubReq |
6019// | |------------->|
6020// | | |
6021// | | SubFail | Duplicated action
6022// | |<-------------|
6023// | RESTNotif (fail)| |
6024// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006025// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006026//
6027//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006028
Anssi Mannila51122392021-05-25 11:51:31 +03006029func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006030 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
6031 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006032
6033 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006034 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006035 restSubId := xappConn1.SendRESTSubsReq(t, params)
6036
6037 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6038 // Decode of this response fails which will result resending original request
6039 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6040
6041 _, cremsg = e2termConn1.RecvSubsReq(t)
6042
Markku Virtanen55d2a282021-06-04 14:46:56 +03006043 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006044
6045 // Subscription already created in E2 Node.
6046 fparams := &teststube2ap.E2StubSubsFailParams{}
6047 fparams.Set(crereq)
6048 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6049 e2termConn1.SendSubsFail(t, fparams, cremsg)
6050
Anssi Mannila51122392021-05-25 11:51:31 +03006051 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006052 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006053
Anssi Mannilab43397e2021-11-16 12:06:16 +02006054 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6055
Anssi Mannila51122392021-05-25 11:51:31 +03006056 // Wait that subs is cleaned
6057 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6058
6059 xappConn1.TestMsgChanEmpty(t)
6060 e2termConn1.TestMsgChanEmpty(t)
6061 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006062 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006063}
6064
6065//-----------------------------------------------------------------------------
6066// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6067//
6068// stub stub
6069// +-------+ +---------+ +---------+
6070// | xapp | | submgr | | e2term |
6071// +-------+ +---------+ +---------+
6072// | | |
6073// | RestSubReq | |
6074// |---------------->| |
6075// | | |
6076// | RESTSubResp | |
6077// |<----------------| |
6078// | | |
6079// | | SubReq |
6080// | |------------->|
6081// | | |
6082// | | SubResp | Unknown instanceId
6083// | |<-------------|
6084// | | |
6085// | | SubReq |
6086// | |------------->|
6087// | | |
6088// | | SubFail | Duplicated action
6089// | |<-------------|
6090// | RESTNotif (fail)| |
6091// |<----------------| |
6092// | | SubDelReq |
6093// | |------------->|
6094// | | |
6095// | | SubDelResp |
6096// | |<-------------|
6097//
6098//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006099
Anssi Mannila51122392021-05-25 11:51:31 +03006100func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006101 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6102 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006103
6104 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006105 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006106 restSubId := xappConn1.SendRESTSubsReq(t, params)
6107
6108 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6109
6110 // Unknown instanceId in this response which will result resending original request
6111 orgInstanceId := crereq.RequestId.InstanceId
6112 crereq.RequestId.InstanceId = 0
6113 e2termConn1.SendSubsResp(t, crereq, cremsg)
6114
6115 _, cremsg = e2termConn1.RecvSubsReq(t)
6116
Markku Virtanen55d2a282021-06-04 14:46:56 +03006117 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006118
6119 // Subscription already created in E2 Node.
6120 fparams := &teststube2ap.E2StubSubsFailParams{}
6121 fparams.Set(crereq)
6122 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6123 e2termConn1.SendSubsFail(t, fparams, cremsg)
6124
6125 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6126 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6127
6128 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006129 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006130
Anssi Mannilab43397e2021-11-16 12:06:16 +02006131 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6132
Anssi Mannila51122392021-05-25 11:51:31 +03006133 // Wait that subs is cleaned
6134 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6135
6136 xappConn1.TestMsgChanEmpty(t)
6137 e2termConn1.TestMsgChanEmpty(t)
6138 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006139 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006140}
6141
6142//-----------------------------------------------------------------------------
6143// TestRESTUnpackSubscriptionResponseNoTransaction
6144//
6145// stub stub
6146// +-------+ +---------+ +---------+
6147// | xapp | | submgr | | e2term |
6148// +-------+ +---------+ +---------+
6149// | | |
6150// | RestSubReq | |
6151// |---------------->| |
6152// | | |
6153// | RESTSubResp | |
6154// |<----------------| |
6155// | | |
6156// | | SubReq |
6157// | |------------->|
6158// | | |
6159// | | SubResp | No transaction for the response
6160// | |<-------------|
6161// | | |
6162// | | SubReq |
6163// | |------------->|
6164// | | |
6165// | | SubFail | Duplicated action
6166// | |<-------------|
6167// | RESTNotif (fail)| |
6168// |<----------------| |
6169// | | SubDelReq |
6170// | |------------->|
6171// | | |
6172// | | SubDelResp |
6173// | |<-------------|
6174// | | |
6175// | | SubDelReq |
6176// | |------------->|
6177// | | |
6178// | | SubDelResp |
6179// | |<-------------|
6180//
6181//-----------------------------------------------------------------------------
6182func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006183 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6184 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006185
6186 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006187 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006188 restSubId := xappConn1.SendRESTSubsReq(t, params)
6189
6190 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6191
6192 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6193 // No transaction exist for this response which will result resending original request
6194 e2termConn1.SendSubsResp(t, crereq, cremsg)
6195
6196 _, cremsg = e2termConn1.RecvSubsReq(t)
6197
Markku Virtanen55d2a282021-06-04 14:46:56 +03006198 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006199
6200 // Subscription already created in E2 Node.
6201 fparams := &teststube2ap.E2StubSubsFailParams{}
6202 fparams.Set(crereq)
6203 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6204 e2termConn1.SendSubsFail(t, fparams, cremsg)
6205
6206 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6207 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6208
6209 // Resending happens because there no transaction
6210 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6211 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6212
6213 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006214 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006215
Anssi Mannilab43397e2021-11-16 12:06:16 +02006216 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6217
Anssi Mannila51122392021-05-25 11:51:31 +03006218 // Wait that subs is cleaned
6219 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6220
6221 xappConn1.TestMsgChanEmpty(t)
6222 e2termConn1.TestMsgChanEmpty(t)
6223 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006224 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006225}
6226
6227//-----------------------------------------------------------------------------
6228// TestRESTUnpackSubscriptionFailureDecodeFail
6229//
6230// stub stub
6231// +-------+ +---------+ +---------+
6232// | xapp | | submgr | | e2term |
6233// +-------+ +---------+ +---------+
6234// | | |
6235// | RestSubReq | |
6236// |---------------->| |
6237// | | |
6238// | RESTSubResp | |
6239// |<----------------| |
6240// | | |
6241// | | SubReq |
6242// | |------------->|
6243// | | |
6244// | | SubFail | ASN.1 decode fails
6245// | |<-------------|
6246// | | |
6247// | | SubReq |
6248// | |------------->|
6249// | | |
6250// | | SubFail | Duplicated action
6251// | |<-------------|
6252// | RESTNotif (fail)| |
6253// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006254// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006255//
6256//-----------------------------------------------------------------------------
6257func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006258 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6259 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006260
6261 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006262 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006263 restSubId := xappConn1.SendRESTSubsReq(t, params)
6264
6265 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6266
6267 // Decode of this response fails which will result resending original request
6268 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6269
6270 _, cremsg = e2termConn1.RecvSubsReq(t)
6271
Markku Virtanen55d2a282021-06-04 14:46:56 +03006272 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006273
6274 // Subscription already created in E2 Node.
6275 fparams := &teststube2ap.E2StubSubsFailParams{}
6276 fparams.Set(crereq)
6277 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6278 e2termConn1.SendSubsFail(t, fparams, cremsg)
6279
Anssi Mannila51122392021-05-25 11:51:31 +03006280 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006281 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006282
Anssi Mannilab43397e2021-11-16 12:06:16 +02006283 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6284
Anssi Mannila51122392021-05-25 11:51:31 +03006285 // Wait that subs is cleaned
6286 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6287
6288 xappConn1.TestMsgChanEmpty(t)
6289 e2termConn1.TestMsgChanEmpty(t)
6290 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006291 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006292}
6293
6294//-----------------------------------------------------------------------------
6295// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6296//
6297// stub stub
6298// +-------+ +---------+ +---------+
6299// | xapp | | submgr | | e2term |
6300// +-------+ +---------+ +---------+
6301// | | |
6302// | RestSubReq | |
6303// |---------------->| |
6304// | | |
6305// | RESTSubResp | |
6306// |<----------------| |
6307// | | |
6308// | | SubReq |
6309// | |------------->|
6310// | | |
6311// | | SubFail | Unknown instanceId
6312// | |<-------------|
6313// | | |
6314// | | SubReq |
6315// | |------------->|
6316// | | |
6317// | | SubFail | Duplicated action
6318// | |<-------------|
6319// | RESTNotif (fail)| |
6320// |<----------------| |
6321// | | SubDelReq |
6322// | |------------->|
6323// | | |
6324// | | SubDelResp |
6325// | |<-------------|
6326//
6327//-----------------------------------------------------------------------------
6328func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006329 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6330 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006331
6332 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006333 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006334 restSubId := xappConn1.SendRESTSubsReq(t, params)
6335
6336 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6337
6338 // Unknown instanceId in this response which will result resending original request
6339 fparams := &teststube2ap.E2StubSubsFailParams{}
6340 fparams.Set(crereq)
6341 fparams.Fail.RequestId.InstanceId = 0
6342 e2termConn1.SendSubsFail(t, fparams, cremsg)
6343
6344 _, cremsg = e2termConn1.RecvSubsReq(t)
6345
Markku Virtanen55d2a282021-06-04 14:46:56 +03006346 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006347
6348 // Subscription already created in E2 Node.
6349 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6350 e2termConn1.SendSubsFail(t, fparams, cremsg)
6351
6352 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6353 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6354
6355 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006356 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006357
Anssi Mannilab43397e2021-11-16 12:06:16 +02006358 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6359
Anssi Mannila51122392021-05-25 11:51:31 +03006360 // Wait that subs is cleaned
6361 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6362
6363 xappConn1.TestMsgChanEmpty(t)
6364 e2termConn1.TestMsgChanEmpty(t)
6365 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006366 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006367}
6368
6369//-----------------------------------------------------------------------------
6370// TestRESTUnpackSubscriptionFailureNoTransaction
6371//
6372// stub stub
6373// +-------+ +---------+ +---------+
6374// | xapp | | submgr | | e2term |
6375// +-------+ +---------+ +---------+
6376// | | |
6377// | RestSubReq | |
6378// |---------------->| |
6379// | | |
6380// | RESTSubResp | |
6381// |<----------------| |
6382// | | |
6383// | | SubReq |
6384// | |------------->|
6385// | | |
6386// | | SubFail | No transaction for the response
6387// | |<-------------|
6388// | | |
6389// | | SubReq |
6390// | |------------->|
6391// | | |
6392// | | SubFail | Duplicated action
6393// | |<-------------|
6394// | RESTNotif (fail)| |
6395// |<----------------| |
6396// | | SubDelReq |
6397// | |------------->|
6398// | | |
6399// | | SubDelResp |
6400// | |<-------------|
6401//
6402//-----------------------------------------------------------------------------
6403func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006404 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6405 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006406
6407 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006408 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006409 restSubId := xappConn1.SendRESTSubsReq(t, params)
6410
6411 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6412
6413 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6414
6415 // No transaction exist for this response which will result resending original request
6416 fparams := &teststube2ap.E2StubSubsFailParams{}
6417 fparams.Set(crereq)
6418 e2termConn1.SendSubsFail(t, fparams, cremsg)
6419
6420 _, cremsg = e2termConn1.RecvSubsReq(t)
6421
Markku Virtanen55d2a282021-06-04 14:46:56 +03006422 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006423
6424 // Subscription already created in E2 Node.
6425 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6426 e2termConn1.SendSubsFail(t, fparams, cremsg)
6427
6428 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6429 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6430
6431 // Resending happens because there no transaction
6432 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6433 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6434
6435 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006436 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006437
Anssi Mannilab43397e2021-11-16 12:06:16 +02006438 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6439
Anssi Mannila51122392021-05-25 11:51:31 +03006440 // Wait that subs is cleaned
6441 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6442
6443 xappConn1.TestMsgChanEmpty(t)
6444 e2termConn1.TestMsgChanEmpty(t)
6445 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006446 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006447}
6448
6449//-----------------------------------------------------------------------------
6450// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6451//
6452// stub stub
6453// +-------+ +---------+ +---------+
6454// | xapp | | submgr | | e2term |
6455// +-------+ +---------+ +---------+
6456// | | |
6457// | [SUBS CREATE] |
6458// | | |
6459// | | |
6460// | RESTSubDelReq | |
6461// |---------------->| |
6462// | | |
6463// | RESTSubDelResp | |
6464// |<----------------| |
6465// | | |
6466// | | SubDelReq |
6467// | |------------->|
6468// | | |
6469// | | SubDelResp | ASN.1 decode fails
6470// | |<-------------|
6471// | | |
6472// | | SubDelReq |
6473// | |------------->|
6474// | | |
6475// | | SubDelFail | Subscription does exist any more
6476// | |<-------------|
6477// | | |
6478//
6479//-----------------------------------------------------------------------------
6480func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006481 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006482
6483 // Req
6484 var params *teststube2ap.RESTSubsReqParams = nil
6485 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6486
6487 // Del
6488 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6489
6490 // E2t: Receive 1st SubsDelReq
6491 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6492
6493 // Decode of this response fails which will result resending original request
6494 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6495
6496 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6497 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6498
6499 // Subscription does not exist in in E2 Node.
6500 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6501
6502 // Wait that subs is cleaned
6503 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6504
6505 xappConn1.TestMsgChanEmpty(t)
6506 e2termConn1.TestMsgChanEmpty(t)
6507 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006508 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006509}
6510
6511//-----------------------------------------------------------------------------
6512// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6513//
6514// stub stub
6515// +-------+ +---------+ +---------+
6516// | xapp | | submgr | | e2term |
6517// +-------+ +---------+ +---------+
6518// | | |
6519// | [SUBS CREATE] |
6520// | | |
6521// | | |
6522// | RESTSubDelReq | |
6523// |---------------->| |
6524// | | |
6525// | RESTSubDelResp | |
6526// |<----------------| |
6527// | | |
6528// | | SubDelReq |
6529// | |------------->|
6530// | | |
6531// | | SubDelResp | Unknown instanceId
6532// | |<-------------|
6533// | | |
6534// | | SubDelReq |
6535// | |------------->|
6536// | | |
6537// | | SubDelFail | Subscription does exist any more
6538// | |<-------------|
6539//
6540//-----------------------------------------------------------------------------
6541func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006542 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006543
6544 // Req
6545 var params *teststube2ap.RESTSubsReqParams = nil
6546 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6547
6548 // Del
6549 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6550
6551 // E2t: Receive 1st SubsDelReq
6552 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6553
6554 // Unknown instanceId in this response which will result resending original request
6555 delreq.RequestId.InstanceId = 0
6556 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6557
6558 // E2t: Receive 2nd SubsDelReq
6559 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6560
6561 // Subscription does not exist in in E2 Node.
6562 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6563
6564 // Wait that subs is cleaned
6565 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6566
6567 xappConn1.TestMsgChanEmpty(t)
6568 e2termConn1.TestMsgChanEmpty(t)
6569 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006570 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006571}
6572
6573//-----------------------------------------------------------------------------
6574// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6575//
6576// stub stub
6577// +-------+ +---------+ +---------+
6578// | xapp | | submgr | | e2term |
6579// +-------+ +---------+ +---------+
6580// | | |
6581// | [SUBS CREATE] |
6582// | | |
6583// | | |
6584// | RESTSubDelReq | |
6585// |---------------->| |
6586// | | |
6587// | RESTSubDelResp | |
6588// |<----------------| |
6589// | | |
6590// | | SubDelReq |
6591// | |------------->|
6592// | | |
6593// | | SubDelResp | No transaction for the response
6594// | |<-------------|
6595// | | |
6596// | | SubDelReq |
6597// | |------------->|
6598// | | |
6599// | | SubDelFail | Subscription does exist any more
6600// | |<-------------|
6601//
6602//-----------------------------------------------------------------------------
6603func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006604 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006605
6606 // Req
6607 var params *teststube2ap.RESTSubsReqParams = nil
6608 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6609
6610 // Del
6611 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6612
6613 // E2t: Receive 1st SubsDelReq
6614 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6615
6616 mainCtrl.MakeTransactionNil(t, e2SubsId)
6617
6618 // No transaction exist for this response which will result resending original request
6619 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6620
6621 // E2t: Receive 2nd SubsDelReq
6622 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6623
6624 // Subscription does not exist in in E2 Node.
6625 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6626
6627 // Wait that subs is cleaned
6628 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6629
6630 xappConn1.TestMsgChanEmpty(t)
6631 e2termConn1.TestMsgChanEmpty(t)
6632 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006633 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006634}
6635
6636//-----------------------------------------------------------------------------
6637// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6638//
6639// stub stub
6640// +-------+ +---------+ +---------+
6641// | xapp | | submgr | | e2term |
6642// +-------+ +---------+ +---------+
6643// | | |
6644// | [SUBS CREATE] |
6645// | | |
6646// | | |
6647// | RESTSubDelReq | |
6648// |---------------->| |
6649// | | |
6650// | RESTSubDelResp | |
6651// |<----------------| |
6652// | | |
6653// | | SubDelReq |
6654// | |------------->|
6655// | | |
6656// | | SubDelFail | ASN.1 decode fails
6657// | |<-------------|
6658// | | |
6659// | | SubDelReq |
6660// | |------------->|
6661// | | |
6662// | | SubDelFail | Subscription does exist any more
6663// | |<-------------|
6664//
6665//-----------------------------------------------------------------------------
6666func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006667 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006668
6669 // Req
6670 var params *teststube2ap.RESTSubsReqParams = nil
6671 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6672
6673 // Del
6674 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6675
6676 // E2t: Receive 1st SubsDelReq
6677 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6678
6679 // Decode of this response fails which will result resending original request
6680 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6681
6682 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6683 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6684
6685 // Subscription does not exist in in E2 Node.
6686 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6687
6688 // Wait that subs is cleaned
6689 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6690
6691 xappConn1.TestMsgChanEmpty(t)
6692 e2termConn1.TestMsgChanEmpty(t)
6693 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006694 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006695}
6696
6697//-----------------------------------------------------------------------------
6698// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6699//
6700// stub stub
6701// +-------+ +---------+ +---------+
6702// | xapp | | submgr | | e2term |
6703// +-------+ +---------+ +---------+
6704// | | |
6705// | [SUBS CREATE] |
6706// | | |
6707// | | |
6708// | RESTSubDelReq | |
6709// |---------------->| |
6710// | | |
6711// | RESTSubDelResp | |
6712// |<----------------| |
6713// | | |
6714// | | SubDelReq |
6715// | |------------->|
6716// | | |
6717// | | SubDelFail | Unknown instanceId
6718// | |<-------------|
6719// | | |
6720// | | SubDelReq |
6721// | |------------->|
6722// | | |
6723// | | SubDelFail | Subscription does exist any more
6724// | |<-------------|
6725//
6726//-----------------------------------------------------------------------------
6727func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006728 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006729
6730 // Req
6731 var params *teststube2ap.RESTSubsReqParams = nil
6732 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6733
6734 // Del
6735 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6736
6737 // E2t: Receive 1st SubsDelReq
6738 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6739
6740 // Unknown instanceId in this response which will result resending original request
6741 delreq.RequestId.InstanceId = 0
6742 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6743
6744 // E2t: Receive 2nd SubsDelReq
6745 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6746
6747 // Subscription does not exist in in E2 Node.
6748 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6749
6750 // Wait that subs is cleaned
6751 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6752
6753 xappConn1.TestMsgChanEmpty(t)
6754 e2termConn1.TestMsgChanEmpty(t)
6755 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006756 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006757}
6758
6759//-----------------------------------------------------------------------------
6760// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6761//
6762// stub stub
6763// +-------+ +---------+ +---------+
6764// | xapp | | submgr | | e2term |
6765// +-------+ +---------+ +---------+
6766// | | |
6767// | [SUBS CREATE] |
6768// | | |
6769// | | |
6770// | RESTSubDelReq | |
6771// |---------------->| |
6772// | | |
6773// | RESTSubDelResp | |
6774// |<----------------| |
6775// | | |
6776// | | SubDelReq |
6777// | |------------->|
6778// | | |
6779// | | SubDelFail | No transaction for the response
6780// | |<-------------|
6781// | | |
6782// | | SubDelReq |
6783// | |------------->|
6784// | | |
6785// | | SubDelFail | Subscription does exist any more
6786// | |<-------------|
6787//
6788//-----------------------------------------------------------------------------
6789func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006790 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006791
6792 // Req
6793 var params *teststube2ap.RESTSubsReqParams = nil
6794 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6795
6796 // Del
6797 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6798
6799 // E2t: Receive 1st SubsDelReq
6800 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6801
6802 mainCtrl.MakeTransactionNil(t, e2SubsId)
6803
6804 // No transaction exist for this response which will result resending original request
6805 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6806
6807 // E2t: Receive 2nd SubsDelReq
6808 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6809
6810 // Subscription does not exist in in E2 Node.
6811 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6812
6813 // Wait that subs is cleaned
6814 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6815
6816 xappConn1.TestMsgChanEmpty(t)
6817 e2termConn1.TestMsgChanEmpty(t)
6818 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006819 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006820}
6821
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006822//-----------------------------------------------------------------------------
6823// TestRESTSubReqFailAsn1PackSubReqError
6824//
6825// stub stub
6826// +-------+ +---------+ +---------+
6827// | xapp | | submgr | | e2term |
6828// +-------+ +---------+ +---------+
6829// | | |
6830// | RESTSubReq | |
6831// |---------------->| |
6832// | | |
6833// | RESTSubResp | |
6834// |<----------------| |
6835// | | |
6836// | ASN.1 encode fails |
6837// | | |
6838// | | SubDelReq |
6839// | |------------->|
6840// | | |
6841// | | SubDelFail |
6842// | |<-------------|
6843// | | |
6844// | RESTNotif | |
6845// | unsuccess | |
6846// |<----------------| |
6847// | | |
6848// | [SUBS DELETE] |
6849// | | |
6850//
6851//-----------------------------------------------------------------------------
6852func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6853
6854 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006855 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006856 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006857 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006858 Counter{cRestSubDelReqFromXapp, 1},
6859 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006860 })
6861
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006862 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006863
6864 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006865 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006866 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6867
6868 // Req
6869 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006870 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006871
6872 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006873 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006874
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006875 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006876 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006877
6878 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006879
6880 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6881
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006882 // Wait that subs is cleaned
6883 waitSubsCleanup(t, e2SubsId, 10)
6884 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006885 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006886}
6887
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006888func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6889 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6890
6891 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6892 Counter{cRestSubReqFromXapp, 2},
6893 Counter{cRestSubRespToXapp, 2},
6894 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006895 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006896 Counter{cSubRespFromE2, 1},
6897 Counter{cRestSubNotifToXapp, 1},
6898 Counter{cRestSubFailNotifToXapp, 1},
6899 Counter{cRestSubDelReqFromXapp, 1},
6900 Counter{cSubDelReqToE2, 1},
6901 Counter{cSubDelRespFromE2, 1},
6902 Counter{cRestSubDelRespToXapp, 1},
6903 })
6904
6905 const e2Timeout int64 = 1
6906 const e2RetryCount int64 = 0
6907 const routingNeeded bool = false
6908
6909 // Req1
6910 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6911 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6912
6913 // Subs Create
6914 restSubId := xappConn1.SendRESTSubsReq(t, params)
6915 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6916
6917 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6918 xappConn1.ExpectRESTNotification(t, restSubId)
6919 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6920 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6921 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6922
6923 // Policy change
6924 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6925 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6926 params.SetSubscriptionID(&restSubId)
6927 params.SetTimeToWait("w200ms")
6928 restSubId = xappConn1.SendRESTSubsReq(t, params)
6929 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6930
6931 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6932 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006933 // SubsResp is missing, e2SubsId will be 0
6934 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6935 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006936
6937 // Del
6938 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6939 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6940 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6941
6942 waitSubsCleanup(t, e2SubsId, 10)
6943
6944 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006945 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006946}
6947
6948//-----------------------------------------------------------------------------
6949// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6950//
6951// stub stub
6952// +-------+ +---------+ +---------+
6953// | xapp | | submgr | | e2term |
6954// +-------+ +---------+ +---------+
6955// | | |
6956// | RESTSubReq | |
6957// |---------------->| |
6958// | | |
6959// | RESTSubResp | |
6960// |<----------------| |
6961// | | SubReq |
6962// | |------------->|
6963// | | |
6964// | | SubResp |
6965// | |<-------------|
6966// | | |
6967// | RESTNotif | |
6968// |<----------------| |
6969// | | |
6970// | RESTSubReq | |
6971// |---------------->| |
6972// | | |
6973// | RESTSubResp | |
6974// |<----------------| |
6975// | | SubReq |
6976// | |------------->|
6977// | |
6978// | Submgr restart |
6979// | | |
6980// | RESTSubDelReq | |
6981// |---------------->| |
6982// | | |
6983// | | SubDelReq |
6984// | |------------->|
6985// | | |
6986// | | SubDelResp |
6987// | |<-------------|
6988// | | |
6989// | RESTSubDelResp | |
6990// |<----------------| |
6991//
6992//-----------------------------------------------------------------------------
6993
6994func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6995 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6996
6997 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6998 Counter{cRestSubReqFromXapp, 2},
6999 Counter{cRestSubRespToXapp, 2},
7000 Counter{cSubReqToE2, 2},
7001 Counter{cSubRespFromE2, 1},
7002 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007003 Counter{cRestSubDelReqFromXapp, 1},
7004 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02007005 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007006 Counter{cRestSubDelRespToXapp, 1},
7007 })
7008
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007009 const e2Timeout int64 = 1
7010 const e2RetryCount int64 = 0
7011 const routingNeeded bool = false
7012
7013 // Req1
7014 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7015 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7016 // Create subscription
7017 restSubId := xappConn1.SendRESTSubsReq(t, params)
7018 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7019
7020 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7021 xappConn1.ExpectRESTNotification(t, restSubId)
7022 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7023 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7024 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7025
7026 // Check subscription
7027 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7028
7029 // Policy change
7030 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7031 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7032 params.SetSubscriptionID(&restSubId)
7033 params.SetTimeToWait("w200ms")
7034 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7035 restSubId = xappConn1.SendRESTSubsReq(t, params)
7036 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7037
7038 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7039 mainCtrl.SetResetTestFlag(t, false)
7040
7041 // SubsResp is missing due to submgr restart
7042
7043 mainCtrl.SimulateRestart(t)
7044 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7045
Anssi Mannila54838ed2021-11-19 11:25:01 +02007046 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
7047 // That needs to be completed before successful subscription query is possible
7048 <-time.After(time.Second * 1)
7049
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007050 // Check subscription
7051 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7052
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007053 // Delete subscription
7054 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7055 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7056 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7057
7058 //Wait that subs is cleaned
7059 waitSubsCleanup(t, e2SubsId, 10)
7060
7061 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007062 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007063}
7064
archaggeafbf95f2021-04-14 08:54:05 +03007065////////////////////////////////////////////////////////////////////////////////////
7066// Services for UT cases
7067////////////////////////////////////////////////////////////////////////////////////
7068const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007069const host string = "localhost"
7070
7071func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7072 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007073 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007074 }
7075 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007076 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007077
7078 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7079 fromXappConn.ExpectRESTNotification(t, restSubId)
7080 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7081 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007082 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007083
7084 return restSubId, e2SubsId
7085}
7086
7087func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7088
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007089 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007090 if meid != "" {
7091 params.SetMeid(meid)
7092 }
7093 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7094 restSubId := xappConn2.SendRESTSubsReq(t, params)
7095 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007096 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007097 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007098 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007099
7100 return restSubId, e2SubsId
7101}
7102
7103func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007104
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007105 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007106 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007107 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007108
7109 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7110 xappConn1.ExpectRESTNotification(t, restSubId)
7111 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7112 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007113 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007114
7115 return restSubId, e2SubsId
7116}
7117
7118func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007119 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007120 restSubId := xappConn1.SendRESTSubsReq(t, params)
7121
7122 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7123 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7124 fparams1.Set(crereq1)
7125 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7126
7127 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7128 xappConn1.ExpectRESTNotification(t, restSubId)
7129 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7130 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007131 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007132
7133 return restSubId, e2SubsId
7134}
7135
7136func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7137 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7138 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7139 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7140}
7141
7142func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7143 xappConn1.SendRESTSubsDelReq(t, restSubId)
7144 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7145 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7146}
7147
7148func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7149 xappConn2.SendRESTSubsDelReq(t, restSubId)
7150 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7151 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7152}
7153
7154func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7155 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02007156 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
7157 assert.Equal(t, meid, resp[0].Meid)
7158 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03007159}
7160
7161func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7162 //Wait that subs is cleaned
7163 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7164
7165 xappConn1.TestMsgChanEmpty(t)
7166 xappConn2.TestMsgChanEmpty(t)
7167 e2termConn1.TestMsgChanEmpty(t)
7168 mainCtrl.wait_registry_empty(t, timeout)
7169}
7170
7171func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7172
7173 var e2SubsId []uint32
7174
7175 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007176 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007177 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7178 fromXappConn.ExpectRESTNotification(t, restSubId)
7179 toE2termConn.SendSubsResp(t, crereq, cremsg)
7180 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7181 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007182 xapp.Logger.Debug("TEST: %v", e2SubsId)
7183 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007184 <-time.After(100 * time.Millisecond)
7185 }
7186 return e2SubsId
7187}
7188
7189func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7190
7191 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007192 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007193 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7194 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7195 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007196 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007197 <-time.After(100 * time.Millisecond)
7198 }
7199
7200 // Wait that subs is cleaned
7201 for i := 0; i < len(e2SubsIds); i++ {
7202 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7203 }
7204
7205}