blob: b4edc3f936f2f5bc4a219ce2e8e4bfc57d44622c [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 (
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000023 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020024 "testing"
25 "time"
26
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030029 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020030 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020031 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
32 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020033)
34
Anssi Mannila27385172021-12-22 09:41:54 +020035// In below test cases there is done only one retry for E2 messages
36// In Helm chart retry count is currently 2 By default. Retry count
37// used in test cases is defined in submgr-config.yaml file.
38
Markku Virtanenac8bde42021-05-25 09:54:42 +000039func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030040 // The effect of this call shall endure though the UT suite!
41 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000042 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000043 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
44
Anssi Mannila3d80b722021-11-12 13:17:15 +020045 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000046 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030047 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000048
Markku Virtanenac8bde42021-05-25 09:54:42 +000049}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030050func TestRanStatusChangeViaSDLNotification(t *testing.T) {
51
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020052 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
53 Counter{cE2StateChangedToUp, 3},
54 })
55
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030056 // Current UT test cases use these ran names
57 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
58 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
59 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
60
61 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
62 mainCtrl.c.e2IfState.SubscribeChannels()
63
64 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
65 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
66 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020067
68 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030069}
70
71//-----------------------------------------------------------------------------
72// TestRESTSubReqAfterE2ConnBreak
73//
74// stub stub
75// +-------+ +---------+ +---------+
76// | xapp | | submgr | | e2term |
77// +-------+ +---------+ +---------+
78// | | |
79// | [E2 Conn. DOWN] |
80// | | |
81// | RESTSubReq | |
82// |---------------->| |
83// | RESTSubFail | |
84// |<----------------| |
85// | | |
86//
87//-----------------------------------------------------------------------------
88
89func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030090
91 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
92 Counter{cRestSubReqFromXapp, 1},
93 Counter{cRestReqRejDueE2Down, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020094 Counter{cE2StateChangedToDown, 1},
95 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030096 })
97
98 // E2 disconnect after E2term has received response
99 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
100 // Req
101 const subReqCount int = 1
102 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
103 xappConn1.SendRESTSubsReq(t, params)
104
105 // Restore E2 connection for following test cases
106 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
107
Anssi Mannilab43397e2021-11-16 12:06:16 +0200108 mainCtrl.VerifyAllClean(t)
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200109 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300110}
111
112//-----------------------------------------------------------------------------
113// TestRESTSubReqE2ConnBreak
114//
115// stub stub
116// +-------+ +---------+ +---------+
117// | xapp | | submgr | | e2term |
118// +-------+ +---------+ +---------+
119// | | |
120// | RESTSubReq | |
121// |---------------->| |
122// | RESTSubResp | |
123// |<----------------| |
124// | | SubReq |
125// | |------------->|
126// | | SubResp |
127// | |<-------------|
128// | | |
129// | [E2 Conn. DOWN] |
130// | [Int. SUBS DELETE] |
131// | | |
132// | RESTNotif(unsuccessful) |
133// |<----------------| |
134// | | |
135// | | |
136//
137//-----------------------------------------------------------------------------
138func TestRESTSubReqE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300139
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)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200691 mainCtrl.VerifyCounterValues(t)
692}
693
694//-----------------------------------------------------------------------------
695// TestSubMergeDelAndRouteUpdateNok
696// stub stub
697// +-------+ +-------+ +---------+ +---------+
698// | xapp2 | | xapp1 | | submgr | | e2term |
699// +-------+ +-------+ +---------+ +---------+
700// | | | |
701// | | | |
702// | | | |
703// | | SubReq1 | |
704// | |------------->| |
705// | | | |
706// | | | SubReq1 |
707// | | |------------->|
708// | | | SubResp1 |
709// | | |<-------------|
710// | | SubResp1 | |
711// | |<-------------| |
712// | | | |
713// | SubReq2 | |
714// |--------------------------->| |
715// | | | |
716// | SubResp2 | |
717// |<---------------------------| |
718// | | | |
719// | | SubDelReq 1 | |
720// | |------------->| |
721// | | | RouteUpdate |
722// | | |-----> rtmgr |
723// | | | |
724// | | | RouteUpdate |
725// | | | status:400 |
726// | | |<----- rtmgr |
727// | | | |
728// | | SubDelResp 1 | |
729// | |<-------------| |
730// | | | |
731// | SubDelReq 2 | |
732// |--------------------------->| |
733// | | | |
734// | | | SubDelReq 2 |
735// | | |------------->|
736// | | | |
737// | | | SubDelReq 2 |
738// | | |------------->|
739// | | | |
740// | SubDelResp 2 | |
741// |<---------------------------| |
742//
743//-----------------------------------------------------------------------------
744func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
745 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
746
747 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200748 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
749 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200750 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200751 Counter{cSubReqToE2, 1},
752 Counter{cSubRespFromE2, 1},
753 Counter{cSubRespToXapp, 2},
754 Counter{cSubDelReqFromXapp, 2},
755 Counter{cRouteDeleteUpdateFail, 1},
756 Counter{cSubDelReqToE2, 1},
757 Counter{cSubDelRespFromE2, 1},
758 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200759 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200760 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200761
762 //Req1
763 rparams1 := &teststube2ap.E2StubSubsReqParams{}
764 rparams1.Init()
765 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
766 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
767 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
768 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
769
770 //Req2
771 rparams2 := &teststube2ap.E2StubSubsReqParams{}
772 rparams2.Init()
773 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
774 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
775
776 resp, _ := xapp.Subscription.QuerySubscriptions()
777 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
778 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300779 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200780
781 //Del1
782 waiter := rtmgrHttp.AllocNextEvent(false)
783 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
784 waiter.WaitResult(t)
785
786 xappConn1.RecvSubsDelResp(t, deltrans1)
787
788 //Del2
789 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
790 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
791 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
792 xappConn2.RecvSubsDelResp(t, deltrans2)
793 //Wait that subs is cleaned
794 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
795
796 xappConn1.TestMsgChanEmpty(t)
797 xappConn2.TestMsgChanEmpty(t)
798 e2termConn1.TestMsgChanEmpty(t)
799 mainCtrl.wait_registry_empty(t, 10)
800
801 mainCtrl.VerifyCounterValues(t)
802}
803
804//-----------------------------------------------------------------------------
805
806//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200807// TestSubReqAndSubDelOk
808//
809// stub stub
810// +-------+ +---------+ +---------+
811// | xapp | | submgr | | e2term |
812// +-------+ +---------+ +---------+
813// | | |
814// | SubReq | |
815// |------------->| |
816// | | |
817// | | SubReq |
818// | |------------->|
819// | | |
820// | | SubResp |
821// | |<-------------|
822// | | |
823// | SubResp | |
824// |<-------------| |
825// | | |
826// | | |
827// | SubDelReq | |
828// |------------->| |
829// | | |
830// | | SubDelReq |
831// | |------------->|
832// | | |
833// | | SubDelResp |
834// | |<-------------|
835// | | |
836// | SubDelResp | |
837// |<-------------| |
838//
839//-----------------------------------------------------------------------------
840func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200842
Anssi Mannila4abf1802021-01-28 13:06:46 +0200843 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200844 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
845 Counter{cSubReqFromXapp, 1},
846 Counter{cSubReqToE2, 1},
847 Counter{cSubRespFromE2, 1},
848 Counter{cSubRespToXapp, 1},
849 Counter{cSubDelReqFromXapp, 1},
850 Counter{cSubDelReqToE2, 1},
851 Counter{cSubDelRespFromE2, 1},
852 Counter{cSubDelRespToXapp, 1},
853 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200854
855 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200856 crereq, cremsg := e2termConn1.RecvSubsReq(t)
857 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200858 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200859
860 resp, _ := xapp.Subscription.QuerySubscriptions()
861 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
862 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300863 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200864
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200865 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200866 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200867
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200868 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200869 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200870
871 //Wait that subs is cleaned
872 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
873
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200874 xappConn1.TestMsgChanEmpty(t)
875 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200876 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200877 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200878
879 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200880}
881
882//-----------------------------------------------------------------------------
883// TestSubReqRetransmission
884//
885// stub stub
886// +-------+ +---------+ +---------+
887// | xapp | | submgr | | e2term |
888// +-------+ +---------+ +---------+
889// | | |
890// | SubReq | |
891// |------------->| |
892// | | |
893// | | SubReq |
894// | |------------->|
895// | | |
896// | SubReq | |
897// | (retrans) | |
898// |------------->| |
899// | | |
900// | | SubResp |
901// | |<-------------|
902// | | |
903// | SubResp | |
904// |<-------------| |
905// | | |
906// | [SUBS DELETE] |
907// | | |
908//
909//-----------------------------------------------------------------------------
910func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200911 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200912
913 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200914 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200915 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200916
917 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200918 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200919 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
920
Juha Hyttinen1683f912020-04-17 10:39:57 +0300921 // hack as there is no real way to see has message be handled.
922 // Previuos counter check just tells that is has been received by submgr
923 // --> artificial delay
924 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200925 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200926 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200927
928 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200929 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200930 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
931 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200932 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200933
934 //Wait that subs is cleaned
935 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
936
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200937 xappConn1.TestMsgChanEmpty(t)
938 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200939 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200940 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200941}
942
943//-----------------------------------------------------------------------------
944// TestSubDelReqRetransmission
945//
946// stub stub
947// +-------+ +---------+ +---------+
948// | xapp | | submgr | | e2term |
949// +-------+ +---------+ +---------+
950// | | |
951// | [SUBS CREATE] |
952// | | |
953// | | |
954// | SubDelReq | |
955// |------------->| |
956// | | |
957// | | SubDelReq |
958// | |------------->|
959// | | |
960// | SubDelReq | |
961// | (same sub) | |
962// | (same xid) | |
963// |------------->| |
964// | | |
965// | | SubDelResp |
966// | |<-------------|
967// | | |
968// | SubDelResp | |
969// |<-------------| |
970//
971//-----------------------------------------------------------------------------
972func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200973 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200974
975 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200976 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200977 crereq, cremsg := e2termConn1.RecvSubsReq(t)
978 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200979 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200980
981 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200983 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200984
985 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200986 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200987 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
988
Juha Hyttinen1683f912020-04-17 10:39:57 +0300989 // hack as there is no real way to see has message be handled.
990 // Previuos counter check just tells that is has been received by submgr
991 // --> artificial delay
992 <-time.After(1 * time.Second)
993
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200994 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200995 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200996
997 //Wait that subs is cleaned
998 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
999
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001000 xappConn1.TestMsgChanEmpty(t)
1001 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001002 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001003 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001004}
1005
1006//-----------------------------------------------------------------------------
1007// TestSubDelReqCollision
1008//
1009// stub stub
1010// +-------+ +---------+ +---------+
1011// | xapp | | submgr | | e2term |
1012// +-------+ +---------+ +---------+
1013// | | |
1014// | [SUBS CREATE] |
1015// | | |
1016// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001017// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001018// |------------->| |
1019// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001020// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001021// | |------------->|
1022// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001023// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001024// | (same sub) | |
1025// | (diff xid) | |
1026// |------------->| |
1027// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001028// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001029// | |<-------------|
1030// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001031// | SubDelResp 1 | |
1032// |<-------------| |
1033// | | |
1034// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001035// |<-------------| |
1036//
1037//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001038
Juha Hyttinenfa015662020-01-24 10:05:18 +02001039func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001040 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001041
1042 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001043 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001044 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1045 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001046 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001047
1048 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001049 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001050 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001051
Juha Hyttinen3944a222020-01-24 11:51:46 +02001052 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001053 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001054 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1055 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001056 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1057
Juha Hyttinen1683f912020-04-17 10:39:57 +03001058 // hack as there is no real way to see has message be handled.
1059 // Previuos counter check just tells that is has been received by submgr
1060 // --> artificial delay
1061 <-time.After(1 * time.Second)
1062
Juha Hyttinen3944a222020-01-24 11:51:46 +02001063 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001064 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001065
1066 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001067 xappConn1.RecvSubsDelResp(t, nil)
1068 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001069
1070 //Wait that subs is cleaned
1071 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1072
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001073 xappConn1.TestMsgChanEmpty(t)
1074 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001075 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001076 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001077}
1078
1079//-----------------------------------------------------------------------------
1080// TestSubReqAndSubDelOkTwoParallel
1081//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001082// stub stub stub
1083// +-------+ +-------+ +---------+ +---------+
1084// | xapp | | xapp | | submgr | | e2term |
1085// +-------+ +-------+ +---------+ +---------+
1086// | | | |
1087// | | | |
1088// | | | |
1089// | | SubReq1 | |
1090// | |------------->| |
1091// | | | |
1092// | | | SubReq1 |
1093// | | |------------->|
1094// | | | |
1095// | SubReq2 | |
1096// |------------------------>| |
1097// | | | |
1098// | | | SubReq2 |
1099// | | |------------->|
1100// | | | |
1101// | | | SubResp1 |
1102// | | |<-------------|
1103// | | SubResp1 | |
1104// | |<-------------| |
1105// | | | |
1106// | | | SubResp2 |
1107// | | |<-------------|
1108// | SubResp2 | |
1109// |<------------------------| |
1110// | | | |
1111// | | [SUBS 1 DELETE] |
1112// | | | |
1113// | | [SUBS 2 DELETE] |
1114// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001115//
1116//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001117
Juha Hyttinenfa015662020-01-24 10:05:18 +02001118func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001119 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001120
1121 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001122 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001123 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001124 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001125 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001126
1127 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001129 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001130
1131 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1132 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1133 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1134
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001135 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001136 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001137
1138 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001139 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001140 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001141
1142 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001143 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001144 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001145
1146 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001147 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001148 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1149 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001150 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001151 //Wait that subs is cleaned
1152 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1153
1154 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001155 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001156 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1157 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001158 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001159 //Wait that subs is cleaned
1160 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1161
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001162 xappConn1.TestMsgChanEmpty(t)
1163 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001164 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001165 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001166}
1167
1168//-----------------------------------------------------------------------------
1169// TestSameSubsDiffRan
1170// Same subscription to different RANs
1171//
1172// stub stub
1173// +-------+ +---------+ +---------+
1174// | xapp | | submgr | | e2term |
1175// +-------+ +---------+ +---------+
1176// | | |
1177// | | |
1178// | | |
1179// | SubReq(r1) | |
1180// |------------->| |
1181// | | |
1182// | | SubReq(r1) |
1183// | |------------->|
1184// | | |
1185// | | SubResp(r1) |
1186// | |<-------------|
1187// | | |
1188// | SubResp(r1) | |
1189// |<-------------| |
1190// | | |
1191// | SubReq(r2) | |
1192// |------------->| |
1193// | | |
1194// | | SubReq(r2) |
1195// | |------------->|
1196// | | |
1197// | | SubResp(r2) |
1198// | |<-------------|
1199// | | |
1200// | SubResp(r2) | |
1201// |<-------------| |
1202// | | |
1203// | [SUBS r1 DELETE] |
1204// | | |
1205// | [SUBS r2 DELETE] |
1206// | | |
1207//
1208//-----------------------------------------------------------------------------
1209func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001210 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001211
1212 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001213 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1214 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001215 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1216 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001218
1219 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001220 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1221 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001222 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1223 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001224 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001225
1226 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001227 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1228 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001229 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1230 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001231 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001232 //Wait that subs is cleaned
1233 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1234
1235 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001236 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1237 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001238 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1239 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001240 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001241 //Wait that subs is cleaned
1242 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1243
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001244 xappConn1.TestMsgChanEmpty(t)
1245 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001246 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001247 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001248}
1249
1250//-----------------------------------------------------------------------------
1251// TestSubReqRetryInSubmgr
1252//
1253// stub stub
1254// +-------+ +---------+ +---------+
1255// | xapp | | submgr | | e2term |
1256// +-------+ +---------+ +---------+
1257// | | |
1258// | SubReq | |
1259// |------------->| |
1260// | | |
1261// | | SubReq |
1262// | |------------->|
1263// | | |
1264// | | |
1265// | | SubReq |
1266// | |------------->|
1267// | | |
1268// | | SubResp |
1269// | |<-------------|
1270// | | |
1271// | SubResp | |
1272// |<-------------| |
1273// | | |
1274// | [SUBS DELETE] |
1275// | | |
1276//
1277//-----------------------------------------------------------------------------
1278
1279func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001280 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001281
1282 // Init counter check
1283 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1284 Counter{cSubReqFromXapp, 1},
1285 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001286 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001287 Counter{cSubReReqToE2, 1},
1288 Counter{cSubRespFromE2, 1},
1289 Counter{cSubRespToXapp, 1},
1290 Counter{cSubDelReqFromXapp, 1},
1291 Counter{cSubDelReqToE2, 1},
1292 Counter{cSubDelRespFromE2, 1},
1293 Counter{cSubDelRespToXapp, 1},
1294 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001295
1296 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001297 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001298
1299 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001300 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001301
1302 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001303 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1304 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001305
1306 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001307 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001308
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001309 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001310 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1311 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001312 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001313
1314 // Wait that subs is cleaned
1315 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1316
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001317 xappConn1.TestMsgChanEmpty(t)
1318 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001319 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001320 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001321
1322 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001323}
1324
1325//-----------------------------------------------------------------------------
1326// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1327//
1328// stub stub
1329// +-------+ +---------+ +---------+
1330// | xapp | | submgr | | e2term |
1331// +-------+ +---------+ +---------+
1332// | | |
1333// | SubReq | |
1334// |------------->| |
1335// | | |
1336// | | SubReq |
1337// | |------------->|
1338// | | |
1339// | | |
1340// | | SubReq |
1341// | |------------->|
1342// | | |
1343// | | SubDelReq |
1344// | |------------->|
1345// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001346// | | SubDelResp |
1347// | |<-------------|
1348// | | |
1349//
1350//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001351func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001352 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001353
1354 // Init counter check
1355 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1356 Counter{cSubReqFromXapp, 1},
1357 Counter{cSubReqToE2, 1},
1358 Counter{cSubReReqToE2, 1},
1359 Counter{cSubReqTimerExpiry, 2},
1360 Counter{cSubDelReqToE2, 1},
1361 Counter{cSubDelRespFromE2, 1},
1362 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001363
1364 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001365 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001366
1367 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001368 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001369
1370 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001371 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001372
1373 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001374 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1375 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001376
1377 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001378 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001379
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001380 xappConn1.TestMsgChanEmpty(t)
1381 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001382 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001383 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001384
1385 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001386}
1387
1388//-----------------------------------------------------------------------------
1389// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1390//
1391// stub stub
1392// +-------+ +---------+ +---------+
1393// | xapp | | submgr | | e2term |
1394// +-------+ +---------+ +---------+
1395// | | |
1396// | SubReq | |
1397// |------------->| |
1398// | | |
1399// | | SubReq |
1400// | |------------->|
1401// | | |
1402// | | |
1403// | | SubReq |
1404// | |------------->|
1405// | | |
1406// | | SubDelReq |
1407// | |------------->|
1408// | | |
1409// | | |
1410// | | SubDelReq |
1411// | |------------->|
1412// | | |
1413// | | |
1414//
1415//-----------------------------------------------------------------------------
1416
1417func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001418 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001419
1420 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1421 Counter{cSubReqFromXapp, 1},
1422 Counter{cSubReqToE2, 1},
1423 Counter{cSubReReqToE2, 1},
1424 Counter{cSubReqTimerExpiry, 2},
1425 Counter{cSubDelReqToE2, 1},
1426 Counter{cSubDelReReqToE2, 1},
1427 Counter{cSubDelReqTimerExpiry, 2},
1428 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001429
1430 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001431 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001432
1433 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001434 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001435
1436 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001437 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001438
1439 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001440 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001441
1442 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001443 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001444
1445 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001446 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001447
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001448 xappConn1.TestMsgChanEmpty(t)
1449 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001450 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001451 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001452
1453 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001454}
1455
1456//-----------------------------------------------------------------------------
1457// TestSubReqSubFailRespInSubmgr
1458//
1459// stub stub
1460// +-------+ +---------+ +---------+
1461// | xapp | | submgr | | e2term |
1462// +-------+ +---------+ +---------+
1463// | | |
1464// | SubReq | |
1465// |------------->| |
1466// | | |
1467// | | SubReq |
1468// | |------------->|
1469// | | |
1470// | | SubFail |
1471// | |<-------------|
1472// | | |
1473// | SubFail | |
1474// |<-------------| |
1475// | | |
1476//
1477//-----------------------------------------------------------------------------
1478
1479func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001480 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001481
1482 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1483 Counter{cSubReqFromXapp, 1},
1484 Counter{cSubReqToE2, 1},
1485 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001486 Counter{cSubFailToXapp, 1},
1487 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001488
1489 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001490 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001491
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001492 // E2t: Receive SubsReq and send SubsFail (first)
1493 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1494 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1495 fparams1.Set(crereq1)
1496 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1497
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001498 // Xapp: Receive SubsFail
1499 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1500
1501 // Wait that subs is cleaned
1502 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1503
1504 xappConn1.TestMsgChanEmpty(t)
1505 xappConn2.TestMsgChanEmpty(t)
1506 e2termConn1.TestMsgChanEmpty(t)
1507 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001508
1509 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001510}
1511
1512//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001513// TestSubDelReqRetryInSubmgr
1514//
1515// stub stub
1516// +-------+ +---------+ +---------+
1517// | xapp | | submgr | | e2term |
1518// +-------+ +---------+ +---------+
1519// | | |
1520// | [SUBS CREATE] |
1521// | | |
1522// | | |
1523// | SubDelReq | |
1524// |------------->| |
1525// | | |
1526// | | SubDelReq |
1527// | |------------->|
1528// | | |
1529// | | SubDelReq |
1530// | |------------->|
1531// | | |
1532// | | SubDelResp |
1533// | |<-------------|
1534// | | |
1535// | SubDelResp | |
1536// |<-------------| |
1537//
1538//-----------------------------------------------------------------------------
1539
1540func TestSubDelReqRetryInSubmgr(t *testing.T) {
1541
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001542 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001543
1544 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001545 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001546 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1547 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001548 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001549
1550 // Subs Delete
1551 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001552 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001553
1554 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001555 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001556
1557 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001558 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1559 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001560
1561 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001562 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001563
1564 // Wait that subs is cleaned
1565 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1566
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001567 xappConn1.TestMsgChanEmpty(t)
1568 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001569 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001570 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001571}
1572
1573//-----------------------------------------------------------------------------
1574// TestSubDelReqTwoRetriesNoRespInSubmgr
1575//
1576// stub stub
1577// +-------+ +---------+ +---------+
1578// | xapp | | submgr | | e2term |
1579// +-------+ +---------+ +---------+
1580// | | |
1581// | [SUBS CREATE] |
1582// | | |
1583// | | |
1584// | SubDelReq | |
1585// |------------->| |
1586// | | |
1587// | | SubDelReq |
1588// | |------------->|
1589// | | |
1590// | | SubDelReq |
1591// | |------------->|
1592// | | |
1593// | | |
1594// | SubDelResp | |
1595// |<-------------| |
1596//
1597//-----------------------------------------------------------------------------
1598
1599func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1600
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001601 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001602
1603 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001604 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001605 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1606 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001607 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001608
1609 // Subs Delete
1610 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001611 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001612
1613 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001614 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001615
1616 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001617 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001618
1619 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001620 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001621
1622 // Wait that subs is cleaned
1623 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1624
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001625 xappConn1.TestMsgChanEmpty(t)
1626 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001627 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001628 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001629}
1630
1631//-----------------------------------------------------------------------------
1632// TestSubDelReqSubDelFailRespInSubmgr
1633//
1634// stub stub
1635// +-------+ +---------+ +---------+
1636// | xapp | | submgr | | e2term |
1637// +-------+ +---------+ +---------+
1638// | | |
1639// | [SUBS CREATE] |
1640// | | |
1641// | | |
1642// | SubDelReq | |
1643// |------------->| |
1644// | | |
1645// | | SubDelReq |
1646// | |------------->|
1647// | | |
1648// | | SubDelFail |
1649// | |<-------------|
1650// | | |
1651// | SubDelResp | |
1652// |<-------------| |
1653// | | |
1654//
1655//-----------------------------------------------------------------------------
1656
1657func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001658 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001659
1660 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1661 Counter{cSubReqFromXapp, 1},
1662 Counter{cSubReqToE2, 1},
1663 Counter{cSubRespFromE2, 1},
1664 Counter{cSubRespToXapp, 1},
1665 Counter{cSubDelReqFromXapp, 1},
1666 Counter{cSubDelReqToE2, 1},
1667 Counter{cSubDelFailFromE2, 1},
1668 Counter{cSubDelRespToXapp, 1},
1669 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001670
1671 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001672 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001673 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1674 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001675 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001676
1677 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001678 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001679
1680 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001681 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1682 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001683
1684 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001685 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001686
1687 // Wait that subs is cleaned
1688 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1689
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001690 xappConn1.TestMsgChanEmpty(t)
1691 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001692 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001693 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001694
1695 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001696}
1697
1698//-----------------------------------------------------------------------------
1699// TestSubReqAndSubDelOkSameAction
1700//
1701// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001702// +-------+ +-------+ +---------+ +---------+
1703// | xapp2 | | xapp1 | | submgr | | e2term |
1704// +-------+ +-------+ +---------+ +---------+
1705// | | | |
1706// | | | |
1707// | | | |
1708// | | SubReq1 | |
1709// | |------------->| |
1710// | | | |
1711// | | | SubReq1 |
1712// | | |------------->|
1713// | | | SubResp1 |
1714// | | |<-------------|
1715// | | SubResp1 | |
1716// | |<-------------| |
1717// | | | |
1718// | SubReq2 | |
1719// |--------------------------->| |
1720// | | | |
1721// | SubResp2 | |
1722// |<---------------------------| |
1723// | | | |
1724// | | SubDelReq 1 | |
1725// | |------------->| |
1726// | | | |
1727// | | SubDelResp 1 | |
1728// | |<-------------| |
1729// | | | |
1730// | SubDelReq 2 | |
1731// |--------------------------->| |
1732// | | | |
1733// | | | SubDelReq 2 |
1734// | | |------------->|
1735// | | | |
1736// | | | SubDelReq 2 |
1737// | | |------------->|
1738// | | | |
1739// | SubDelResp 2 | |
1740// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001741//
1742//-----------------------------------------------------------------------------
1743func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001744 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001745
Anssi Mannila4abf1802021-01-28 13:06:46 +02001746 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001747 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1748 Counter{cSubReqFromXapp, 2},
1749 Counter{cSubReqToE2, 1},
1750 Counter{cSubRespFromE2, 1},
1751 Counter{cSubRespToXapp, 2},
1752 Counter{cMergedSubscriptions, 1},
1753 Counter{cUnmergedSubscriptions, 1},
1754 Counter{cSubDelReqFromXapp, 2},
1755 Counter{cSubDelReqToE2, 1},
1756 Counter{cSubDelRespFromE2, 1},
1757 Counter{cSubDelRespToXapp, 2},
1758 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001759
Juha Hyttinen3944a222020-01-24 11:51:46 +02001760 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001761 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001762 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001763 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001764 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1765 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001766 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001767
1768 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001769 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001770 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001771 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001773
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001774 resp, _ := xapp.Subscription.QuerySubscriptions()
1775 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1776 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001777 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001778
Juha Hyttinen3944a222020-01-24 11:51:46 +02001779 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001780 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001781 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001782
1783 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001784 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001785 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1786 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001787 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001788 //Wait that subs is cleaned
1789 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1790
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001791 xappConn1.TestMsgChanEmpty(t)
1792 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001793 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001794 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001795
1796 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001797}
1798
1799//-----------------------------------------------------------------------------
1800// TestSubReqAndSubDelOkSameActionParallel
1801//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001802// stub stub stub
1803// +-------+ +-------+ +---------+ +---------+
1804// | xapp2 | | xapp1 | | submgr | | e2term |
1805// +-------+ +-------+ +---------+ +---------+
1806// | | | |
1807// | | | |
1808// | | | |
1809// | | SubReq1 | |
1810// | |------------->| |
1811// | | | |
1812// | | | SubReq1 |
1813// | | |------------->|
1814// | SubReq2 | |
1815// |--------------------------->| |
1816// | | | SubResp1 |
1817// | | |<-------------|
1818// | | SubResp1 | |
1819// | |<-------------| |
1820// | | | |
1821// | SubResp2 | |
1822// |<---------------------------| |
1823// | | | |
1824// | | SubDelReq 1 | |
1825// | |------------->| |
1826// | | | |
1827// | | SubDelResp 1 | |
1828// | |<-------------| |
1829// | | | |
1830// | SubDelReq 2 | |
1831// |--------------------------->| |
1832// | | | |
1833// | | | SubDelReq 2 |
1834// | | |------------->|
1835// | | | |
1836// | | | SubDelReq 2 |
1837// | | |------------->|
1838// | | | |
1839// | SubDelResp 2 | |
1840// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001841//
1842//-----------------------------------------------------------------------------
1843func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001844 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001845
1846 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001847 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001848 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001849 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001850 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001851
1852 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001853 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001854 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001855 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001856
1857 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001858 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001859 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001860
1861 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001862 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001863
1864 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001865 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1866 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001867
1868 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001869 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001870 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1871 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001872 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001873
1874 //Wait that subs is cleaned
1875 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1876
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001877 xappConn1.TestMsgChanEmpty(t)
1878 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001879 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001880 mainCtrl.wait_registry_empty(t, 10)
1881}
1882
1883//-----------------------------------------------------------------------------
1884// TestSubReqAndSubDelNokSameActionParallel
1885//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001886// stub stub stub
1887// +-------+ +-------+ +---------+ +---------+
1888// | xapp2 | | xapp1 | | submgr | | e2term |
1889// +-------+ +-------+ +---------+ +---------+
1890// | | | |
1891// | | | |
1892// | | | |
1893// | | SubReq1 | |
1894// | |------------->| |
1895// | | | |
1896// | | | SubReq1 |
1897// | | |------------->|
1898// | SubReq2 | |
1899// |--------------------------->| |
1900// | | | SubFail1 |
1901// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001902// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001903// | | SubFail1 | |
1904// | |<-------------| |
1905// | | | |
1906// | SubFail2 | |
1907// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001908//
1909//-----------------------------------------------------------------------------
1910func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001911 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001912
1913 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001914 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001915 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001916 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001917
1918 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001919 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001920
1921 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001922 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001923 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001924 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001925 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001926 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001927
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001928 // E2t: send SubsFail (first)
1929 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1930 fparams1.Set(crereq1)
1931 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1932
Juha Hyttinen3944a222020-01-24 11:51:46 +02001933 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001934 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001935 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001936 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001937
1938 //Wait that subs is cleaned
1939 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1940
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001941 xappConn1.TestMsgChanEmpty(t)
1942 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001943 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001944 mainCtrl.wait_registry_empty(t, 10)
1945}
1946
1947//-----------------------------------------------------------------------------
1948// TestSubReqAndSubDelNoAnswerSameActionParallel
1949//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001950// stub stub stub
1951// +-------+ +-------+ +---------+ +---------+
1952// | xapp2 | | xapp1 | | submgr | | e2term |
1953// +-------+ +-------+ +---------+ +---------+
1954// | | | |
1955// | | | |
1956// | | | |
1957// | | SubReq1 | |
1958// | |------------->| |
1959// | | | |
1960// | | | SubReq1 |
1961// | | |------------->|
1962// | | SubReq2 | |
1963// |--------------------------->| |
1964// | | | |
1965// | | | SubReq1 |
1966// | | |------------->|
1967// | | | |
1968// | | | |
1969// | | | SubDelReq |
1970// | | |------------->|
1971// | | | |
1972// | | | SubDelResp |
1973// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001974//
1975//-----------------------------------------------------------------------------
1976func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001977 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001978
1979 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001980 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001981 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001982 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001983
Juha Hyttinen1683f912020-04-17 10:39:57 +03001984 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001985
1986 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001987 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001988 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001989 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001990 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001991 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001992
1993 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001994 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001995
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001996 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1997 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001998
1999 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002000 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002001
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002002 xappConn1.TestMsgChanEmpty(t)
2003 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002004 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002005 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002006}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002007
2008//----------------------------- Policy cases ---------------------------------
2009//-----------------------------------------------------------------------------
2010// TestSubReqPolicyAndSubDelOk
2011//
2012// stub stub
2013// +-------+ +---------+ +---------+
2014// | xapp | | submgr | | e2term |
2015// +-------+ +---------+ +---------+
2016// | | |
2017// | SubReq | |
2018// |------------->| |
2019// | | |
2020// | | SubReq |
2021// | |------------->|
2022// | | |
2023// | | SubResp |
2024// | |<-------------|
2025// | | |
2026// | SubResp | |
2027// |<-------------| |
2028// | | |
2029// | | |
2030// | SubDelReq | |
2031// |------------->| |
2032// | | |
2033// | | SubDelReq |
2034// | |------------->|
2035// | | |
2036// | | SubDelResp |
2037// | |<-------------|
2038// | | |
2039// | SubDelResp | |
2040// |<-------------| |
2041//
2042//-----------------------------------------------------------------------------
2043func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2044 CaseBegin("TestSubReqAndSubDelOk")
2045
2046 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2047 rparams1.Init()
2048 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2049 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2050
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002051 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2052 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002053 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2054 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002055 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002056
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002057 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002058 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002059
2060 //Wait that subs is cleaned
2061 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2062
2063 xappConn1.TestMsgChanEmpty(t)
2064 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002065 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002066 mainCtrl.wait_registry_empty(t, 10)
2067}
2068
2069//-----------------------------------------------------------------------------
2070// TestSubReqPolicyChangeAndSubDelOk
2071//
2072// stub stub
2073// +-------+ +---------+ +---------+
2074// | xapp | | submgr | | e2term |
2075// +-------+ +---------+ +---------+
2076// | | |
2077// | SubReq | |
2078// |------------->| |
2079// | | |
2080// | | SubReq |
2081// | |------------->|
2082// | | |
2083// | | SubResp |
2084// | |<-------------|
2085// | | |
2086// | SubResp | |
2087// |<-------------| |
2088// | | |
2089// | SubReq | |
2090// |------------->| |
2091// | | |
2092// | | SubReq |
2093// | |------------->|
2094// | | |
2095// | | SubResp |
2096// | |<-------------|
2097// | | |
2098// | SubResp | |
2099// |<-------------| |
2100// | | |
2101// | SubDelReq | |
2102// |------------->| |
2103// | | |
2104// | | SubDelReq |
2105// | |------------->|
2106// | | |
2107// | | SubDelResp |
2108// | |<-------------|
2109// | | |
2110// | SubDelResp | |
2111// |<-------------| |
2112//
2113//-----------------------------------------------------------------------------
2114
2115func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2116 CaseBegin("TestSubReqAndSubDelOk")
2117
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002118 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2119 rparams1.Init()
2120 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2121 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002122
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002123 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2124 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002125 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2126
2127 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002128 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002129 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2130 xappConn1.SendSubsReq(t, rparams1, cretrans)
2131
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002132 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2133 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002134 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2135 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002136 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002137
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002138 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002139 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002140
2141 //Wait that subs is cleaned
2142 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2143
2144 xappConn1.TestMsgChanEmpty(t)
2145 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002146 e2termConn1.TestMsgChanEmpty(t)
2147 mainCtrl.wait_registry_empty(t, 10)
2148}
2149
2150//-----------------------------------------------------------------------------
2151// TestSubReqAndSubDelOkTwoE2termParallel
2152//
2153// stub stub stub
2154// +-------+ +---------+ +---------+ +---------+
2155// | xapp | | submgr | | e2term1 | | e2term2 |
2156// +-------+ +---------+ +---------+ +---------+
2157// | | | |
2158// | | | |
2159// | | | |
2160// | SubReq1 | | |
2161// |------------->| | |
2162// | | | |
2163// | | SubReq1 | |
2164// | |------------->| |
2165// | | | |
2166// | SubReq2 | | |
2167// |------------->| | |
2168// | | | |
2169// | | SubReq2 | |
2170// | |---------------------------->|
2171// | | | |
2172// | | SubResp1 | |
2173// | |<-------------| |
2174// | SubResp1 | | |
2175// |<-------------| | |
2176// | | SubResp2 | |
2177// | |<----------------------------|
2178// | SubResp2 | | |
2179// |<-------------| | |
2180// | | | |
2181// | [SUBS 1 DELETE] | |
2182// | | | |
2183// | [SUBS 2 DELETE] | |
2184// | | | |
2185//
2186//-----------------------------------------------------------------------------
2187func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2188 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2189
2190 //Req1
2191 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2192 xappConn1.SendSubsReq(t, nil, cretrans1)
2193 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2194
2195 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2196 xappConn1.SendSubsReq(t, nil, cretrans2)
2197 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2198
2199 //Resp1
2200 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2201 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2202
2203 //Resp2
2204 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2205 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2206
2207 //Del1
2208 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2209 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2210 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2211 xappConn1.RecvSubsDelResp(t, deltrans1)
2212 //Wait that subs is cleaned
2213 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2214
2215 //Del2
2216 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2217 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2218 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2219 xappConn1.RecvSubsDelResp(t, deltrans2)
2220 //Wait that subs is cleaned
2221 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2222
2223 xappConn1.TestMsgChanEmpty(t)
2224 xappConn2.TestMsgChanEmpty(t)
2225 e2termConn1.TestMsgChanEmpty(t)
2226 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002227 mainCtrl.wait_registry_empty(t, 10)
2228}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002229
2230//-----------------------------------------------------------------------------
2231// TestSubReqInsertAndSubDelOk
2232//
2233// stub stub
2234// +-------+ +---------+ +---------+
2235// | xapp | | submgr | | e2term |
2236// +-------+ +---------+ +---------+
2237// | | |
2238// | SubReq | |
2239// |------------->| |
2240// | | |
2241// | | SubReq |
2242// | |------------->|
2243// | | |
2244// | | SubResp |
2245// | |<-------------|
2246// | | |
2247// | SubResp | |
2248// |<-------------| |
2249// | | |
2250// | | |
2251// | SubDelReq | |
2252// |------------->| |
2253// | | |
2254// | | SubDelReq |
2255// | |------------->|
2256// | | |
2257// | | SubDelResp |
2258// | |<-------------|
2259// | | |
2260// | SubDelResp | |
2261// |<-------------| |
2262//
2263//-----------------------------------------------------------------------------
2264func TestSubReqInsertAndSubDelOk(t *testing.T) {
2265 CaseBegin("TestInsertSubReqAndSubDelOk")
2266
2267 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2268 rparams1.Init()
2269 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2270 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2271
2272 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2273 e2termConn1.SendSubsResp(t, crereq, cremsg)
2274 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2275 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2276 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2277
2278 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2279 xappConn1.RecvSubsDelResp(t, deltrans)
2280
2281 //Wait that subs is cleaned
2282 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2283
2284 xappConn1.TestMsgChanEmpty(t)
2285 xappConn2.TestMsgChanEmpty(t)
2286 e2termConn1.TestMsgChanEmpty(t)
2287 mainCtrl.wait_registry_empty(t, 10)
2288}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002289
2290//-----------------------------------------------------------------------------
2291// TestSubReqRetransmissionWithSameSubIdDiffXid
2292//
2293// This case simulates case where xApp restarts and starts sending same
2294// subscription requests which have already subscribed successfully
2295
2296// stub stub
2297// +-------+ +---------+ +---------+
2298// | xapp | | submgr | | e2term |
2299// +-------+ +---------+ +---------+
2300// | | |
2301// | SubReq | |
2302// |------------->| |
2303// | | |
2304// | | SubReq |
2305// | |------------->|
2306// | | |
2307// | | SubResp |
2308// | |<-------------|
2309// | | |
2310// | SubResp | |
2311// |<-------------| |
2312// | | |
2313// | xApp restart | |
2314// | | |
2315// | SubReq | |
2316// | (retrans with same xApp generated subid but diff xid)
2317// |------------->| |
2318// | | |
2319// | SubResp | |
2320// |<-------------| |
2321// | | |
2322// | [SUBS DELETE] |
2323// | | |
2324//
2325//-----------------------------------------------------------------------------
2326func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2327 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2328
2329 //Subs Create
2330 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2331 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2332 e2termConn1.SendSubsResp(t, crereq, cremsg)
2333 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2334
2335 // xApp restart here
2336 // --> artificial delay
2337 <-time.After(1 * time.Second)
2338
2339 //Subs Create
2340 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2341 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2342
2343 //Subs Delete
2344 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2345 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2346 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2347 xappConn1.RecvSubsDelResp(t, deltrans)
2348
2349 //Wait that subs is cleaned
2350 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2351
2352 xappConn1.TestMsgChanEmpty(t)
2353 xappConn2.TestMsgChanEmpty(t)
2354 e2termConn1.TestMsgChanEmpty(t)
2355 mainCtrl.wait_registry_empty(t, 10)
2356}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002357
2358//-----------------------------------------------------------------------------
2359// TestSubReqNokAndSubDelOkWithRestartInMiddle
2360//
2361// stub stub
2362// +-------+ +---------+ +---------+
2363// | xapp | | submgr | | e2term |
2364// +-------+ +---------+ +---------+
2365// | | |
2366// | SubReq | |
2367// |------------->| |
2368// | | |
2369// | | SubReq |
2370// | |------------->|
2371// | | |
2372// | | SubResp |
2373// | <----|
2374// | |
2375// | Submgr restart |
2376// | |
2377// | | |
2378// | | SubDelReq |
2379// | |------------->|
2380// | | |
2381// | | SubDelResp |
2382// | |<-------------|
2383// | | |
2384//
2385//-----------------------------------------------------------------------------
2386
2387func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2388 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2389
Anssi Mannilac92b4212020-12-07 14:59:34 +02002390 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2391 xappConn1.SendSubsReq(t, nil, nil)
2392 e2termConn1.RecvSubsReq(t)
2393 mainCtrl.SetResetTestFlag(t, false)
2394
2395 resp, _ := xapp.Subscription.QuerySubscriptions()
2396 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002397 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002398 e2SubsId := uint32(resp[0].SubscriptionID)
2399 t.Logf("e2SubsId = %v", e2SubsId)
2400
archaggeafbf95f2021-04-14 08:54:05 +03002401 mainCtrl.SimulateRestart(t)
2402 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002403
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002404 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002405 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2406 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2407
2408 // Wait that subs is cleaned
2409 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2410
2411 xappConn1.TestMsgChanEmpty(t)
2412 xappConn2.TestMsgChanEmpty(t)
2413 e2termConn1.TestMsgChanEmpty(t)
2414 mainCtrl.wait_registry_empty(t, 10)
2415}
2416
2417//-----------------------------------------------------------------------------
2418// TestSubReqAndSubDelOkWithRestartInMiddle
2419//
2420// stub stub
2421// +-------+ +---------+ +---------+
2422// | xapp | | submgr | | e2term |
2423// +-------+ +---------+ +---------+
2424// | | |
2425// | SubReq | |
2426// |------------->| |
2427// | | |
2428// | | SubReq |
2429// | |------------->|
2430// | | |
2431// | | SubResp |
2432// | |<-------------|
2433// | | |
2434// | SubResp | |
2435// |<-------------| |
2436// | | |
2437// | |
2438// | Submgr restart |
2439// | |
2440// | SubDelReq | |
2441// |------------->| |
2442// | | |
2443// | | SubDelReq |
2444// | |------------->|
2445// | | |
2446// | | SubDelResp |
2447// | |<-------------|
2448// | | |
2449// | SubDelResp | |
2450// |<-------------| |
2451//
2452//-----------------------------------------------------------------------------
2453
2454func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2455 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2456
2457 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2458 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2459 e2termConn1.SendSubsResp(t, crereq, cremsg)
2460 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2461
2462 // Check subscription
2463 resp, _ := xapp.Subscription.QuerySubscriptions()
2464 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2465 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002466 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002467
2468 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002469 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002470
Anssi Mannila54838ed2021-11-19 11:25:01 +02002471 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2472 // That needs to be completed before successful subscription query is possible
2473 <-time.After(time.Second * 1)
2474
Anssi Mannilac92b4212020-12-07 14:59:34 +02002475 // Check that subscription is restored correctly after restart
2476 resp, _ = xapp.Subscription.QuerySubscriptions()
2477 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2478 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002479 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002480
2481 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2482 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2483 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2484 xappConn1.RecvSubsDelResp(t, deltrans)
2485
2486 //Wait that subs is cleaned
2487 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2488
2489 xappConn1.TestMsgChanEmpty(t)
2490 xappConn2.TestMsgChanEmpty(t)
2491 e2termConn1.TestMsgChanEmpty(t)
2492 mainCtrl.wait_registry_empty(t, 10)
2493}
2494
2495//-----------------------------------------------------------------------------
2496// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2497//
2498// stub stub
2499// +-------+ +-------+ +---------+ +---------+
2500// | xapp2 | | xapp1 | | submgr | | e2term |
2501// +-------+ +-------+ +---------+ +---------+
2502// | | | |
2503// | | | |
2504// | | | |
2505// | | SubReq1 | |
2506// | |------------->| |
2507// | | | |
2508// | | | SubReq1 |
2509// | | |------------->|
2510// | | | SubResp1 |
2511// | | |<-------------|
2512// | | SubResp1 | |
2513// | |<-------------| |
2514// | | | |
2515// | |
2516// | submgr restart |
2517// | |
2518// | | | |
2519// | | | |
2520// | SubReq2 | |
2521// |--------------------------->| |
2522// | | | |
2523// | SubResp2 | |
2524// |<---------------------------| |
2525// | | | |
2526// | | SubDelReq 1 | |
2527// | |------------->| |
2528// | | | |
2529// | | SubDelResp 1 | |
2530// | |<-------------| |
2531// | | | |
2532// | | | |
2533// | |
2534// | submgr restart |
2535// | |
2536// | | | |
2537// | SubDelReq 2 | |
2538// |--------------------------->| |
2539// | | | |
2540// | | | SubDelReq 2 |
2541// | | |------------->|
2542// | | | |
2543// | | | SubDelReq 2 |
2544// | | |------------->|
2545// | | | |
2546// | SubDelResp 2 | |
2547// |<---------------------------| |
2548//
2549//-----------------------------------------------------------------------------
2550
2551func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2552 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2553
2554 //Req1
2555 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2556 rparams1.Init()
2557 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2558 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2559 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2560 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2561
2562 //Req2
2563 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2564 rparams2.Init()
2565 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2566 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2567
2568 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002569 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002570 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2571 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002572 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002573
2574 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002575 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002576
Anssi Mannila54838ed2021-11-19 11:25:01 +02002577 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2578 // That needs to be completed before successful subscription query is possible
2579 <-time.After(time.Second * 1)
2580
Anssi Mannilac92b4212020-12-07 14:59:34 +02002581 // Check that subscription is restored correctly after restart
2582 resp, _ = xapp.Subscription.QuerySubscriptions()
2583 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2584 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002585 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002586
2587 //Del1
2588 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2589 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2590 xappConn1.RecvSubsDelResp(t, deltrans1)
2591 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2592
2593 mainCtrl.SimulateRestart(t)
2594 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2595
Anssi Mannila54838ed2021-11-19 11:25:01 +02002596 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2597 // Submgr need be ready before successful subscription deletion is possible
2598 <-time.After(time.Second * 1)
2599
Anssi Mannilac92b4212020-12-07 14:59:34 +02002600 //Del2
2601 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2602 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2603
2604 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2605 xappConn2.RecvSubsDelResp(t, deltrans2)
2606
2607 //Wait that subs is cleaned
2608 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2609
2610 xappConn1.TestMsgChanEmpty(t)
2611 xappConn2.TestMsgChanEmpty(t)
2612 e2termConn1.TestMsgChanEmpty(t)
2613 mainCtrl.wait_registry_empty(t, 10)
2614}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002615
archaggeafbf95f2021-04-14 08:54:05 +03002616//*****************************************************************************
2617// REST interface test cases
2618//*****************************************************************************
2619
Anssi Mannila47518ae2021-04-16 09:27:07 +03002620//-----------------------------------------------------------------------------
2621// Test debug GET and POST requests
2622//
2623// curl
2624// +-------+ +---------+
2625// | user | | submgr |
2626// +-------+ +---------+
2627// | |
2628// | GET/POST Req |
2629// |------------->|
2630// | Resp |
2631// |<-------------|
2632// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002633func TestGetSubscriptions(t *testing.T) {
2634
2635 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2636}
2637
2638func TestGetSymptomData(t *testing.T) {
2639
2640 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2641}
2642
2643func TestPostdeleteSubId(t *testing.T) {
2644
2645 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2646}
2647
2648func TestPostEmptyDb(t *testing.T) {
2649
2650 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2651}
archaggeafbf95f2021-04-14 08:54:05 +03002652
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002653func TestGetRestSubscriptions(t *testing.T) {
2654
2655 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2656}
2657
archaggeafbf95f2021-04-14 08:54:05 +03002658//-----------------------------------------------------------------------------
2659// TestRESTSubReqAndRouteNok
2660//
2661// stub stub
2662// +-------+ +---------+ +---------+
2663// | xapp | | submgr | | rtmgr |
2664// +-------+ +---------+ +---------+
2665// | | |
2666// | RESTSubReq | |
2667// |---------------->| |
2668// | | |
2669// | RESTSubResp | |
2670// |<----------------| |
2671// | | RouteCreate |
2672// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03002673// | | RouteCreate |
2674// | | status:400 |
2675// | |(Bad request) |
2676// | |<-------------|
2677// | RESTNotif | |
2678// |<----------------| |
2679// | | |
2680// | [SUBS INT DELETE] |
2681// | | |
2682// | RESTSubDelReq | |
2683// |---------------->| |
2684// | RESTSubDelResp | |
2685// |<----------------| |
2686//
2687//-----------------------------------------------------------------------------
2688func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002689
2690 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002691 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002692 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002693 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002694 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002695 Counter{cRestSubDelReqFromXapp, 1},
2696 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002697 })
2698
2699 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002700
Markku Virtanenda34eec2021-05-20 08:22:04 +00002701 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2702 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002703 newSubsId := mainCtrl.get_registry_next_subid(t)
2704
2705 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002706 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002707 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002708 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002709 waiter.WaitResult(t)
2710
archaggeafbf95f2021-04-14 08:54:05 +03002711 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002712 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002713
2714 // Del
2715 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2716
2717 // Wait that subs is cleaned
2718 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2719 waitSubsCleanup(t, e2SubsId, 10)
2720 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002721 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002722}
2723
Anssi Mannila27385172021-12-22 09:41:54 +02002724//-----------------------------------------------------------------------------
2725// TestRESTSubReqAndRouteUpdateNok
2726//
2727// stub stub stub stub
2728// +-------+ +-------+ +---------+ +---------+ +---------+
2729// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
2730// +-------+ +-------+ +---------+ +---------+ +---------+
2731// | | | | |
2732// | RESTSubReq1 | | |
2733// |------------------------>| | |
2734// | RESTSubResp2 | | |
2735// |<------------------------| | |
2736// | | | | |
2737// | | | RouteCreate | |
2738// | | |------------->| |
2739// | | | CreateResp | |
2740// | | |<-------------| |
2741// | | | SubReq | |
2742// | | |---------------------------->|
2743// | | | SubResp | |
2744// | | |<----------------------------|
2745// | RESTNotif1 | | |
2746// |<------------------------| | |
2747// | | | | |
2748// | | RESTSubReq2 | | |
2749// | |------------>| | |
2750// | | RESTSubResp2| | |
2751// | |<------------| | |
2752// | | | RouteUpdate | |
2753// | | |------------->| |
2754// | | | RouteUpdate | |
2755// | | | status:400 | |
2756// | | |(Bad request) | |
2757// | | |<-------------| |
2758// | | RESTNotif2(unsuccessful) | |
2759// | |<------------| | |
2760// | | | | |
2761// | [SUBS INT DELETE] | |
2762// | | | | |
2763// | RESTSubDelReq1 | | |
2764// |------------------------>| | |
2765// | RESTSubDelResp1 | | |
2766// |<------------------------| | |
2767// | | | | |
2768// | | | [SUBS DELETE] |
2769//
2770//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03002771func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002772
2773 //Init counter check
2774 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002775 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002776 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002777 Counter{cSubReqToE2, 1},
2778 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002779 Counter{cRestSubNotifToXapp, 1},
2780 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002781 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002782 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002783 Counter{cSubDelReqToE2, 1},
2784 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002785 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002786 })
2787
2788 var params *teststube2ap.RESTSubsReqParams = nil
2789
Anssi Mannila27385172021-12-22 09:41:54 +02002790 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03002791 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2792
2793 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2794
2795 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2796 waiter := rtmgrHttp.AllocNextEvent(false)
2797 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002798 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002799 params.SetMeid("RAN_NAME_1")
2800 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002801 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002802 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002803 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03002804 xappConn2.WaitRESTNotification(t, restSubId2)
2805
2806 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2807
2808 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002809 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03002810
2811 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2812 //Wait that subs is cleaned
2813 waitSubsCleanup(t, e2SubsId, 10)
2814
2815 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002816 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002817}
2818
Anssi Mannila27385172021-12-22 09:41:54 +02002819//-----------------------------------------------------------------------------
2820// TestRESTSubDelReqAndRouteDeleteNok
2821//
2822// stub stub stub
2823// +-------+ +---------+ +---------+ +---------+
2824// | xapp | | submgr | | rtmgr | | e2term |
2825// +-------+ +---------+ +---------+ +---------+
2826// | | | |
2827// | RESTSubReq | | |
2828// |---------------->| | |
2829// | | | |
2830// | RESTSubResp | | |
2831// |<----------------| | |
2832// | | SubReq | |
2833// | |---------------------------->|
2834// | | SubResp | |
2835// | |<----------------------------|
2836// | RESTNotif | | |
2837// |<----------------| | |
2838// | | | |
2839// | | | |
2840// | RESTSubDelReq | | |
2841// |---------------->| | |
2842// | RESTSubDelResp | | |
2843// |<----------------| | |
2844// | | SubSelReq | |
2845// | |---------------------------->|
2846// | | SubSelResp | |
2847// | |<----------------------------|
2848// | | RouteDelete | |
2849// | |------------->| |
2850// | | Routedelete | |
2851// | | status:400 | |
2852// | |(Bad request) | |
2853// | |<-------------| |
2854//
2855//-----------------------------------------------------------------------------
2856
archaggeafbf95f2021-04-14 08:54:05 +03002857func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002858
2859 // Init counter check
2860 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002861 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002862 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002863 Counter{cSubReqToE2, 1},
2864 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002865 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002866 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002867 Counter{cRouteDeleteFail, 1},
2868 Counter{cSubDelReqToE2, 1},
2869 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002870 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002871 })
2872
2873 var params *teststube2ap.RESTSubsReqParams = nil
2874
2875 //Subs Create
2876 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2877
2878 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2879
2880 waiter := rtmgrHttp.AllocNextEvent(false)
2881 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2882 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2883 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2884 waiter.WaitResult(t)
2885
2886 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002887 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002888 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002889}
2890
Anssi Mannila27385172021-12-22 09:41:54 +02002891//-----------------------------------------------------------------------------
2892// TestRESTSubMergeDelAndRouteUpdateNok
2893//
2894// stub stub stub stub
2895// +-------+ +-------+ +---------+ +---------+ +---------+
2896// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
2897// +-------+ +-------+ +---------+ +---------+ +---------+
2898// | | | | |
2899// | RESTSubReq1 | | |
2900// |------------------------>| | |
2901// | RESTSubResp2 | | |
2902// |<------------------------| | |
2903// | | | | |
2904// | | | RouteCreate | |
2905// | | |------------->| |
2906// | | | CreateResp | |
2907// | | |<-------------| |
2908// | | | SubReq | |
2909// | | |---------------------------->|
2910// | | | SubResp | |
2911// | | |<----------------------------|
2912// | RESTNotif1 | | |
2913// |<------------------------| | |
2914// | | | | |
2915// | | RESTSubReq2 | | |
2916// | |------------>| | |
2917// | | RESTSubResp2| | |
2918// | |<------------| | |
2919// | | | RouteCreate | |
2920// | | |------------->| |
2921// | | | CreateResp | |
2922// | | |<-------------| |
2923// | | | SubReq | |
2924// | | |---------------------------->|
2925// | | | SubResp | |
2926// | | |<----------------------------|
2927// | | RESTNotif2 | | |
2928// | |<------------| | |
2929// | | | | |
2930// | [SUBS INT DELETE] | |
2931// | | | | |
2932// | RESTSubDelReq1 | | |
2933// |------------------------>| | |
2934// | RESTSubDelResp1 | | |
2935// |<------------------------| | |
2936// | | | SubDelReq | |
2937// | | |---------------------------->|
2938// | | | SubDelResp | |
2939// | | |<----------------------------|
2940// | | | RouteUpdate | |
2941// | | |------------->| |
2942// | | | RouteUpdate | |
2943// | | | status:400 | |
2944// | | |(Bad request) | |
2945// | | |<-------------| |
2946// | | | | |
2947// | | RESTSubDelReq2 | |
2948// | |------------>| | |
2949// | | RESTSubDelResp2 | |
2950// | |<------------| | |
2951// | | | SubDelReq | |
2952// | | |---------------------------->|
2953// | | | SubdelResp | |
2954// | | |<----------------------------|
2955// | | | RouteDelete | |
2956// | | |------------->| |
2957// | | | Deleteresp | |
2958// | | |<-------------| |
2959
2960//-----------------------------------------------------------------------------
2961
archaggeafbf95f2021-04-14 08:54:05 +03002962func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002963
2964 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002965 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002966 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002967 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002968 Counter{cSubReqToE2, 1},
2969 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002970 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002971 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002972 Counter{cRouteDeleteUpdateFail, 1},
2973 Counter{cSubDelReqToE2, 1},
2974 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002975 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002976 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002977 })
2978
2979 var params *teststube2ap.RESTSubsReqParams = nil
2980
2981 //Subs Create
2982 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2983
2984 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2985 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2986
2987 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2988
2989 //Del1, this shall fail on rtmgr side
2990 waiter := rtmgrHttp.AllocNextEvent(false)
2991 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2992 waiter.WaitResult(t)
2993
2994 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2995
2996 //Del2
2997 deleteXapp2Subscription(t, &restSubId2)
2998
2999 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003000 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003001 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003002}
3003
3004//-----------------------------------------------------------------------------
3005// TestRESTSubReqRetransmission
3006//
3007// stub stub
3008// +-------+ +---------+ +---------+
3009// | xapp | | submgr | | e2term |
3010// +-------+ +---------+ +---------+
3011// | | |
3012// | RESTSubReq1 | |
3013// |---------------->| |
3014// | | |
3015// | RESTSubResp | |
3016// |<----------------| |
3017// | | SubReq1 |
3018// | |------------->|
3019// | | |
3020// | RESTSubReq2 | |
3021// | (retrans) | |
3022// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003023// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003024// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003025// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003026// | | SubResp1 |
3027// | |<-------------|
3028// | RESTNotif1 | |
3029// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003030// | | |
3031// | [SUBS DELETE] |
3032// | | |
3033//
3034//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003035
archaggeafbf95f2021-04-14 08:54:05 +03003036func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003037
3038 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003039 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003040 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003041 Counter{cSubReqToE2, 1},
3042 Counter{cSubRespFromE2, 1},
3043 Counter{cRestSubNotifToXapp, 1},
3044 Counter{cRestSubDelReqFromXapp, 1},
3045 Counter{cSubDelReqToE2, 1},
3046 Counter{cSubDelRespFromE2, 1},
3047 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003048 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003049 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003050 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3051 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3052
3053 // Subs Create
3054 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003055
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003056 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003057 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003058
Anssi Mannilab43397e2021-11-16 12:06:16 +02003059 xappConn1.SendRESTSubsReq(t, params)
3060 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003061
Anssi Mannilab43397e2021-11-16 12:06:16 +02003062 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003063
3064 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003065 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003066 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3067 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003068
Anssi Mannilab43397e2021-11-16 12:06:16 +02003069 e2SubsId := <-xappConn1.ListedRESTNotifications
3070
3071 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003072
3073 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003074 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003075 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3076 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3077
Anssi Mannilab43397e2021-11-16 12:06:16 +02003078 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003079
3080 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003081 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003082}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003083
Markku Virtanen42723e22021-06-15 10:09:23 +03003084//-----------------------------------------------------------------------------
3085// stub stub stub
3086// +-------+ +---------+ +---------+ +---------+
3087// | xapp | | submgr | | e2term | | rtmgr |
3088// +-------+ +---------+ +---------+ +---------+
3089// | | | |
3090// | RESTSubReq | | |
3091// |---------------->| | |
3092// | RESTSubResp | | |
3093// |<----------------| | |
3094// | | RouteCreate | |
3095// | |--------------------------->|
3096// | | RouteResponse| |
3097// | |<---------------------------| // The order of these events may vary
3098// | | SubReq | |
3099// | |------------->| | // The order of these events may vary
3100// | | SubResp | |
3101// | |<-------------| |
3102// | RESTNotif1 | | |
3103// |<----------------| | |
3104// | RESTSubReq | | |
3105// | [RETRANS1] | | |
3106// |---------------->| | |
3107// | RESTNotif1 | | |
3108// |<----------------| | |
3109// | RESTSubReq | | |
3110// | [RETRANS2] | | |
3111// |---------------->| | |
3112// | RESTNotif1 | | |
3113// |<----------------| | |
3114// | RESTSubDelReq | | |
3115// |---------------->| | |
3116// | | SubDelReq | |
3117// | |------------->| |
3118// | RESTSubDelResp| | |
3119// |<----------------| | |
3120// | | SubDelResp | |
3121// | |<-------------| |
3122// | | | |
3123//
3124//-----------------------------------------------------------------------------
3125
3126func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003127
3128 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3129 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003130 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003131 Counter{cRestSubRespToXapp, 3},
3132 Counter{cSubReqToE2, 1},
3133 Counter{cSubRespFromE2, 1},
3134 Counter{cRestSubNotifToXapp, 3},
3135 Counter{cRestSubDelReqFromXapp, 1},
3136 Counter{cSubDelReqToE2, 1},
3137 Counter{cSubDelRespFromE2, 1},
3138 Counter{cRestSubDelRespToXapp, 1},
3139 })
3140
3141 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3142
3143 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3144
3145 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3146
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003147 mainCtrl.WaitOngoingRequestMapEmpty()
3148
Markku Virtanen42723e22021-06-15 10:09:23 +03003149 //1.st resend
3150 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3151
3152 assert.Equal(t, restSubId_resend, restSubId)
3153
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003154 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003155
3156 //2.nd resend
3157 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3158
3159 assert.Equal(t, restSubId_resend2, restSubId)
3160
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003161 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003162
3163 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3164
3165 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003166 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003167 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003168}
3169
3170//-----------------------------------------------------------------------------
3171// stub stub stub
3172// +-------+ +---------+ +---------+ +---------+
3173// | xapp | | submgr | | e2term | | rtmgr |
3174// +-------+ +---------+ +---------+ +---------+
3175// | | | |
3176// | RESTSubReq | | |
3177// |---------------->| | |
3178// | RESTSubResp | | |
3179// |<----------------| | |
3180// | | RouteCreate | |
3181// | |--------------------------->|
3182// | | RouteResponse| |
3183// | |<---------------------------| // The order of these events may vary
3184// | | SubReq | |
3185// | |------------->| | // The order of these events may vary
3186// | | SubResp | |
3187// | |<-------------| |
3188// | RESTNotif1 | | |
3189// |<----------------| | |
3190// | RESTSubReq | | |
3191// | [RETRANS, with RESTsubsId] | |
3192// |---------------->| | |
3193// | RESTNotif1 | | |
3194// |<----------------| | |
3195// | RESTSubReq | | |
3196// | [RETRANS, without RESTsubsId] | |
3197// |---------------->| | |
3198// | RESTNotif1 | | |
3199// |<----------------| | |
3200// | RESTSubDelReq | | |
3201// |---------------->| | |
3202// | | SubDelReq | |
3203// | |------------->| |
3204// | RESTSubDelResp| | |
3205// |<----------------| | |
3206// | | SubDelResp | |
3207// | |<-------------| |
3208// | | | |
3209//
3210//-----------------------------------------------------------------------------
3211func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003212
3213 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3214 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003215 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003216 Counter{cRestSubRespToXapp, 3},
3217 Counter{cSubReqToE2, 1},
3218 Counter{cSubRespFromE2, 1},
3219 Counter{cRestSubNotifToXapp, 3},
3220 Counter{cRestSubDelReqFromXapp, 1},
3221 Counter{cSubDelReqToE2, 1},
3222 Counter{cSubDelRespFromE2, 1},
3223 Counter{cRestSubDelRespToXapp, 1},
3224 })
3225
3226 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3227
3228 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3229
3230 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3231
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003232 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003233
3234 //1.st resend with subscription ID
3235 params.SetSubscriptionID(&restSubId)
3236 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3237
3238 assert.Equal(t, restSubId_resend, restSubId)
3239
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003240 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003241
3242 //2.nd resend without subscription ID (faking app restart)
3243 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3244 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3245
3246 assert.Equal(t, restSubId_resend2, restSubId)
3247
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003248 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003249
3250 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3251
3252 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003253 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003254 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003255}
3256
3257//-----------------------------------------------------------------------------
3258// stub stub stub
3259// +-------+ +---------+ +---------+ +---------+
3260// | xapp | | submgr | | e2term | | rtmgr |
3261// +-------+ +---------+ +---------+ +---------+
3262// | | | |
3263// | RESTSubReq | | |
3264// |---------------->| | |
3265// | RESTSubResp | | |
3266// |<----------------| | |
3267// | | RouteCreate | |
3268// | |--------------------------->|
3269// | | RouteResponse| |
3270// | |<---------------------------|
3271// | | SubReq | |
3272// | |------------->| |
3273// | | SubResp | |
3274// | |<-------------| |
3275// | RESTNotif1 | | |
3276// |<----------------| | |
3277// | RESTSubReq | | |
3278// | [with RestSUbsId + one additional e2 subDetail]
3279// |---------------->| | |
3280// | RESTNotif1 | | |
3281// | [for initial e2 subDetail] | |
3282// |<----------------| | |
3283// | | RouteCreate | |
3284// | |--------------------------->|
3285// | | RouteResponse| |
3286// | |<---------------------------|
3287// | | SubReq | |
3288// | |------------->| |
3289// | | SubResp | |
3290// | |<-------------| |
3291// | RESTNotif1 | | |
3292// |<----------------| | |
3293// | RESTSubReq | | |
3294// | [with RESTsubsId initial request] |
3295// |---------------->| | |
3296// | RESTNotif1 | | |
3297// |<----------------| | |
3298// | RESTSubDelReq | | |
3299// |---------------->| | |
3300// | RESTSubDelResp| | |
3301// |<----------------| | |
3302// | | SubDelReq | |
3303// | |------------->| |
3304// | | SubDelResp | |
3305// | |<-------------| |
3306// | | SubDelReq | |
3307// | |------------->| |
3308// | | SubDelResp | |
3309// | |<-------------| |
3310// | | | |
3311//
3312//-----------------------------------------------------------------------------
3313
3314func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003315
3316 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3317 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003318 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003319 Counter{cRestSubRespToXapp, 3},
3320 Counter{cSubReqToE2, 2},
3321 Counter{cSubRespFromE2, 2},
3322 Counter{cRestSubNotifToXapp, 4},
3323 Counter{cRestSubDelReqFromXapp, 1},
3324 Counter{cSubDelReqToE2, 2},
3325 Counter{cSubDelRespFromE2, 2},
3326 Counter{cRestSubDelRespToXapp, 1},
3327 })
3328
3329 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3330
3331 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3332
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003333 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003334
3335 // Send modified requst, this time with e2 subscriptions.
3336 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3337 params2.SetSubscriptionID(&restSubId)
3338
3339 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003340 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003341 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3342 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003343 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3344 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003345
3346 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3347
Markku Virtanen2b512b62021-07-30 12:04:00 +00003348 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003349 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3350 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3351 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3352 assert.NotEqual(t, e2SubsId2, 0)
3353
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003354 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003355
3356 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3357 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3358 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003359 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003360 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3361 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3362 assert.Equal(t, restSubId_resend, restSubId_resend2)
3363
Markku Virtanen2b512b62021-07-30 12:04:00 +00003364 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3365 assert.Equal(t, e2SubsId, e2SubsId1)
3366
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003367 mainCtrl.WaitOngoingRequestMapEmpty()
3368
Markku Virtanen42723e22021-06-15 10:09:23 +03003369 // Delete both e2 subscriptions
3370 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3371 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3372 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3373
3374 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003375 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003376 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003377}
3378
3379//-----------------------------------------------------------------------------
3380// stub stub stub
3381// +-------+ +---------+ +---------+ +---------+
3382// | xapp | | submgr | | e2term | | rtmgr |
3383// +-------+ +---------+ +---------+ +---------+
3384// | | | |
3385// | RESTSubReq | | |
3386// |---------------->| | |
3387// | RESTSubResp | | |
3388// |<----------------| | |
3389// | | RouteCreate | |
3390// | |--------------------------->|
3391// | | RouteResponse| |
3392// | |<---------------------------|
3393// | | SubReq | |
3394// | |------------->| |
3395// | | SubResp | |
3396// | |<-------------| |
3397// | RESTNotif1 | | |
3398// |<----------------| | |
3399// | RESTSubReq | | |
3400// | [with RestSUbsId + one additional e2 subDetail]
3401// |---------------->| | |
3402// | RESTNotif1 | | |
3403// | [for initial e2 subDetail] | |
3404// |<----------------| | |
3405// | | RouteCreate | |
3406// | |--------------------------->|
3407// | | RouteResponse| |
3408// | |<---------------------------|
3409// | | SubReq | |
3410// | |------------->| |
3411// | | SubResp | |
3412// | |<-------------| |
3413// | RESTNotif1 | | |
3414// |<----------------| | |
3415// | RESTSubReq | | |
3416// | [without RESTsubsId initial request] |
3417// |---------------->| | |
3418// | RESTNotif1 | | |
3419// |<----------------| | |
3420// | RESTSubDelReq | | |
3421// |---------------->| | |
3422// | RESTSubDelResp| | |
3423// |<----------------| | |
3424// | | SubDelReq | |
3425// | |------------->| |
3426// | | SubDelResp | |
3427// | |<-------------| |
3428// | | SubDelReq | |
3429// | |------------->| |
3430// | | SubDelResp | |
3431// | |<-------------| |
3432// | | | |
3433//
3434//-----------------------------------------------------------------------------
3435
3436func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003437
3438 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3439 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003440 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003441 Counter{cRestSubRespToXapp, 3},
3442 Counter{cSubReqToE2, 2},
3443 Counter{cSubRespFromE2, 2},
3444 Counter{cRestSubNotifToXapp, 4},
3445 Counter{cRestSubDelReqFromXapp, 1},
3446 Counter{cSubDelReqToE2, 2},
3447 Counter{cSubDelRespFromE2, 2},
3448 Counter{cRestSubDelRespToXapp, 1},
3449 })
3450
3451 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3452
3453 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3454
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003455 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003456
Anssi Mannila21782182021-12-10 10:56:02 +02003457 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003458 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3459 params2.SetSubscriptionID(&restSubId)
3460
3461 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003462 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003463 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3464 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3465
Markku Virtanen2b512b62021-07-30 12:04:00 +00003466 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3467 assert.Equal(t, e2SubsId, e2SubsId1)
3468 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3469 xappConn1.DecrementRequestCount()
3470
Markku Virtanen42723e22021-06-15 10:09:23 +03003471 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3472
3473 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3474 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3475 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3476 assert.NotEqual(t, e2SubsId2, 0)
3477
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003478 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003479
3480 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3481 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003482 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003483 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3484 // md5sum shall find the original request
3485 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3486 assert.Equal(t, restSubId_resend, restSubId_resend2)
3487
Markku Virtanen2b512b62021-07-30 12:04:00 +00003488 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3489 assert.Equal(t, e2SubsId, e2SubsId1)
3490
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003491 mainCtrl.WaitOngoingRequestMapEmpty()
3492
Markku Virtanen42723e22021-06-15 10:09:23 +03003493 // Delete both e2 subscriptions
3494 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3495 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3496 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3497
3498 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003499 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003500 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003501}
3502
3503//-----------------------------------------------------------------------------
3504// stub stub stub
3505// +-------+ +---------+ +---------+ +---------+
3506// | xapp | | submgr | | e2term | | rtmgr |
3507// +-------+ +---------+ +---------+ +---------+
3508// | | | |
3509// | RESTSubReq | | |
3510// |---------------->| | |
3511// | RESTSubResp | | |
3512// |<----------------| | |
3513// | | RouteCreate | |
3514// | |--------------------------->|
3515// | | RouteResponse| |
3516// | |<---------------------------|
3517// | | SubReq | |
3518// | |------------->| |
3519// | | SubResp | |
3520// | |<-------------| |
3521// | RESTNotif1 | | |
3522// |<----------------| | |
3523// | RESTSubReq | | |
3524// | [with RestSUbsId + one additional e2 subDetail]
3525// |---------------->| | |
3526// | RESTNotif1 | | |
3527// | [for initial e2 subDetail] | |
3528// |<----------------| | |
3529// | | RouteCreate | |
3530// | |--------------------------->|
3531// | | RouteResponse| |
3532// | |<---------------------------|
3533// | | SubReq | |
3534// | |------------->| |
3535// | | SubResp | |
3536// | |<-------------| |
3537// | RESTNotif1 | | |
3538// |<----------------| | |
3539// | RESTSubDelReq | | |
3540// |---------------->| | |
3541// | RESTSubDelResp| | |
3542// |<----------------| | |
3543// | | SubDelReq | |
3544// | |------------->| |
3545// | | SubDelResp | |
3546// | |<-------------| |
3547// | | SubDelReq | |
3548// | |------------->| |
3549// | | SubDelResp | |
3550// | |<-------------| |
3551// | RESTSubReq | | |
3552// | [with RESTsubsId initial request] |
3553// |---------------->| | |
3554// | RESTSubResp | | |
3555// |<----------------| | |
3556// | | RouteCreate | |
3557// | |--------------------------->|
3558// | | RouteResponse| |
3559// | |<---------------------------|
3560// | | SubReq | |
3561// | |------------->| |
3562// | | SubResp | |
3563// | |<-------------| |
3564// | RESTNotif1 | | |
3565// |<----------------| | |
3566// | | | |
3567//
3568//-----------------------------------------------------------------------------
3569func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003570
3571 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3572 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003573 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003574 Counter{cRestSubRespToXapp, 3},
3575 Counter{cSubReqToE2, 3},
3576 Counter{cSubRespFromE2, 3},
3577 Counter{cRestSubNotifToXapp, 4},
3578 Counter{cRestSubDelReqFromXapp, 2},
3579 Counter{cSubDelReqToE2, 3},
3580 Counter{cSubDelRespFromE2, 3},
3581 Counter{cRestSubDelRespToXapp, 2},
3582 })
3583
3584 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3585
3586 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3587
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003588 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003589
3590 // Send modified requst, this time with e2 subscriptions.
3591 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3592 params2.SetSubscriptionID(&restSubId)
3593
3594 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003595 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003596 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3597 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3598
Markku Virtanen2b512b62021-07-30 12:04:00 +00003599 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3600 assert.Equal(t, e2SubsId, e2SubsId1)
3601
Markku Virtanen42723e22021-06-15 10:09:23 +03003602 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3603
3604 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3605 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3606 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3607 assert.NotEqual(t, e2SubsId2, 0)
3608
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003609 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003610
3611 // Delete both e2 subscriptions
3612 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3613 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3614 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3615
3616 waitSubsCleanup(t, e2SubsId, 10)
3617
3618 // Resend the original request, we shall find it's previous md5sum/restsubs
3619 // but the restsubscription has been already removed. This shall trigger a
3620 // fresh create.
3621 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3622
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003623 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003624
3625 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3626
3627 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003628 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003629 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003630}
3631
Anssi Mannila27385172021-12-22 09:41:54 +02003632//-----------------------------------------------------------------------------
3633// TestRESTSubDelReqRetransmission
3634//
3635// stub stub
3636// +-------+ +---------+ +---------+
3637// | xapp | | submgr | | e2term |
3638// +-------+ +---------+ +---------+
3639// | | |
3640// | RESTSubReq | |
3641// |---------------->| |
3642// | | |
3643// | RESTSubResp | |
3644// |<----------------| |
3645// | | SubReq |
3646// | |------------->|
3647// | | SubResp |
3648// | |<-------------|
3649// | RESTNotif1 | |
3650// |<----------------| |
3651// | | |
3652// | RESTSubDelReq | |
3653// |---------------->| |
3654// | RESTSubDelResp | |
3655// |<----------------| |
3656// | | SubDelReq |
3657// | |------------->|
3658// | RESTSubDelReq | |
3659// |---------------->| |
3660// | RESTSubDelResp | |
3661// |<----------------| |
3662// | | SubDelResp |
3663// | |<-------------|
3664// | | |
3665//
3666//-----------------------------------------------------------------------------
3667
archaggeafbf95f2021-04-14 08:54:05 +03003668func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003669
3670 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003671 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003672 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003673 Counter{cSubReqToE2, 1},
3674 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003675 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003676 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003677 Counter{cSubDelReqToE2, 1},
3678 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003679 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003680 })
3681
3682 var params *teststube2ap.RESTSubsReqParams = nil
3683
3684 //Subs Create
3685 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3686
3687 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3688
3689 //Subs Delete
3690 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3691 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3692
Anssi Mannila27385172021-12-22 09:41:54 +02003693 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03003694 seqBef := mainCtrl.get_msgcounter(t)
3695 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3696 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3697
Anssi Mannila27385172021-12-22 09:41:54 +02003698 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03003699 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3700
3701 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003702 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003703 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003704}
3705
3706//-----------------------------------------------------------------------------
3707// TestRESTSubReqDelReq
3708//
3709// stub stub
3710// +-------+ +---------+ +---------+
3711// | xapp | | submgr | | e2term |
3712// +-------+ +---------+ +---------+
3713// | | |
3714// | RESTSubReq | |
3715// |---------------->| |
3716// | | |
3717// | RESTSubResp | |
3718// |<----------------| |
3719// | | SubReq |
3720// | |------------->|
3721// | RESTSubDelReq | |
3722// |---------------->| |
3723// | RESTSubDelResp | |
3724// | unsuccess | |
3725// |<----------------| |
3726// | | SubResp |
3727// | |<-------------|
3728// | RESTNotif1 | |
3729// |<----------------| |
3730// | | |
3731// | [SUBS DELETE] |
3732// | | |
3733//
3734//-----------------------------------------------------------------------------
3735func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003736
3737 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003738 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003739 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003740 Counter{cSubReqToE2, 1},
3741 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003742 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003743 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003744 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003745 Counter{cSubDelReqToE2, 1},
3746 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003747 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003748 })
3749
3750 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003751
3752 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003753 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003754 restSubId := xappConn1.SendRESTSubsReq(t, params)
3755
3756 // Del. This will fail as processing of the subscription
3757 // is still ongoing in submgr. Deletion is not allowed before
3758 // subscription creation has been completed.
3759 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3760 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3761 xappConn1.ExpectRESTNotification(t, restSubId)
3762 e2termConn1.SendSubsResp(t, crereq, cremsg)
3763 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3764
3765 // Retry del
3766 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3767
3768 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3769 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3770
3771 // Wait that subs is cleaned
3772 waitSubsCleanup(t, e2SubsId, 10)
3773 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003774 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003775}
3776
Anssi Mannila27385172021-12-22 09:41:54 +02003777//-----------------------------------------------------------------------------
3778// TestRESTSubReqAndSubDelOkTwoParallel
3779//
3780// stub stub stub
3781// +-------+ +-------+ +---------+ +---------+
3782// | xapp2 | | xapp1 | | submgr | | e2term |
3783// +-------+ +-------+ +---------+ +---------+
3784// | | | |
3785// | | RESTSubReq1 | |
3786// | |------------->| |
3787// | | RESTSubResp1 | |
3788// | |<-------------| |
3789// | | | |
3790// | | | SubReq1 |
3791// | | |------------->|
3792// | | | |
3793// | RESTSubReq2 | |
3794// |------------------------>| |
3795// | RESTSubResp2 | |
3796// |<------------------------| |
3797// | | | |
3798// | | | SubReq2 |
3799// | | |------------->|
3800// | | | |
3801// | | | SubResp1 |
3802// | | |<-------------|
3803// | | RESTNotif1 | |
3804// | |<-------------| |
3805// | | | |
3806// | | | SubResp2 |
3807// | | |<-------------|
3808// | RESTNotif2 | |
3809// |<------------------------| |
3810// | | | |
3811// | | [SUBS 1 DELETE] |
3812// | | | |
3813// | | [SUBS 2 DELETE] |
3814// | | | |
3815//
3816//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003817
3818func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003819
3820 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003821 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003822 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003823 Counter{cSubReqToE2, 2},
3824 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003825 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003826 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003827 Counter{cSubDelReqToE2, 2},
3828 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003829 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003830 })
3831
3832 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003833 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003834 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003835 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003836
3837 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003838 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003839 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003840 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003841
3842 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3843 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3844
3845 //XappConn1 receives both of the responses
3846 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3847
3848 //Resp1
3849 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3850 //Resp2
3851 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3852
3853 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003854 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003855 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003856 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003857
3858 //Del1
3859 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3860 //Del2
3861 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3862
3863 //Wait that subs is cleaned
3864 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3865 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3866
3867 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003868 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003869}
3870
Anssi Mannila27385172021-12-22 09:41:54 +02003871//-----------------------------------------------------------------------------
3872// TestRESTSameSubsDiffRan
3873// Same subscription to different RANs
3874//
3875// stub stub
3876// +-------+ +---------+ +---------+
3877// | xapp | | submgr | | e2term |
3878// +-------+ +---------+ +---------+
3879// | | |
3880// | RESTSubReq(r1) | |
3881// |---------------->| |
3882// | RESTSubResp(r1) | |
3883// |<----------------| |
3884// | | |
3885// | | SubReq(r1) |
3886// | |------------->|
3887// | | |
3888// | | SubResp(r1) |
3889// | |<-------------|
3890// | | |
3891// | RESTNotif(r1) | |
3892// |<----------------| |
3893// | | |
3894// | RESTSubReq(r2) | |
3895// |---------------->| |
3896// | | |
3897// | RESTSubResp(r2) | |
3898// |<----------------| |
3899// | | SubReq(r2) |
3900// | |------------->|
3901// | | |
3902// | | SubResp(r2) |
3903// | |<-------------|
3904// | | |
3905// | RESTNotif(r2) | |
3906// |<----------------| |
3907// | | |
3908// | [SUBS r1 DELETE] |
3909// | | |
3910// | [SUBS r2 DELETE] |
3911// | | |
3912//
3913//-----------------------------------------------------------------------------
3914
archaggeafbf95f2021-04-14 08:54:05 +03003915func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003916
3917 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003918 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003919 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003920 Counter{cSubReqToE2, 2},
3921 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003922 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003923 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003924 Counter{cSubDelReqToE2, 2},
3925 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003926 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003927 })
3928
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003929 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003930 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003931 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003932
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003933 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003934 params.SetMeid("RAN_NAME_2")
3935 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003936 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003937
3938 //Del1
3939 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3940 //Del2
3941 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3942
3943 //Wait that subs is cleaned
3944 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3945 waitSubsCleanup(t, e2SubsId2, 10)
3946
3947 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003948 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003949}
3950
Anssi Mannila27385172021-12-22 09:41:54 +02003951//-----------------------------------------------------------------------------
3952// TestRESTSubReqRetryInSubmgr
3953//
3954// stub stub
3955// +-------+ +---------+ +---------+
3956// | xapp | | submgr | | e2term |
3957// +-------+ +---------+ +---------+
3958// | | |
3959// | RESTSubReq | |
3960// |---------------->| |
3961// | RESTSubResp | |
3962// |<----------------| |
3963// | | SubReq |
3964// | | |
3965// | | |
3966// | | SubReq |
3967// | |------------->|
3968// | | SubResp |
3969// | |<-------------|
3970// | | |
3971// | RESTNotif | |
3972// |<----------------| |
3973// | | |
3974// | [SUBS DELETE] |
3975// | | |
3976//
3977//-----------------------------------------------------------------------------
3978
archaggeafbf95f2021-04-14 08:54:05 +03003979func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003980
3981 // Init counter check
3982 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003983 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003984 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003985 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003986 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003987 Counter{cSubReReqToE2, 1},
3988 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003989 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003990 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003991 Counter{cSubDelReqToE2, 1},
3992 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003993 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003994 })
3995
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003996 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003997 restSubId := xappConn1.SendRESTSubsReq(t, params)
3998
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003999 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004000
4001 // Catch the first message and ignore it
4002 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004003 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004004
4005 // The second request is being handled normally
4006 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4007 xappConn1.ExpectRESTNotification(t, restSubId)
4008 e2termConn1.SendSubsResp(t, crereq, cremsg)
4009 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4010
4011 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4012
Anssi Mannila27385172021-12-22 09:41:54 +02004013 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004014 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4015
4016 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4017 //Wait that subs is cleaned
4018 waitSubsCleanup(t, e2SubsId, 10)
4019
4020 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004021 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004022}
4023
4024//-----------------------------------------------------------------------------
4025// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4026//
4027// stub stub
4028// +-------+ +---------+ +---------+
4029// | xapp | | submgr | | e2term |
4030// +-------+ +---------+ +---------+
4031// | | |
4032// | RESTSubReq | |
4033// |---------------->| |
4034// | | |
4035// | RESTSubResp | |
4036// |<----------------| |
4037// | | SubReq |
4038// | |------------->|
4039// | | |
4040// | | |
4041// | | SubReq |
4042// | |------------->|
4043// | | |
4044// | | SubDelReq |
4045// | |------------->|
4046// | | |
4047// | | |
4048// | | SubDelReq |
4049// | |------------->|
4050// | | |
4051// | | |
4052// | | SubDelResp |
4053// | |<-------------|
4054// | RESTNotif | |
4055// | unsuccess | |
4056// |<----------------| |
4057// | | |
4058// | [SUBS DELETE] |
4059// | | |
4060//
4061//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004062
archaggeafbf95f2021-04-14 08:54:05 +03004063func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004064
4065 // Init counter check
4066 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004067 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004068 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004069 Counter{cSubReqToE2, 1},
4070 Counter{cSubReReqToE2, 1},
4071 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004072 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004073 Counter{cSubDelReqToE2, 1},
4074 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004075 Counter{cRestSubDelReqFromXapp, 1},
4076 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004077 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004078
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004079 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004080 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004081 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004082
4083 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004084 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004085
4086 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004087 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004088
4089 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004090 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004091 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004092 xappConn1.WaitRESTNotification(t, restSubId)
4093
Anssi Mannilab43397e2021-11-16 12:06:16 +02004094 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4095
archaggeafbf95f2021-04-14 08:54:05 +03004096 // Wait that subs is cleaned
4097 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004098 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004099 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004100}
4101
Anssi Mannila27385172021-12-22 09:41:54 +02004102//-----------------------------------------------------------------------------
4103// TestREST2eTermNotRespondingToSubReq
4104//
4105// stub stub
4106// +-------+ +---------+ +---------+
4107// | xapp | | submgr | | e2term |
4108// +-------+ +---------+ +---------+
4109// | | |
4110// | RESTSubReq | |
4111// |---------------->| |
4112// | RESTSubResp | |
4113// |<----------------| |
4114// | | SubReq |
4115// | |------------->|
4116// | | |
4117// | | SubReq |
4118// | |------------->|
4119// | | |
4120// | | SubDelReq |
4121// | |------------->|
4122// | | |
4123// | | SubDelReq |
4124// | |------------->|
4125// | RESTNotif(Unsuccessful) |
4126// |<----------------| |
4127// | | |
4128// | RESTSubDelReq | |
4129// |---------------->| |
4130// | RESTSubDelResp | |
4131// |<----------------| |
4132// | | |
4133//
4134//-----------------------------------------------------------------------------
4135
archaggeafbf95f2021-04-14 08:54:05 +03004136func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004137
4138 // Init counter check
4139 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004140 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004141 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004142 Counter{cSubReqToE2, 1},
4143 Counter{cSubReReqToE2, 1},
4144 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004145 Counter{cSubDelReReqToE2, 1},
4146 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004147 Counter{cSubDelReqToE2, 1},
4148 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004149 Counter{cRestSubDelReqFromXapp, 1},
4150 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004151 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004152
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004153 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004154 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004155 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004156
4157 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004158 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004159
4160 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004161 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004162
4163 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004164 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004165
Markku Virtanen55d2a282021-06-04 14:46:56 +03004166 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004167 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004168 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004169
4170 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4171
Anssi Mannilab43397e2021-11-16 12:06:16 +02004172 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004173
Anssi Mannilab43397e2021-11-16 12:06:16 +02004174 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004175 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004176 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004177}
4178
4179//-----------------------------------------------------------------------------
4180// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4181//
4182// stub stub
4183// +-------+ +---------+ +---------+
4184// | xapp | | submgr | | e2term |
4185// +-------+ +---------+ +---------+
4186// | | |
4187// | RESTSubReq | |
4188// |---------------->| |
4189// | | |
4190// | RESTSubResp | |
4191// |<----------------| |
4192// | | SubReq |
4193// | |------------->|
4194// | | |
4195// | | |
4196// | | SubReq |
4197// | |------------->|
4198// | | |
4199// | | SubDelReq |
4200// | |------------->|
4201// | | |
4202// | | |
4203// | | SubDelReq |
4204// | |------------->|
4205// | | |
4206// | | |
4207// | | SubDelResp |
4208// | |<-------------|
4209// | RESTNotif | |
4210// | unsuccess | |
4211// |<----------------| |
4212// | | |
4213// | [SUBS DELETE] |
4214// | | |
4215//
4216//-----------------------------------------------------------------------------
4217func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004218
4219 // Init counter check
4220 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004221 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004222 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004223 Counter{cSubReqToE2, 1},
4224 Counter{cSubReReqToE2, 1},
4225 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004226 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004227 Counter{cSubDelReqToE2, 1},
4228 Counter{cSubDelReReqToE2, 1},
4229 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004230 Counter{cRestSubDelReqFromXapp, 1},
4231 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004232 })
4233
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004234 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004235 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004236 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004237
4238 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004239 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004240
4241 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004242 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004243
4244 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004245 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004246
Markku Virtanen55d2a282021-06-04 14:46:56 +03004247 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004248 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004249 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004250
4251 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4252
Anssi Mannilab43397e2021-11-16 12:06:16 +02004253 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004254
Anssi Mannilab43397e2021-11-16 12:06:16 +02004255 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004256 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004257 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004258}
4259
4260//-----------------------------------------------------------------------------
4261// TestRESTSubReqSubFailRespInSubmgr
4262//
4263// stub stub
4264// +-------+ +---------+ +---------+
4265// | xapp | | submgr | | e2term |
4266// +-------+ +---------+ +---------+
4267// | | |
4268// | RESTSubReq | |
4269// |---------------->| |
4270// | | |
4271// | RESTSubResp | |
4272// |<----------------| |
4273// | | SubReq |
4274// | |------------->|
4275// | | |
4276// | | SubFail |
4277// | |<-------------|
4278// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004279// | RESTNotif | |
4280// | unsuccess | |
4281// |<----------------| |
4282// | | |
4283// | [SUBS DELETE] |
4284// | | |
4285//
4286//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004287
archaggeafbf95f2021-04-14 08:54:05 +03004288func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004289
4290 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004291 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004292 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004293 Counter{cSubReqToE2, 1},
4294 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004295 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004296 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004297 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004298 })
4299
4300 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004301 const e2Timeout int64 = 2
4302 const e2RetryCount int64 = 1
4303 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004304
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004305 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004306 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004307 restSubId := xappConn1.SendRESTSubsReq(t, params)
4308
4309 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4310 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4311 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004312 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004313 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4314
archaggeafbf95f2021-04-14 08:54:05 +03004315 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004316 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004317
4318 // REST subscription sill there to be deleted
4319 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4320
4321 // Wait that subs is cleaned
4322 waitSubsCleanup(t, e2SubsId, 10)
4323
4324 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004325 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004326}
4327
4328//-----------------------------------------------------------------------------
4329// TestRESTSubDelReqRetryInSubmgr
4330//
4331// stub stub
4332// +-------+ +---------+ +---------+
4333// | xapp | | submgr | | e2term |
4334// +-------+ +---------+ +---------+
4335// | | |
4336// | [SUBS CREATE] |
4337// | | |
4338// | | |
4339// | RESTSubDelReq | |
4340// |---------------->| |
4341// | | |
4342// | RESTSubDelResp | |
4343// |<----------------| |
4344// | | SubDelReq |
4345// | |------------->|
4346// | | |
4347// | | SubDelReq |
4348// | |------------->|
4349// | | |
4350// | | SubDelResp |
4351// | |<-------------|
4352// | | |
4353//
4354//-----------------------------------------------------------------------------
4355func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004356
4357 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004358 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004359 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004360 Counter{cSubReqToE2, 1},
4361 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004362 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004363 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004364 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004365 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004366 Counter{cSubDelReReqToE2, 1},
4367 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004368 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004369 })
4370 // Req
4371 var params *teststube2ap.RESTSubsReqParams = nil
4372 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4373
4374 // Del
4375 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4376
4377 // E2t: Receive 1st SubsDelReq
4378 e2termConn1.RecvSubsDelReq(t)
4379
4380 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4381 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4382 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4383
4384 //Wait that subs is cleaned
4385 waitSubsCleanup(t, e2SubsId, 10)
4386
4387 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004388 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004389}
4390
4391//-----------------------------------------------------------------------------
4392// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4393//
4394// stub stub
4395// +-------+ +---------+ +---------+
4396// | xapp | | submgr | | e2term |
4397// +-------+ +---------+ +---------+
4398// | | |
4399// | [SUBS CREATE] |
4400// | | |
4401// | | |
4402// | RESTSubDelReq | |
4403// |---------------->| |
4404// | | |
4405// | RESTSubDelResp | |
4406// |<----------------| |
4407// | | SubDelReq |
4408// | |------------->|
4409// | | |
4410// | | SubDelReq |
4411// | |------------->|
4412// | | |
4413// | | |
4414//
4415//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004416
archaggeafbf95f2021-04-14 08:54:05 +03004417func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004418
4419 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004420 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004421 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004422 Counter{cSubReqToE2, 1},
4423 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004424 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004425 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004426 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004427 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004428 Counter{cSubDelReReqToE2, 1},
4429 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004430 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004431 })
4432
4433 // Req
4434 var params *teststube2ap.RESTSubsReqParams = nil
4435 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4436
4437 // Del
4438 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4439
4440 // E2t: Receive 1st SubsDelReq
4441 e2termConn1.RecvSubsDelReq(t)
4442
4443 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4444 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4445 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4446
4447 //Wait that subs is cleaned
4448 waitSubsCleanup(t, e2SubsId, 10)
4449
4450 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004451 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004452}
4453
4454//-----------------------------------------------------------------------------
4455// TestRESTSubDelReqSubDelFailRespInSubmgr
4456//
4457// stub stub
4458// +-------+ +---------+ +---------+
4459// | xapp | | submgr | | e2term |
4460// +-------+ +---------+ +---------+
4461// | | |
4462// | [SUBS CREATE] |
4463// | | |
4464// | | |
4465// | RESTSubDelReq | |
4466// |---------------->| |
4467// | | |
4468// | RESTSubDelResp | |
4469// |<----------------| |
4470// | | SubDelReq |
4471// | |------------->|
4472// | | |
4473// | | SubDelFail |
4474// | |<-------------|
4475// | | |
4476//
4477//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004478
archaggeafbf95f2021-04-14 08:54:05 +03004479func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004480
4481 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004482 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004483 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004484 Counter{cSubReqToE2, 1},
4485 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004486 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004487 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004488 Counter{cSubDelReqToE2, 1},
4489 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004490 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004491 })
4492
4493 // Req
4494 var params *teststube2ap.RESTSubsReqParams = nil
4495 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4496
4497 // Del
4498 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4499
4500 // E2t: Send receive SubsDelReq and send SubsDelFail
4501 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4502 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4503
4504 //Wait that subs is cleaned
4505 waitSubsCleanup(t, e2SubsId, 10)
4506
4507 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004508 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004509}
4510
4511//-----------------------------------------------------------------------------
4512// TestRESTSubReqAndSubDelOkSameAction
4513//
4514// stub stub
4515// +-------+ +-------+ +---------+ +---------+
4516// | xapp2 | | xapp1 | | submgr | | e2term |
4517// +-------+ +-------+ +---------+ +---------+
4518// | | | |
4519// | | RESTSubReq1 | |
4520// | |---------------->| |
4521// | | | |
4522// | | RESTSubResp1 | |
4523// | |<----------------| |
4524// | | | |
4525// | | | SubReq1 |
4526// | | |------------->|
4527// | | | SubResp1 |
4528// | | |<-------------|
4529// | | RESTNotif1 | |
4530// | |<----------------| |
4531// | | | |
4532// | RESTSubReq2 | |
4533// |------------------------------>| |
4534// | | | |
4535// | RESTSubResp2 | |
4536// |<------------------------------| |
4537// | | | |
4538// | | RESTNotif2 | |
4539// |<------------------------------| |
4540// | | | |
4541// | | RESTSubDelReq1 | |
4542// | |---------------->| |
4543// | | | |
4544// | | RESTSubDelResp1 | |
4545// | |<----------------| |
4546// | | | |
4547// | RESTSubDelReq2 | |
4548// |------------------------------>| |
4549// | | | |
4550// | RESTSubDelResp2 | |
4551// |<------------------------------| |
4552// | | | |
4553// | | | SubDelReq2 |
4554// | | |------------->|
4555// | | | |
4556// | | | SubDelResp2 |
4557// | | |<-------------|
4558// | | | |
4559//
4560//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004561
archaggeafbf95f2021-04-14 08:54:05 +03004562func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004563
4564 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004565 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004566 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004567 Counter{cSubReqToE2, 1},
4568 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004569 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004570 Counter{cMergedSubscriptions, 1},
4571 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004572 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004573 Counter{cSubDelReqToE2, 1},
4574 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004575 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004576 })
4577
4578 // Req1
4579 var params *teststube2ap.RESTSubsReqParams = nil
4580
4581 //Subs Create
4582 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4583 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4584
4585 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004586 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004587 params.SetMeid("RAN_NAME_1")
4588
4589 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004590 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004591 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004592 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004593 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004594 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004595 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004596 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004597
4598 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4599
4600 // Del1
4601 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4602
4603 // Del2
4604 deleteXapp2Subscription(t, &restSubId2)
4605
4606 //Wait that subs is cleaned
4607 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004608 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004609 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004610}
4611
4612//-----------------------------------------------------------------------------
4613// TestSubReqAndSubDelOkSameActionParallel
4614//
4615// stub stub stub
4616// +-------+ +-------+ +---------+ +---------+
4617// | xapp2 | | xapp1 | | submgr | | e2term |
4618// +-------+ +-------+ +---------+ +---------+
4619// | | | |
4620// | | | |
4621// | | | |
4622// | | SubReq1 | |
4623// | |------------->| |
4624// | | | |
4625// | | | SubReq1 |
4626// | | |------------->|
4627// | SubReq2 | |
4628// |--------------------------->| |
4629// | | | SubResp1 |
4630// | | |<-------------|
4631// | | SubResp1 | |
4632// | |<-------------| |
4633// | | | SubReq2 |
4634// | | |------------->|
4635// | | | |
4636// | | | SubResp2 |
4637// | | |<-------------|
4638// | SubResp2 | |
4639// |<---------------------------| |
4640// | | | |
4641// | | SubDelReq 1 | |
4642// | |------------->| |
4643// | | | |
4644// | | SubDelResp 1 | |
4645// | |<-------------| |
4646// | | | |
4647// | SubDelReq 2 | |
4648// |--------------------------->| |
4649// | | | |
4650// | | | SubDelReq 2 |
4651// | | |------------->|
4652// | | | |
4653// | | | SubDelReq 2 |
4654// | | |------------->|
4655// | | | |
4656// | SubDelResp 2 | |
4657// |<---------------------------| |
4658//
4659func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004660
4661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004662 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004663 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004664 Counter{cSubReqToE2, 2},
4665 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004666 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004667 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004668 Counter{cSubDelReqToE2, 2},
4669 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004670 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004671 })
4672
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004673 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004674 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4675 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4676
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004677 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004678 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4679
4680 xappConn1.ExpectRESTNotification(t, restSubId1)
4681 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4682 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4683
4684 xappConn2.ExpectRESTNotification(t, restSubId2)
4685 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4686 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4687 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4688
4689 // Del1
4690 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4691 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4692 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4693 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4694
4695 // Del2
4696 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4697 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4698 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4699
4700 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004701 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004702 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004703}
4704
4705//-----------------------------------------------------------------------------
4706// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4707//
4708// stub stub stub
4709// +-------+ +-------+ +---------+ +---------+
4710// | xapp2 | | xapp1 | | submgr | | e2term |
4711// +-------+ +-------+ +---------+ +---------+
4712// | | | |
4713// | | | |
4714// | | | |
4715// | | RESTSubReq1 | |
4716// | |---------------->| |
4717// | | | |
4718// | | RESTSubResp1 | |
4719// | |<----------------| |
4720// | | | SubReq1 |
4721// | | |------------->|
4722// | RESTSubReq2 | |
4723// |------------------------------>| |
4724// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004725// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004726// |<------------------------------| |
4727// | | | SubReq1 |
4728// | | |------------->|
4729// | | | |
4730// | | | |
4731// | | | SubDelReq |
4732// | | |------------->|
4733// | | | |
4734// | | | SubDelResp |
4735// | | |<-------------|
4736// | | RESTNotif1 | |
4737// | | unsuccess | |
4738// | |<----------------| |
4739// | RESTNotif2 | |
4740// | | unsuccess | |
4741// |<------------------------------| |
4742// | | | |
4743// | | RESTSubDelReq1 | |
4744// | |---------------->| |
4745// | | | |
4746// | | RESTSubDelResp1 | |
4747// | |<----------------| |
4748// | | | |
4749// | RESTSubDelReq2 | |
4750// |------------------------------>| |
4751// | | | |
4752// | RESTSubDelResp2 | |
4753// |<------------------------------| |
4754//
4755//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004756
archaggeafbf95f2021-04-14 08:54:05 +03004757func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004758
4759 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004760 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004761 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004762 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004763 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004764 Counter{cSubReqTimerExpiry, 2},
4765 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004766 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004767 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004768 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004769 Counter{cSubDelReqToE2, 1},
4770 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004771 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004772 })
archaggeafbf95f2021-04-14 08:54:05 +03004773 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004774
4775 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004776 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004777 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4778 crereq1, _ := e2termConn1.RecvSubsReq(t)
4779
4780 // Req2
4781 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004782 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004783 params2.SetMeid("RAN_NAME_1")
4784 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4785 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4786
4787 //Req1 (retransmitted)
4788 e2termConn1.RecvSubsReq(t)
4789
4790 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004791
4792 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004793 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4794
Markku Virtanenda34eec2021-05-20 08:22:04 +00004795 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004796 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004797 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004798 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004799
4800 // Del1
4801 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4802
4803 // Del2
4804 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4805
Markku Virtanenda34eec2021-05-20 08:22:04 +00004806 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4807
archaggeafbf95f2021-04-14 08:54:05 +03004808 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004809 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004810 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004811 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004812}
4813
4814//-----------------------------------------------------------------------------
4815// TestRESTSubReqAndSubDelNokSameActionParallel
4816//
4817// stub stub stub
4818// +-------+ +-------+ +---------+ +---------+
4819// | xapp2 | | xapp1 | | submgr | | e2term |
4820// +-------+ +-------+ +---------+ +---------+
4821// | | | |
4822// | | | |
4823// | | | |
4824// | | RESTSubReq1 | |
4825// | |---------------->| |
4826// | | | |
4827// | | RESTSubResp1 | |
4828// | |<----------------| |
4829// | | | SubReq1 |
4830// | | |------------->|
4831// | RESTSubReq2 | |
4832// |------------------------------>| |
4833// | | | |
4834// | RESTSubDelResp2 | |
4835// |<------------------------------| |
4836// | | | SubFail1 |
4837// | | |<-------------|
4838// | | | |
4839// | | RESTNotif1 | |
4840// | | unsuccess | |
4841// | |<----------------| |
4842// | RESTNotif2 | |
4843// | | unsuccess | |
4844// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004845// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004846// | | 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 +03004847// | |---------------->| |
4848// | | | |
4849// | | RESTSubDelResp1 | |
4850// | |<----------------| |
4851// | | | |
4852// | RESTSubDelReq2 | |
4853// |------------------------------>| |
4854// | | | |
4855// | RESTSubDelResp2 | |
4856// |<------------------------------| |
4857//
4858//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004859
archaggeafbf95f2021-04-14 08:54:05 +03004860func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004861
4862 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004863 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004864 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004865 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004866 Counter{cSubReqToE2, 1},
4867 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004868 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004869 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004870 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004871 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004872 })
4873
4874 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004875
4876 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004877 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004878 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4879 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4880
4881 // Req2
4882 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004883 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004884 params2.SetMeid("RAN_NAME_1")
4885 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4886 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4887
4888 // E2t: send SubsFail (first)
4889 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4890 fparams1.Set(crereq1)
4891 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4892
archaggeafbf95f2021-04-14 08:54:05 +03004893 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004894 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004895 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004896 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004897 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004898
4899 // Del1
4900 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4901
4902 // Del2
4903 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4904
4905 //Wait that subs is cleaned
4906 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4907 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004908 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004909 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004910}
Anssi Mannila54838ed2021-11-19 11:25:01 +02004911
Anssi Mannila27385172021-12-22 09:41:54 +02004912//-----------------------------------------------------------------------------
4913// TestRESTSubReqPolicyAndSubDelOk
4914//
4915// stub stub
4916// +-------+ +---------+ +---------+
4917// | xapp | | submgr | | e2term |
4918// +-------+ +---------+ +---------+
4919// | | |
4920// | RESTSubReq | |
4921// |--------------->| |
4922// | RESTSubResp | |
4923// |<---------------| |
4924// | | |
4925// | | SubReq |
4926// | |------------->|
4927// | | |
4928// | | SubResp |
4929// | |<-------------|
4930// | | |
4931// | RESTNotif | |
4932// |<---------------| |
4933// | | |
4934// | | |
4935// | RESTSubDelReq | |
4936// |--------------->| |
4937// | RESTSubDelResp | |
4938// |<---------------| |
4939// | | |
4940// | | SubDelReq |
4941// | |------------->|
4942// | | |
4943// | | SubDelResp |
4944// | |<-------------|
4945// | | |
4946//
4947//-----------------------------------------------------------------------------
4948
archaggeafbf95f2021-04-14 08:54:05 +03004949func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004950
4951 // Init counter check
4952 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004953 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004954 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004955 Counter{cSubReqToE2, 1},
4956 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004957 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004958 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004959 Counter{cSubDelReqToE2, 1},
4960 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004961 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004962 })
4963
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004964 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004965 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004966 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004967
4968 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4969 xappConn1.ExpectRESTNotification(t, restSubId)
4970 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4971 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004972 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004973
4974 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4975 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4976 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4977
4978 // Wait that subs is cleaned
4979 waitSubsCleanup(t, e2SubsId, 10)
4980 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004981 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004982}
4983
4984//-----------------------------------------------------------------------------
4985// TestRESTSubReqPolicyChangeAndSubDelOk
4986//
4987// stub stub
4988// +-------+ +---------+ +---------+
4989// | xapp | | submgr | | e2term |
4990// +-------+ +---------+ +---------+
4991// | | |
4992// | RESTSubReq | |
4993// |---------------->| |
4994// | | |
4995// | RESTSubResp | |
4996// |<----------------| |
4997// | | SubReq |
4998// | |------------->|
4999// | | |
5000// | | SubResp |
5001// | |<-------------|
5002// | | |
5003// | RESTNotif | |
5004// |<----------------| |
5005// | | |
5006// | RESTSubReq | |
5007// |---------------->| |
5008// | | |
5009// | RESTSubResp | |
5010// |<----------------| |
5011// | | SubReq |
5012// | |------------->|
5013// | | |
5014// | | SubResp |
5015// | |<-------------|
5016// | | |
5017// | RESTNotif | |
5018// |<----------------| |
5019// | | |
5020// | RESTSubDelReq | |
5021// |---------------->| |
5022// | | |
5023// | | SubDelReq |
5024// | |------------->|
5025// | | |
5026// | | SubDelResp |
5027// | |<-------------|
5028// | | |
5029// | RESTSubDelResp | |
5030// |<----------------| |
5031//
5032//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005033
archaggeafbf95f2021-04-14 08:54:05 +03005034func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005035
5036 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005037 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005038 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005039 Counter{cSubReqToE2, 2},
5040 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005041 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005042 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005043 Counter{cSubDelReqToE2, 1},
5044 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005045 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005046 })
5047
5048 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005049 const e2Timeout int64 = 1
5050 const e2RetryCount int64 = 0
5051 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005052
5053 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005054 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005055 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005056 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5057
5058 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005059 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005060
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005061 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005062 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005063 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005064 params.SetTimeToWait("w200ms")
5065 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5066
5067 // Del
5068 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5069
5070 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5071 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5072
5073 // Wait that subs is cleaned
5074 waitSubsCleanup(t, e2SubsId, 10)
5075 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005076 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005077}
5078
5079//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005080// TestRESTSubReqPolicyChangeNOk
5081//
5082// stub stub
5083// +-------+ +---------+ +---------+
5084// | xapp | | submgr | | e2term |
5085// +-------+ +---------+ +---------+
5086// | | |
5087// | RESTSubReq | |
5088// |---------------->| |
5089// | | |
5090// | RESTSubResp | |
5091// |<----------------| |
5092// | | SubReq |
5093// | |------------->|
5094// | | |
5095// | | SubResp |
5096// | |<-------------|
5097// | | |
5098// | RESTNotif | |
5099// |<----------------| |
5100// | | |
5101// | RESTSubReq | |
5102// |---------------->| |
5103// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005104// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005105// | | |
5106// | RESTSubDelReq | |
5107// |---------------->| |
5108// | | |
5109// | | SubDelReq |
5110// | |------------->|
5111// | | |
5112// | | SubDelResp |
5113// | |<-------------|
5114// | | |
5115// | RESTSubDelResp | |
5116// |<----------------| |
5117//
5118//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005119
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005120func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005121
5122 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5123 Counter{cRestSubReqFromXapp, 2},
5124 Counter{cRestSubRespToXapp, 1},
5125 Counter{cSubReqToE2, 1},
5126 Counter{cSubRespFromE2, 1},
5127 Counter{cRestSubNotifToXapp, 1},
5128 Counter{cRestSubFailToXapp, 1},
5129 Counter{cRestSubDelReqFromXapp, 1},
5130 Counter{cSubDelReqToE2, 1},
5131 Counter{cSubDelRespFromE2, 1},
5132 Counter{cRestSubDelRespToXapp, 1},
5133 })
5134
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005135 // Req
5136 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5137 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5138
5139 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005140 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5141
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005142 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005143 params.SetSubscriptionID(&restSubIdUpd)
5144 params.SetTimeToWait("w200ms")
5145
5146 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5147 assert.Equal(t, restSubId2, "")
5148
5149 // Del
5150 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5151
5152 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5153 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5154
5155 // Wait that subs is cleaned
5156 waitSubsCleanup(t, e2SubsId, 10)
5157 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005158 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005159}
5160
5161//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005162// TestRESTSubReqAndSubDelOkTwoE2termParallel
5163//
5164// stub stub stub
5165// +-------+ +---------+ +---------+ +---------+
5166// | xapp | | submgr | | e2term1 | | e2term2 |
5167// +-------+ +---------+ +---------+ +---------+
5168// | | | |
5169// | | | |
5170// | | | |
5171// | RESTSubReq1 | | |
5172// |---------------->| | |
5173// | | | |
5174// | RESTSubResp1 | | |
5175// |<----------------| | |
5176// | | SubReq1 | |
5177// | |------------->| |
5178// | | | |
5179// | RESTSubReq2 | | |
5180// |---------------->| | |
5181// | | | |
5182// | RESTSubResp2 | | |
5183// |<----------------| | |
5184// | | SubReq2 | |
5185// | |---------------------------->|
5186// | | | |
5187// | | SubResp1 | |
5188// | |<-------------| |
5189// | RESTNotif1 | | |
5190// |<----------------| | |
5191// | | SubResp2 | |
5192// | |<----------------------------|
5193// | RESTNotif2 | | |
5194// |<----------------| | |
5195// | | | |
5196// | [SUBS 1 DELETE] | |
5197// | | | |
5198// | [SUBS 2 DELETE] | |
5199// | | | |
5200//
5201//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005202
archaggeafbf95f2021-04-14 08:54:05 +03005203func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005204
5205 // Init counter check
5206 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005207 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005208 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005209 Counter{cSubReqToE2, 2},
5210 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005211 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005212 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005213 Counter{cSubDelReqToE2, 2},
5214 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005215 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005216 })
5217
5218 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005219
5220 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005221 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005222 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5223 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5224
5225 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005226 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005227 params.SetMeid("RAN_NAME_11")
5228 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5229 // would not work as notification would not be received
5230 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5231 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5232
5233 // Resp1
5234 xappConn1.ExpectRESTNotification(t, restSubId1)
5235 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5236 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005237 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005238
5239 // Resp2
5240 xappConn2.ExpectRESTNotification(t, restSubId2)
5241 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5242 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005243 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005244
5245 // Delete1
5246 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5247 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5248 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5249
5250 // Wait that subs is cleaned
5251 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5252
5253 // Delete2
5254 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5255 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5256 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5257
5258 // Wait that subs is cleaned
5259 waitSubsCleanup(t, e2SubsId2, 10)
5260
5261 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005262 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005263}
5264
5265//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005266// TestRESTSubReqInsertAndSubDelOk
5267//
5268// stub stub
5269// +-------+ +---------+ +---------+
5270// | xapp | | submgr | | e2term |
5271// +-------+ +---------+ +---------+
5272// | | |
5273// | RestSubReq | |
5274// |---------------->| |
5275// | | |
5276// | RESTSubResp | |
5277// |<----------------| |
5278// | | |
5279// | | SubReq |
5280// | |------------->|
5281// | | |
5282// | | SubResp |
5283// | |<-------------|
5284// | RESTNotif | |
5285// |<----------------| |
5286// | ... | ... |
5287// | | |
5288// | RESTSubDelReq | |
5289// |---------------->| |
5290// | | |
5291// | | SubDelReq |
5292// | |------------->|
5293// | | |
5294// | | SubDelResp |
5295// | |<-------------|
5296// | | |
5297// | RESTSubDelResp| |
5298// |<----------------| |
5299//
5300//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005301
archaggeafbf95f2021-04-14 08:54:05 +03005302func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005303
5304 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005305 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005306 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005307 Counter{cSubReqToE2, 1},
5308 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005309 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005310 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005311 Counter{cSubDelReqToE2, 1},
5312 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005313 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005314 })
5315
5316 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005317
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005318 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005319 params.SetSubActionTypes("insert")
5320
5321 // Req
5322 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5323
5324 // Del
5325 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5326
5327 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5328 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5329
5330 // Wait that subs is cleaned
5331 waitSubsCleanup(t, e2SubsId, 10)
5332 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005333 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005334}
5335
5336//-----------------------------------------------------------------------------
5337// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5338//
5339// stub stub
5340// +-------+ +---------+ +---------+
5341// | xapp | | submgr | | e2term |
5342// +-------+ +---------+ +---------+
5343// | | |
5344// | RESTSubReq | |
5345// |------------->| |
5346// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005347// | RESTSubResp | |
5348// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005349// | | SubReq |
5350// | |------------->|
5351// | | |
5352// | | SubResp |
5353// | <----|
5354// | |
5355// | Submgr restart |
5356// | |
5357// | | |
5358// | | SubDelReq |
5359// | |------------->|
5360// | | |
5361// | | SubDelResp |
5362// | |<-------------|
5363// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005364// | RESTNotif | |
5365// | unsuccess | |
5366// |<-------------| |
5367// | | |
5368// | RESTSubDelReq| |
5369// |------------->| |
5370// | | |
5371// |RESTSubDelResp| |
5372// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005373//
5374//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005375
archaggeafbf95f2021-04-14 08:54:05 +03005376func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005377
5378 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005379 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005380 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005381 Counter{cSubReqToE2, 1},
5382 Counter{cSubDelReqFromXapp, 1},
5383 Counter{cSubDelReqToE2, 1},
5384 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005385 Counter{cRestSubDelReqFromXapp, 1},
5386 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005387 })
5388
5389 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005390
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005391 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005392
5393 //Req
5394 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5395 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005396 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005397
5398 e2termConn1.RecvSubsReq(t)
5399
5400 mainCtrl.SetResetTestFlag(t, false)
5401
5402 mainCtrl.SimulateRestart(t)
5403 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5404
Anssi Mannilab43397e2021-11-16 12:06:16 +02005405 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005406 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5407 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5408
Anssi Mannilab43397e2021-11-16 12:06:16 +02005409 //Del
5410 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5411
archaggeafbf95f2021-04-14 08:54:05 +03005412 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005413 e2termConn1.TestMsgChanEmpty(t)
5414 mainCtrl.wait_registry_empty(t, 10)
5415
5416 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005417 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005418}
5419
5420//-----------------------------------------------------------------------------
5421// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5422//
5423// stub stub
5424// +-------+ +---------+ +---------+
5425// | xapp | | submgr | | e2term |
5426// +-------+ +---------+ +---------+
5427// | | |
5428// | RESTSubReq | |
5429// |---------------->| |
5430// | | |
5431// | RESTSubResp | |
5432// |<----------------| |
5433// | | SubReq |
5434// | |------------->|
5435// | | |
5436// | | SubResp |
5437// | |<-------------|
5438// | | |
5439// | RESTNotif | |
5440// |<----------------| |
5441// | | |
5442// | |
5443// | Submgr restart |
5444// | | |
5445// | RESTSubDelReq | |
5446// |---------------->| |
5447// | | |
5448// | | SubDelReq |
5449// | |------------->|
5450// | | |
5451// | | SubDelResp |
5452// | |<-------------|
5453// | | |
5454// | RESTSubDelResp | |
5455// |<----------------| |
5456//
5457//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005458
archaggeafbf95f2021-04-14 08:54:05 +03005459func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005460
5461 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005462 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005463 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005464 Counter{cSubReqToE2, 1},
5465 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005466 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005467 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005468 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005469 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005470 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005471 })
archaggeafbf95f2021-04-14 08:54:05 +03005472
5473 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005474 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005475 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005476 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005477
5478 // Check subscription
5479 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5480
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005481 mainCtrl.SimulateRestart(t)
5482 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005483
Anssi Mannila54838ed2021-11-19 11:25:01 +02005484 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5485 // That needs to be completed before successful subscription query is possible
5486 <-time.After(time.Second * 1)
5487
archaggeafbf95f2021-04-14 08:54:05 +03005488 // Check subscription
5489 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5490
5491 // Delete subscription
5492 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5493
5494 //Wait that subs is cleaned
5495 waitSubsCleanup(t, e2SubsId, 10)
5496
5497 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005498 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005499}
5500
5501//-----------------------------------------------------------------------------
5502// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5503//
5504// stub stub
5505// +-------+ +-------+ +---------+ +---------+
5506// | xapp2 | | xapp1 | | submgr | | e2term |
5507// +-------+ +-------+ +---------+ +---------+
5508// | | | |
5509// | | RESTSubReq1 | |
5510// | |---------------->| |
5511// | | | |
5512// | | RESTSubResp1 | |
5513// | |<----------------| |
5514// | | | |
5515// | | | SubReq1 |
5516// | | |------------->|
5517// | | | SubResp1 |
5518// | | |<-------------|
5519// | | RESTNotif1 | |
5520// | |<----------------| |
5521// | | | |
5522// | RESTSubReq2 | |
5523// |------------------------------>| |
5524// | | | |
5525// | RESTSubResp2 | |
5526// |<------------------------------| |
5527// | | | |
5528// | | RESTNotif2 | |
5529// |<------------------------------| |
5530// | | | |
5531// | | Submgr restart |
5532// | | | |
5533// | | RESTSubDelReq1 | |
5534// | |---------------->| |
5535// | | | |
5536// | | RESTSubDelResp1 | |
5537// | |<----------------| |
5538// | | | |
5539// | | Submgr restart |
5540// | | | |
5541// | RESTSubDelReq2 | |
5542// |------------------------------>| |
5543// | | | |
5544// | RESTSubDelResp2 | |
5545// |<------------------------------| |
5546// | | | |
5547// | | | SubDelReq2 |
5548// | | |------------->|
5549// | | | |
5550// | | | SubDelResp2 |
5551// | | |<-------------|
5552// | | | |
5553//
5554//-----------------------------------------------------------------------------
5555func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005556
5557 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005558 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005559 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005560 Counter{cSubReqToE2, 1},
5561 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005562 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005563 Counter{cMergedSubscriptions, 1},
5564 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005565 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005566 Counter{cSubDelReqToE2, 1},
5567 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005568 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005569 })
5570
archaggeafbf95f2021-04-14 08:54:05 +03005571 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005572 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005573 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005574 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005575
5576 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005577 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005578 params.SetMeid("RAN_NAME_1")
5579 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005580 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005581 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005582 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005583 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005584 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005585
5586 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5587
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005588 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005589 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5590
5591 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5592 // That needs to be completed before successful subscription delete is possible
5593 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005594
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005595 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03005596 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02005597 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005598 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02005599
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005600 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005601 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5602
5603 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5604 // That needs to be completed before successful subscription query is possible
5605 <-time.After(time.Second * 1)
5606
archaggeafbf95f2021-04-14 08:54:05 +03005607 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5608
5609 // Delete subscription 2
5610 deleteXapp2Subscription(t, &restSubId2)
5611
5612 //Wait that subs is cleaned
5613 waitSubsCleanup(t, e2SubsId2, 10)
5614
5615 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005616 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005617}
5618
5619//-----------------------------------------------------------------------------
5620// TestRESTReportSubReqAndSubDelOk
5621//
5622// stub stub
5623// +-------+ +---------+ +---------+
5624// | xapp | | submgr | | e2term |
5625// +-------+ +---------+ +---------+
5626// | | |
5627// | RestSubReq | |
5628// |---------------->| |
5629// | | |
5630// | RESTSubResp | |
5631// |<----------------| |
5632// | | |
5633// | | SubReq |
5634// | |------------->|
5635// | | |
5636// | | SubResp |
5637// | |<-------------|
5638// | RESTNotif | |
5639// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02005640// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03005641// | |------------->|
5642// | | |
5643// | | SubResp |
5644// | |<-------------|
5645// | RESTNotif | |
5646// |<----------------| |
5647// | ... | ... |
5648// | | |
5649// | | |
5650// | RESTSubDelReq | |
5651// |---------------->| |
5652// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02005653// | RESTSubDelResp| |
5654// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005655// | | SubDelReq |
5656// | |------------->|
5657// | | |
5658// | | SubDelResp |
5659// | |<-------------|
5660// | | |
archaggeafbf95f2021-04-14 08:54:05 +03005661//
5662//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005663
archaggeafbf95f2021-04-14 08:54:05 +03005664func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005665 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005666 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005667 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005668}
5669
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005670func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005671 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005672
Anssi Mannila21782182021-12-10 10:56:02 +02005673 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5674 Counter{cRestSubReqFromXapp, 1},
5675 Counter{cRestSubRespToXapp, 1},
5676 Counter{cSubReqToE2, uint64(subReqCount)},
5677 Counter{cSubRespFromE2, uint64(subReqCount)},
5678 Counter{cRestSubNotifToXapp, 1},
5679 Counter{cRestSubDelReqFromXapp, 1},
5680 Counter{cRestSubDelRespToXapp, 1},
5681 Counter{cSubDelReqToE2, uint64(subReqCount)},
5682 Counter{cSubDelRespFromE2, uint64(subReqCount)},
5683 })
5684
archaggeafbf95f2021-04-14 08:54:05 +03005685 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005686 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005687 restSubId := xappConn1.SendRESTSubsReq(t, params)
5688
5689 var e2SubsId []uint32
5690 for i := 0; i < subReqCount; i++ {
5691 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5692 xappConn1.ExpectRESTNotification(t, restSubId)
5693
5694 e2termConn1.SendSubsResp(t, crereq, cremsg)
5695 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005696 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005697 e2SubsId = append(e2SubsId, instanceId)
5698 resp, _ := xapp.Subscription.QuerySubscriptions()
5699 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5700 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5701 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5702
5703 }
5704
5705 // Del
5706 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5707
5708 for i := 0; i < subReqCount; i++ {
5709 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5710 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5711 }
5712
5713 // Wait that subs is cleaned
5714 for i := 0; i < subReqCount; i++ {
5715 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5716 }
5717
5718 xappConn1.TestMsgChanEmpty(t)
5719 e2termConn1.TestMsgChanEmpty(t)
5720 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005721 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02005722 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03005723}
5724
Anssi Mannila27385172021-12-22 09:41:54 +02005725//-----------------------------------------------------------------------------
5726// TestRESTTwoPolicySubReqAndSubDelOk
5727//
5728// stub stub
5729// +-------+ +---------+ +---------+
5730// | xapp | | submgr | | e2term |
5731// +-------+ +---------+ +---------+
5732// | | |
5733// | RestSubReq | |
5734// |---------------->| |
5735// | | |
5736// | RESTSubResp | |
5737// |<----------------| |
5738// | | |
5739// | | SubReq |
5740// | |------------->|
5741// | | |
5742// | | SubResp |
5743// | |<-------------|
5744// | RESTNotif | |
5745// |<----------------| |
5746// | | SubReq |
5747// | |------------->|
5748// | | |
5749// | | SubResp |
5750// | |<-------------|
5751// | RESTNotif | |
5752// |<----------------| |
5753// | | |
5754// | RESTSubDelReq | |
5755// |---------------->| |
5756// | | |
5757// | RESTSubDelResp| |
5758// |<----------------| |
5759// | | SubDelReq |
5760// | |------------->|
5761// | | |
5762// | | SubDelResp |
5763// | |<-------------|
5764// | | |
5765// | | SubDelReq |
5766// | |------------->|
5767// | | |
5768// | | SubDelResp |
5769// | |<-------------|
5770// | | |
5771//
5772//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005773
archaggeafbf95f2021-04-14 08:54:05 +03005774func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5775
archaggeafbf95f2021-04-14 08:54:05 +03005776 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005777 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005778 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005779 Counter{cSubReqToE2, 2},
5780 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005781 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005782 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005783 Counter{cSubDelReqToE2, 2},
5784 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005785 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005786 })
5787
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005788 const subReqCount int = 2
5789
archaggeafbf95f2021-04-14 08:54:05 +03005790 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005791 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005792 restSubId := xappConn1.SendRESTSubsReq(t, params)
5793 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5794
5795 assert.Equal(t, len(e2SubsIds), 2)
5796
5797 // Del
5798 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5799 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5800
5801 xappConn1.TestMsgChanEmpty(t)
5802 e2termConn1.TestMsgChanEmpty(t)
5803 mainCtrl.wait_registry_empty(t, 10)
5804
5805 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005806 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005807}
Anssi Mannila27385172021-12-22 09:41:54 +02005808
5809//-----------------------------------------------------------------------------
5810// TestRESTPolicySubReqAndSubDelOk19E2Subs
5811//
5812// stub stub
5813// +-------+ +---------+ +---------+
5814// | xapp | | submgr | | e2term |
5815// +-------+ +---------+ +---------+
5816// | | |
5817// | RestSubReq | |
5818// |---------------->| |
5819// | | |
5820// | RESTSubResp | |
5821// |<----------------| |
5822// | | | ------
5823// | | SubReq |
5824// | |------------->|
5825// | | | E2 subscription x 19
5826// | | SubResp |
5827// | |<-------------|
5828// | RESTNotif | |
5829// |<----------------| |
5830// | | | ------
5831// | RESTSubDelReq | |
5832// |---------------->| |
5833// | | |
5834// | RESTSubDelResp| |
5835// |<----------------| |
5836// | | SubDelReq | ------
5837// | |------------->|
5838// | | | E2 subscription delete x 19
5839// | | SubDelResp |
5840// | |<-------------|
5841// | | | ------
5842// | | |
5843//
5844//-----------------------------------------------------------------------------
5845
5846func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005847
archaggeafbf95f2021-04-14 08:54:05 +03005848 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005849 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005850 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005851 Counter{cSubReqToE2, 19},
5852 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005853 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005854 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005855 Counter{cSubDelReqToE2, 19},
5856 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005857 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005858 })
5859
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005860 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005861 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005862 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005863 restSubId := xappConn1.SendRESTSubsReq(t, params)
5864 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5865
5866 assert.Equal(t, len(e2SubsIds), 19)
5867
5868 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5869 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5870
5871 xappConn1.TestMsgChanEmpty(t)
5872 e2termConn1.TestMsgChanEmpty(t)
5873 mainCtrl.wait_registry_empty(t, 10)
5874
5875 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005876 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005877}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005878
Anssi Mannila27385172021-12-22 09:41:54 +02005879//-----------------------------------------------------------------------------
5880// TestRESTTwoPolicySubReqAndSubDelOk
5881//
5882// stub stub
5883// +-------+ +---------+ +---------+
5884// | xapp | | submgr | | e2term |
5885// +-------+ +---------+ +---------+
5886// | | |
5887// | RestSubReq | |
5888// |---------------->| |
5889// | | |
5890// | RESTSubResp | |
5891// |<----------------| |
5892// | | |
5893// | | SubReq |
5894// | |------------->|
5895// | | |
5896// | | SubResp |
5897// | |<-------------|
5898// | RESTNotif | |
5899// |<----------------| |
5900// | | SubReq |
5901// | |------------->|
5902// | | |
5903// | | SubResp |
5904// | |<-------------|
5905// | RESTNotif | |
5906// |<----------------| |
5907// | | |
5908// | RESTSubDelReq | |
5909// |---------------->| |
5910// | | |
5911// | RESTSubDelResp| |
5912// |<----------------| |
5913// | | SubDelReq |
5914// | |------------->|
5915// | | |
5916// | | SubDelResp |
5917// | |<-------------|
5918// | | |
5919// | | SubDelReq |
5920// | |------------->|
5921// | | |
5922// | | SubDelResp |
5923// | |<-------------|
5924// | | |
5925//
5926//-----------------------------------------------------------------------------
5927
archaggeafbf95f2021-04-14 08:54:05 +03005928func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5929
5930 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005931
5932 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005933 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005934 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005935 Counter{cSubReqToE2, uint64(subReqCount)},
5936 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005937 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005938 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005939 Counter{cSubDelReqToE2, uint64(subReqCount)},
5940 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005941 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005942 })
5943
5944 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005945 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005946 restSubId := xappConn1.SendRESTSubsReq(t, params)
5947 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5948
5949 assert.Equal(t, len(e2SubsIds), subReqCount)
5950
5951 // Del
5952 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5953 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5954
5955 xappConn1.TestMsgChanEmpty(t)
5956 e2termConn1.TestMsgChanEmpty(t)
5957 mainCtrl.wait_registry_empty(t, 10)
5958
5959 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005960 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005961}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005962
Anssi Mannila27385172021-12-22 09:41:54 +02005963//-----------------------------------------------------------------------------
5964// TestRESTTwoReportSubReqAndSubDelOkNoActParams
5965//
5966// stub stub
5967// +-------+ +---------+ +---------+
5968// | xapp | | submgr | | e2term |
5969// +-------+ +---------+ +---------+
5970// | | |
5971// | RestSubReq | |
5972// |---------------->| |
5973// | | |
5974// | RESTSubResp | |
5975// |<----------------| |
5976// | | |
5977// | | SubReq |
5978// | |------------->|
5979// | | |
5980// | | SubResp |
5981// | |<-------------|
5982// | RESTNotif | |
5983// |<----------------| |
5984// | | SubReq |
5985// | |------------->|
5986// | | |
5987// | | SubResp |
5988// | |<-------------|
5989// | RESTNotif | |
5990// |<----------------| |
5991// | | |
5992// | RESTSubDelReq | |
5993// |---------------->| |
5994// | | |
5995// | RESTSubDelResp| |
5996// |<----------------| |
5997// | | SubDelReq |
5998// | |------------->|
5999// | | |
6000// | | SubDelResp |
6001// | |<-------------|
6002// | | |
6003// | | SubDelReq |
6004// | |------------->|
6005// | | |
6006// | | SubDelResp |
6007// | |<-------------|
6008// | | |
6009//
6010//-----------------------------------------------------------------------------
6011
archaggeafbf95f2021-04-14 08:54:05 +03006012func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6013
6014 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006015
6016 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006017 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006018 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006019 Counter{cSubReqToE2, uint64(subReqCount)},
6020 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006021 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006022 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006023 Counter{cSubDelReqToE2, uint64(subReqCount)},
6024 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006025 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006026 })
6027
6028 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006029 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006030 restSubId := xappConn1.SendRESTSubsReq(t, params)
6031 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6032
6033 assert.Equal(t, len(e2SubsIds), subReqCount)
6034
6035 // Del
6036 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6037 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6038
6039 xappConn1.TestMsgChanEmpty(t)
6040 e2termConn1.TestMsgChanEmpty(t)
6041 mainCtrl.wait_registry_empty(t, 10)
6042
6043 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006044 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006045}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006046
Anssi Mannila27385172021-12-22 09:41:54 +02006047//-----------------------------------------------------------------------------
6048// TestRESTReportSubReqAndSubDelOk19E2Subs
6049//
6050// stub stub
6051// +-------+ +---------+ +---------+
6052// | xapp | | submgr | | e2term |
6053// +-------+ +---------+ +---------+
6054// | | |
6055// | RestSubReq | |
6056// |---------------->| |
6057// | | |
6058// | RESTSubResp | |
6059// |<----------------| |
6060// | | | ------
6061// | | SubReq |
6062// | |------------->|
6063// | | | E2 subscription x 19
6064// | | SubResp |
6065// | |<-------------|
6066// | RESTNotif | |
6067// |<----------------| |
6068// | | | ------
6069// | RESTSubDelReq | |
6070// |---------------->| |
6071// | | |
6072// | RESTSubDelResp| |
6073// |<----------------| |
6074// | | SubDelReq | ------
6075// | |------------->|
6076// | | | E2 subscription delete x 19
6077// | | SubDelResp |
6078// | |<-------------|
6079// | | | ------
6080// | | |
6081//
6082//-----------------------------------------------------------------------------
6083
6084func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006085
6086 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006087
6088 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006089 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006090 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006091 Counter{cSubReqToE2, uint64(subReqCount)},
6092 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006093 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006094 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006095 Counter{cSubDelReqToE2, uint64(subReqCount)},
6096 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006097 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006098 })
6099
6100 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006101 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006102 restSubId := xappConn1.SendRESTSubsReq(t, params)
6103 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6104
6105 assert.Equal(t, len(e2SubsIds), subReqCount)
6106
6107 // Del
6108 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6109 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6110
6111 xappConn1.TestMsgChanEmpty(t)
6112 e2termConn1.TestMsgChanEmpty(t)
6113 mainCtrl.wait_registry_empty(t, 10)
6114
6115 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006116 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006117}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006118
Anssi Mannila27385172021-12-22 09:41:54 +02006119//-----------------------------------------------------------------------------
6120// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6121//
6122// stub stub stub
6123// +-------+ +-------+ +---------+ +---------+
6124// | xapp2 | | xapp1 | | submgr | | e2term |
6125// +-------+ +-------+ +---------+ +---------+
6126// | | | |
6127// | | RESTSubReq1 | |
6128// | |------------->| |
6129// | | RESTSubResp1 | |
6130// | |<-------------| |
6131// | | | |
6132// | | | SubReq1 |
6133// | | |------------->|
6134// | | | |
6135// | RESTSubReq2 | |
6136// |------------------------>| |
6137// | RESTSubResp2 | |
6138// |<------------------------| |
6139// | | | |
6140// | | | SubReq2 |
6141// | | |------------->|
6142// | | | |
6143// | | | SubResp1 |
6144// | | |<-------------|
6145// | | RESTNotif1 | |
6146// | |<-------------| |
6147// | | | |
6148// | | | SubResp2 |
6149// | | |<-------------|
6150// | RESTNotif2 | |
6151// |<------------------------| |
6152// | | | |
6153// | | [SUBS 1 DELETE] |
6154// | | | |
6155// | | [SUBS 2 DELETE] |
6156// | | | |
6157//
6158//-----------------------------------------------------------------------------
6159
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006160func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006161
6162 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006163 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006164 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006165 Counter{cSubReqToE2, 2},
6166 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006167 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006168 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006169 Counter{cSubDelReqToE2, 2},
6170 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006171 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006172 })
6173
6174 // Req1
6175 var params *teststube2ap.RESTSubsReqParams = nil
6176
6177 //Subs Create
6178 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006179 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006180
6181 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6182
6183 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006184 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006185 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006186 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006187 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6188
6189 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006190 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006191 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6192 xappConn2.ExpectRESTNotification(t, restSubId2)
6193 e2termConn1.SendSubsResp(t, crereq, cremsg)
6194 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6195
6196 deleteXapp1Subscription(t, &restSubId1)
6197 deleteXapp2Subscription(t, &restSubId2)
6198
6199 waitSubsCleanup(t, e2SubsId1, 10)
6200 waitSubsCleanup(t, e2SubsId2, 10)
6201
6202 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006203 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006204}
6205
Anssi Mannila27385172021-12-22 09:41:54 +02006206//-----------------------------------------------------------------------------
6207// TestRESTSubReqReportSameActionDiffActionListLen
6208//
6209// stub stub stub
6210// +-------+ +-------+ +---------+ +---------+
6211// | xapp2 | | xapp1 | | submgr | | e2term |
6212// +-------+ +-------+ +---------+ +---------+
6213// | | | |
6214// | | RESTSubReq1 | |
6215// | |------------->| |
6216// | | RESTSubResp1 | |
6217// | |<-------------| |
6218// | | | |
6219// | | | SubReq1 |
6220// | | |------------->|
6221// | | | |
6222// | RESTSubReq2 | |
6223// |------------------------>| |
6224// | RESTSubResp2 | |
6225// |<------------------------| |
6226// | | | |
6227// | | | SubReq2 |
6228// | | |------------->|
6229// | | | |
6230// | | | SubResp1 |
6231// | | |<-------------|
6232// | | RESTNotif1 | |
6233// | |<-------------| |
6234// | | | |
6235// | | | SubResp2 |
6236// | | |<-------------|
6237// | RESTNotif2 | |
6238// |<------------------------| |
6239// | | | |
6240// | | [SUBS 1 DELETE] |
6241// | | | |
6242// | | [SUBS 2 DELETE] |
6243// | | | |
6244//
6245//-----------------------------------------------------------------------------
6246
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006247func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006248
6249 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006250 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006251 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006252 Counter{cSubReqToE2, 2},
6253 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006254 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006255 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006256 Counter{cSubDelReqToE2, 2},
6257 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006258 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006259 })
6260
6261 // Req1
6262 var params *teststube2ap.RESTSubsReqParams = nil
6263
6264 //Subs Create
6265 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006266 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006267
6268 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6269
6270 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006271 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006272 params.SetMeid("RAN_NAME_1")
6273
6274 actionId := int64(1)
6275 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006276 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006277 subsequestActionType := "continue"
6278 timeToWait := "w10ms"
6279 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6280
6281 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006282 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006283 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6284 xappConn2.ExpectRESTNotification(t, restSubId2)
6285 e2termConn1.SendSubsResp(t, crereq, cremsg)
6286 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6287
6288 deleteXapp1Subscription(t, &restSubId1)
6289 deleteXapp2Subscription(t, &restSubId2)
6290
6291 waitSubsCleanup(t, e2SubsId1, 10)
6292 waitSubsCleanup(t, e2SubsId2, 10)
6293
6294 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006295 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006296}
6297
Anssi Mannila27385172021-12-22 09:41:54 +02006298//-----------------------------------------------------------------------------
6299// TestRESTSubReqReportSameActionDiffActionID
6300//
6301// stub stub stub
6302// +-------+ +-------+ +---------+ +---------+
6303// | xapp2 | | xapp1 | | submgr | | e2term |
6304// +-------+ +-------+ +---------+ +---------+
6305// | | | |
6306// | | RESTSubReq1 | |
6307// | |------------->| |
6308// | | RESTSubResp1 | |
6309// | |<-------------| |
6310// | | | |
6311// | | | SubReq1 |
6312// | | |------------->|
6313// | | | |
6314// | RESTSubReq2 | |
6315// |------------------------>| |
6316// | RESTSubResp2 | |
6317// |<------------------------| |
6318// | | | |
6319// | | | SubReq2 |
6320// | | |------------->|
6321// | | | |
6322// | | | SubResp1 |
6323// | | |<-------------|
6324// | | RESTNotif1 | |
6325// | |<-------------| |
6326// | | | |
6327// | | | SubResp2 |
6328// | | |<-------------|
6329// | RESTNotif2 | |
6330// |<------------------------| |
6331// | | | |
6332// | | [SUBS 1 DELETE] |
6333// | | | |
6334// | | [SUBS 2 DELETE] |
6335// | | | |
6336//
6337//-----------------------------------------------------------------------------
6338
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006339func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006340
6341 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006342 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006343 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006344 Counter{cSubReqToE2, 2},
6345 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006346 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006347 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006348 Counter{cSubDelReqToE2, 2},
6349 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006350 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006351 })
6352
6353 // Req1
6354 var params *teststube2ap.RESTSubsReqParams = nil
6355
6356 //Subs Create
6357 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006358 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006359
6360 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6361
6362 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006363 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006364 params.SetMeid("RAN_NAME_1")
6365 params.SetSubActionIDs(int64(2))
6366
6367 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006368 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006369 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6370 xappConn2.ExpectRESTNotification(t, restSubId2)
6371 e2termConn1.SendSubsResp(t, crereq, cremsg)
6372 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6373
6374 deleteXapp1Subscription(t, &restSubId1)
6375 deleteXapp2Subscription(t, &restSubId2)
6376
6377 waitSubsCleanup(t, e2SubsId1, 10)
6378 waitSubsCleanup(t, e2SubsId2, 10)
6379
6380 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006381 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006382}
6383
Anssi Mannila27385172021-12-22 09:41:54 +02006384//-----------------------------------------------------------------------------
6385// TestRESTSubReqDiffActionType
6386//
6387// stub stub stub
6388// +-------+ +-------+ +---------+ +---------+
6389// | xapp2 | | xapp1 | | submgr | | e2term |
6390// +-------+ +-------+ +---------+ +---------+
6391// | | | |
6392// | | RESTSubReq1 | |
6393// | |------------->| |
6394// | | RESTSubResp1 | |
6395// | |<-------------| |
6396// | | | |
6397// | | | SubReq1 |
6398// | | |------------->|
6399// | | | |
6400// | RESTSubReq2 | |
6401// |------------------------>| |
6402// | RESTSubResp2 | |
6403// |<------------------------| |
6404// | | | |
6405// | | | SubReq2 |
6406// | | |------------->|
6407// | | | |
6408// | | | SubResp1 |
6409// | | |<-------------|
6410// | | RESTNotif1 | |
6411// | |<-------------| |
6412// | | | |
6413// | | | SubResp2 |
6414// | | |<-------------|
6415// | RESTNotif2 | |
6416// |<------------------------| |
6417// | | | |
6418// | | [SUBS 1 DELETE] |
6419// | | | |
6420// | | [SUBS 2 DELETE] |
6421// | | | |
6422//
6423//-----------------------------------------------------------------------------
6424
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006425func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006426
6427 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006428 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006429 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006430 Counter{cSubReqToE2, 2},
6431 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006432 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006433 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006434 Counter{cSubDelReqToE2, 2},
6435 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006436 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006437 })
6438
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006439 const e2Timeout int64 = 2
6440 const e2RetryCount int64 = 2
6441 const routingNeeded bool = true
6442
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006443 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006444 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006445 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006446
6447 //Subs Create
6448 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006449 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006450
6451 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6452
6453 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006454 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006455 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006456 params.SetMeid("RAN_NAME_1")
6457
6458 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006459 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006460 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6461 xappConn2.ExpectRESTNotification(t, restSubId2)
6462 e2termConn1.SendSubsResp(t, crereq, cremsg)
6463 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6464
6465 deleteXapp1Subscription(t, &restSubId1)
6466 deleteXapp2Subscription(t, &restSubId2)
6467
6468 waitSubsCleanup(t, e2SubsId1, 10)
6469 waitSubsCleanup(t, e2SubsId2, 10)
6470
6471 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006472 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006473}
6474
Anssi Mannila27385172021-12-22 09:41:54 +02006475//-----------------------------------------------------------------------------
6476// TestRESTSubReqPolicyAndSubDelOkSameAction
6477//
6478// stub stub stub
6479// +-------+ +-------+ +---------+ +---------+
6480// | xapp2 | | xapp1 | | submgr | | e2term |
6481// +-------+ +-------+ +---------+ +---------+
6482// | | | |
6483// | | RESTSubReq1 | |
6484// | |------------->| |
6485// | | RESTSubResp1 | |
6486// | |<-------------| |
6487// | | | |
6488// | | | SubReq1 |
6489// | | |------------->|
6490// | | | |
6491// | RESTSubReq2 | |
6492// |------------------------>| |
6493// | RESTSubResp2 | |
6494// |<------------------------| |
6495// | | | |
6496// | | | SubReq2 |
6497// | | |------------->|
6498// | | | |
6499// | | | SubResp1 |
6500// | | |<-------------|
6501// | | RESTNotif1 | |
6502// | |<-------------| |
6503// | | | |
6504// | | | SubResp2 |
6505// | | |<-------------|
6506// | RESTNotif2 | |
6507// |<------------------------| |
6508// | | | |
6509// | | [SUBS 1 DELETE] |
6510// | | | |
6511// | | [SUBS 2 DELETE] |
6512// | | | |
6513//
6514//-----------------------------------------------------------------------------
6515
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006516func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006517
6518 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006519 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006520 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006521 Counter{cSubReqToE2, 2},
6522 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006523 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006524 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006525 Counter{cSubDelReqToE2, 2},
6526 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006527 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006528 })
6529
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006530 const e2Timeout int64 = 2
6531 const e2RetryCount int64 = 2
6532 const routingNeeded bool = true
6533
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006534 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006535 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006536 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006537
6538 //Subs Create
6539 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006540 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006541
6542 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6543
6544 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006545 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006546 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006547 params.SetMeid("RAN_NAME_1")
6548
6549 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006550 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006551 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6552 xappConn2.ExpectRESTNotification(t, restSubId2)
6553 e2termConn1.SendSubsResp(t, crereq, cremsg)
6554 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6555
6556 deleteXapp1Subscription(t, &restSubId1)
6557 deleteXapp2Subscription(t, &restSubId2)
6558
6559 waitSubsCleanup(t, e2SubsId1, 10)
6560 waitSubsCleanup(t, e2SubsId2, 10)
6561
6562 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006563 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006564}
6565
Anssi Mannila27385172021-12-22 09:41:54 +02006566//-----------------------------------------------------------------------------
6567// TestRESTSubReqReportSameActionDiffActionDefinitionLen
6568//
6569// stub stub stub
6570// +-------+ +-------+ +---------+ +---------+
6571// | xapp2 | | xapp1 | | submgr | | e2term |
6572// +-------+ +-------+ +---------+ +---------+
6573// | | | |
6574// | | RESTSubReq1 | |
6575// | |------------->| |
6576// | | RESTSubResp1 | |
6577// | |<-------------| |
6578// | | | |
6579// | | | SubReq1 |
6580// | | |------------->|
6581// | | | |
6582// | RESTSubReq2 | |
6583// |------------------------>| |
6584// | RESTSubResp2 | |
6585// |<------------------------| |
6586// | | | |
6587// | | | SubReq2 |
6588// | | |------------->|
6589// | | | |
6590// | | | SubResp1 |
6591// | | |<-------------|
6592// | | RESTNotif1 | |
6593// | |<-------------| |
6594// | | | |
6595// | | | SubResp2 |
6596// | | |<-------------|
6597// | RESTNotif2 | |
6598// |<------------------------| |
6599// | | | |
6600// | | [SUBS 1 DELETE] |
6601// | | | |
6602// | | [SUBS 2 DELETE] |
6603// | | | |
6604//
6605//-----------------------------------------------------------------------------
6606
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006607func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006608
6609 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006610 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006611 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006612 Counter{cSubReqToE2, 2},
6613 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006614 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006615 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006616 Counter{cSubDelReqToE2, 2},
6617 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006618 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006619 })
6620
6621 // Req1
6622 var params *teststube2ap.RESTSubsReqParams = nil
6623
6624 //Subs Create
6625 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006626 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006627
6628 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6629
6630 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006631 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006632 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006633 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006634 params.SetSubActionDefinition(actionDefinition)
6635
6636 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006637 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006638 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6639 xappConn2.ExpectRESTNotification(t, restSubId2)
6640 e2termConn1.SendSubsResp(t, crereq, cremsg)
6641 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6642
6643 deleteXapp1Subscription(t, &restSubId1)
6644 deleteXapp2Subscription(t, &restSubId2)
6645
6646 waitSubsCleanup(t, e2SubsId1, 10)
6647 waitSubsCleanup(t, e2SubsId2, 10)
6648
6649 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006650 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006651}
6652
Anssi Mannila27385172021-12-22 09:41:54 +02006653//-----------------------------------------------------------------------------
6654// TestRESTSubReqReportSameActionDiffActionDefinitionContents
6655//
6656// stub stub stub
6657// +-------+ +-------+ +---------+ +---------+
6658// | xapp2 | | xapp1 | | submgr | | e2term |
6659// +-------+ +-------+ +---------+ +---------+
6660// | | | |
6661// | | RESTSubReq1 | |
6662// | |------------->| |
6663// | | RESTSubResp1 | |
6664// | |<-------------| |
6665// | | | |
6666// | | | SubReq1 |
6667// | | |------------->|
6668// | | | |
6669// | RESTSubReq2 | |
6670// |------------------------>| |
6671// | RESTSubResp2 | |
6672// |<------------------------| |
6673// | | | |
6674// | | | SubReq2 |
6675// | | |------------->|
6676// | | | |
6677// | | | SubResp1 |
6678// | | |<-------------|
6679// | | RESTNotif1 | |
6680// | |<-------------| |
6681// | | | |
6682// | | | SubResp2 |
6683// | | |<-------------|
6684// | RESTNotif2 | |
6685// |<------------------------| |
6686// | | | |
6687// | | [SUBS 1 DELETE] |
6688// | | | |
6689// | | [SUBS 2 DELETE] |
6690// | | | |
6691//
6692//-----------------------------------------------------------------------------
6693
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006694func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006695
6696 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006697 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006698 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006699 Counter{cSubReqToE2, 2},
6700 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006701 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006702 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006703 Counter{cSubDelReqToE2, 2},
6704 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006705 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006706 })
6707
6708 // Req1
6709 var params *teststube2ap.RESTSubsReqParams = nil
6710
6711 //Subs Create
6712 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006713 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006714
6715 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6716
6717 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006718 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006719 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006720 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006721 params.SetSubActionDefinition(actionDefinition)
6722
6723 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006724 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006725 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6726 xappConn2.ExpectRESTNotification(t, restSubId2)
6727 e2termConn1.SendSubsResp(t, crereq, cremsg)
6728 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6729
6730 deleteXapp1Subscription(t, &restSubId1)
6731 deleteXapp2Subscription(t, &restSubId2)
6732
6733 waitSubsCleanup(t, e2SubsId1, 10)
6734 waitSubsCleanup(t, e2SubsId2, 10)
6735
6736 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006737 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006738}
6739
Anssi Mannila27385172021-12-22 09:41:54 +02006740//-----------------------------------------------------------------------------
6741// TestRESTSubReqReportSameActionDiffSubsAction
6742//
6743// stub stub stub
6744// +-------+ +-------+ +---------+ +---------+
6745// | xapp2 | | xapp1 | | submgr | | e2term |
6746// +-------+ +-------+ +---------+ +---------+
6747// | | | |
6748// | | RESTSubReq1 | |
6749// | |------------->| |
6750// | | RESTSubResp1 | |
6751// | |<-------------| |
6752// | | | |
6753// | | | SubReq1 |
6754// | | |------------->|
6755// | | | |
6756// | RESTSubReq2 | |
6757// |------------------------>| |
6758// | RESTSubResp2 | |
6759// |<------------------------| |
6760// | | | |
6761// | | | SubReq2 |
6762// | | |------------->|
6763// | | | |
6764// | | | SubResp1 |
6765// | | |<-------------|
6766// | | RESTNotif1 | |
6767// | |<-------------| |
6768// | | | |
6769// | | | SubResp2 |
6770// | | |<-------------|
6771// | RESTNotif2 | |
6772// |<------------------------| |
6773// | | | |
6774// | | [SUBS 1 DELETE] |
6775// | | | |
6776// | | [SUBS 2 DELETE] |
6777// | | | |
6778//
6779//-----------------------------------------------------------------------------
6780
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006781func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006782
6783 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006784 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006785 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006786 Counter{cSubReqToE2, 2},
6787 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006788 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006789 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006790 Counter{cSubDelReqToE2, 2},
6791 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006792 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006793 })
6794
6795 // Req1
6796 var params *teststube2ap.RESTSubsReqParams = nil
6797
6798 //Subs Create
6799 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006800 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006801
6802 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6803
6804 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006805 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006806 params.SetMeid("RAN_NAME_1")
6807 params.SetTimeToWait("w200ms")
6808 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006809 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006810 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6811 xappConn2.ExpectRESTNotification(t, restSubId2)
6812 e2termConn1.SendSubsResp(t, crereq, cremsg)
6813 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6814
6815 deleteXapp1Subscription(t, &restSubId1)
6816 deleteXapp2Subscription(t, &restSubId2)
6817
6818 waitSubsCleanup(t, e2SubsId1, 10)
6819 waitSubsCleanup(t, e2SubsId2, 10)
6820
6821 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006822 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006823}
6824
Anssi Mannila51122392021-05-25 11:51:31 +03006825//-----------------------------------------------------------------------------
6826// TestRESTUnpackSubscriptionResponseDecodeFail
6827//
6828// stub stub
6829// +-------+ +---------+ +---------+
6830// | xapp | | submgr | | e2term |
6831// +-------+ +---------+ +---------+
6832// | | |
6833// | RestSubReq | |
6834// |---------------->| |
6835// | | |
6836// | RESTSubResp | |
6837// |<----------------| |
6838// | | |
6839// | | SubReq |
6840// | |------------->|
6841// | | |
6842// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02006843// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006844// | | |
6845// | | SubReq |
6846// | |------------->|
6847// | | |
6848// | | SubFail | Duplicated action
6849// | |<-------------|
6850// | RESTNotif (fail)| |
6851// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006852// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006853// | [SUBS DELETE] |
6854// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006855//
6856//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006857
Anssi Mannila51122392021-05-25 11:51:31 +03006858func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02006859
6860 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6861 Counter{cRestSubReqFromXapp, 1},
6862 Counter{cRestSubRespToXapp, 1},
6863 Counter{cSubReqToE2, 1},
6864 Counter{cSubReqTimerExpiry, 1},
6865 Counter{cSubReReqToE2, 1},
6866 Counter{cSubRespFromE2, 1},
6867 Counter{cSubFailFromE2, 1},
6868 Counter{cRestSubFailNotifToXapp, 1},
6869 Counter{cRestSubDelReqFromXapp, 1},
6870 Counter{cRestSubDelRespToXapp, 1},
6871 })
6872
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006873 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006874
6875 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006876 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006877 restSubId := xappConn1.SendRESTSubsReq(t, params)
6878
6879 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6880 // Decode of this response fails which will result resending original request
6881 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6882
6883 _, cremsg = e2termConn1.RecvSubsReq(t)
6884
Markku Virtanen55d2a282021-06-04 14:46:56 +03006885 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006886
6887 // Subscription already created in E2 Node.
6888 fparams := &teststube2ap.E2StubSubsFailParams{}
6889 fparams.Set(crereq)
6890 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6891 e2termConn1.SendSubsFail(t, fparams, cremsg)
6892
Anssi Mannila51122392021-05-25 11:51:31 +03006893 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006894 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006895
Anssi Mannilab43397e2021-11-16 12:06:16 +02006896 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6897
Anssi Mannila51122392021-05-25 11:51:31 +03006898 // Wait that subs is cleaned
6899 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6900
6901 xappConn1.TestMsgChanEmpty(t)
6902 e2termConn1.TestMsgChanEmpty(t)
6903 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006904 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006905 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006906}
6907
6908//-----------------------------------------------------------------------------
6909// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6910//
6911// stub stub
6912// +-------+ +---------+ +---------+
6913// | xapp | | submgr | | e2term |
6914// +-------+ +---------+ +---------+
6915// | | |
6916// | RestSubReq | |
6917// |---------------->| |
6918// | | |
6919// | RESTSubResp | |
6920// |<----------------| |
6921// | | |
6922// | | SubReq |
6923// | |------------->|
6924// | | |
6925// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02006926// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03006927// | | |
6928// | | SubReq |
6929// | |------------->|
6930// | | |
6931// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02006932// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03006933// | RESTNotif (fail)| |
6934// |<----------------| |
6935// | | SubDelReq |
6936// | |------------->|
6937// | | |
6938// | | SubDelResp |
6939// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02006940// | | |
6941// | [SUBS DELETE] |
6942// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006943//
6944//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006945
Anssi Mannila51122392021-05-25 11:51:31 +03006946func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02006947
6948 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6949 Counter{cRestSubReqFromXapp, 1},
6950 Counter{cRestSubRespToXapp, 1},
6951 Counter{cSubReqToE2, 1},
6952 Counter{cSubReqTimerExpiry, 2},
6953 Counter{cSubReReqToE2, 1},
6954 Counter{cSubRespFromE2, 1},
6955 Counter{cSubFailFromE2, 1},
6956 Counter{cRestSubFailNotifToXapp, 1},
6957 Counter{cRestSubDelReqFromXapp, 1},
6958 Counter{cRestSubDelRespToXapp, 1},
6959 Counter{cSubDelReqToE2, 1},
6960 Counter{cSubDelRespFromE2, 1},
6961 })
6962
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006963 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006964
6965 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006966 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006967 restSubId := xappConn1.SendRESTSubsReq(t, params)
6968
6969 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6970
Anssi Mannila21782182021-12-10 10:56:02 +02006971 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03006972 orgInstanceId := crereq.RequestId.InstanceId
6973 crereq.RequestId.InstanceId = 0
6974 e2termConn1.SendSubsResp(t, crereq, cremsg)
6975
6976 _, cremsg = e2termConn1.RecvSubsReq(t)
6977
Markku Virtanen55d2a282021-06-04 14:46:56 +03006978 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006979
Anssi Mannila21782182021-12-10 10:56:02 +02006980 // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03006981 fparams := &teststube2ap.E2StubSubsFailParams{}
6982 fparams.Set(crereq)
6983 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6984 e2termConn1.SendSubsFail(t, fparams, cremsg)
6985
6986 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6987 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6988
6989 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006990 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006991
Anssi Mannilab43397e2021-11-16 12:06:16 +02006992 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6993
Anssi Mannila51122392021-05-25 11:51:31 +03006994 // Wait that subs is cleaned
6995 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6996
6997 xappConn1.TestMsgChanEmpty(t)
6998 e2termConn1.TestMsgChanEmpty(t)
6999 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007000 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007001 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007002}
7003
7004//-----------------------------------------------------------------------------
7005// TestRESTUnpackSubscriptionResponseNoTransaction
7006//
7007// stub stub
7008// +-------+ +---------+ +---------+
7009// | xapp | | submgr | | e2term |
7010// +-------+ +---------+ +---------+
7011// | | |
7012// | RestSubReq | |
7013// |---------------->| |
7014// | | |
7015// | RESTSubResp | |
7016// |<----------------| |
7017// | | |
7018// | | SubReq |
7019// | |------------->|
7020// | | |
7021// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007022// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007023// | | |
7024// | | SubReq |
7025// | |------------->|
7026// | | |
7027// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007028// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007029// | RESTNotif (fail)| |
7030// |<----------------| |
7031// | | SubDelReq |
7032// | |------------->|
7033// | | |
7034// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007035// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007036// | | |
7037// | | SubDelReq |
7038// | |------------->|
7039// | | |
7040// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007041// | |<-------------| Ongoing transaction not found.
7042// | | |
7043// | [SUBS DELETE] |
7044// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007045//
7046//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007047
Anssi Mannila51122392021-05-25 11:51:31 +03007048func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007049
7050 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7051 Counter{cRestSubReqFromXapp, 1},
7052 Counter{cRestSubRespToXapp, 1},
7053 Counter{cSubReqToE2, 1},
7054 Counter{cSubReqTimerExpiry, 2},
7055 Counter{cSubReReqToE2, 1},
7056 Counter{cSubRespFromE2, 1},
7057 Counter{cSubFailFromE2, 1},
7058 Counter{cRestSubFailNotifToXapp, 1},
7059 Counter{cRestSubDelReqFromXapp, 1},
7060 Counter{cRestSubDelRespToXapp, 1},
7061 Counter{cSubDelReqToE2, 1},
7062 Counter{cSubDelReqTimerExpiry, 2},
7063 Counter{cSubDelReReqToE2, 1},
7064 Counter{cSubDelRespFromE2, 2},
7065 })
7066
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007067 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007068
7069 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007070 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007071 restSubId := xappConn1.SendRESTSubsReq(t, params)
7072
7073 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7074
7075 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7076 // No transaction exist for this response which will result resending original request
7077 e2termConn1.SendSubsResp(t, crereq, cremsg)
7078
7079 _, cremsg = e2termConn1.RecvSubsReq(t)
7080
Markku Virtanen55d2a282021-06-04 14:46:56 +03007081 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007082
7083 // Subscription already created in E2 Node.
7084 fparams := &teststube2ap.E2StubSubsFailParams{}
7085 fparams.Set(crereq)
7086 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7087 e2termConn1.SendSubsFail(t, fparams, cremsg)
7088
7089 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7090 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7091
7092 // Resending happens because there no transaction
7093 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7094 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7095
7096 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007097 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007098
Anssi Mannilab43397e2021-11-16 12:06:16 +02007099 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7100
Anssi Mannila51122392021-05-25 11:51:31 +03007101 // Wait that subs is cleaned
7102 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7103
7104 xappConn1.TestMsgChanEmpty(t)
7105 e2termConn1.TestMsgChanEmpty(t)
7106 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007107 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007108 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007109}
7110
7111//-----------------------------------------------------------------------------
7112// TestRESTUnpackSubscriptionFailureDecodeFail
7113//
7114// stub stub
7115// +-------+ +---------+ +---------+
7116// | xapp | | submgr | | e2term |
7117// +-------+ +---------+ +---------+
7118// | | |
7119// | RestSubReq | |
7120// |---------------->| |
7121// | | |
7122// | RESTSubResp | |
7123// |<----------------| |
7124// | | |
7125// | | SubReq |
7126// | |------------->|
7127// | | |
7128// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007129// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007130// | | |
7131// | | SubReq |
7132// | |------------->|
7133// | | |
7134// | | SubFail | Duplicated action
7135// | |<-------------|
7136// | RESTNotif (fail)| |
7137// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007138// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007139// | [SUBS DELETE] |
7140// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007141//
7142//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007143
Anssi Mannila51122392021-05-25 11:51:31 +03007144func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007145
7146 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7147 Counter{cRestSubReqFromXapp, 1},
7148 Counter{cRestSubRespToXapp, 1},
7149 Counter{cSubReqToE2, 1},
7150 Counter{cSubReqTimerExpiry, 1},
7151 Counter{cSubReReqToE2, 1},
7152 Counter{cSubFailFromE2, 2},
7153 Counter{cRestSubFailNotifToXapp, 1},
7154 Counter{cRestSubDelReqFromXapp, 1},
7155 Counter{cRestSubDelRespToXapp, 1},
7156 })
7157
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007158 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007159
7160 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007161 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007162 restSubId := xappConn1.SendRESTSubsReq(t, params)
7163
7164 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7165
7166 // Decode of this response fails which will result resending original request
7167 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7168
7169 _, cremsg = e2termConn1.RecvSubsReq(t)
7170
Markku Virtanen55d2a282021-06-04 14:46:56 +03007171 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007172
7173 // Subscription already created in E2 Node.
7174 fparams := &teststube2ap.E2StubSubsFailParams{}
7175 fparams.Set(crereq)
7176 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7177 e2termConn1.SendSubsFail(t, fparams, cremsg)
7178
Anssi Mannila51122392021-05-25 11:51:31 +03007179 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007180 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007181
Anssi Mannilab43397e2021-11-16 12:06:16 +02007182 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7183
Anssi Mannila51122392021-05-25 11:51:31 +03007184 // Wait that subs is cleaned
7185 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7186
7187 xappConn1.TestMsgChanEmpty(t)
7188 e2termConn1.TestMsgChanEmpty(t)
7189 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007190 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007191 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007192}
7193
7194//-----------------------------------------------------------------------------
7195// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7196//
7197// stub stub
7198// +-------+ +---------+ +---------+
7199// | xapp | | submgr | | e2term |
7200// +-------+ +---------+ +---------+
7201// | | |
7202// | RestSubReq | |
7203// |---------------->| |
7204// | | |
7205// | RESTSubResp | |
7206// |<----------------| |
7207// | | |
7208// | | SubReq |
7209// | |------------->|
7210// | | |
7211// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007212// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007213// | | |
7214// | | SubReq |
7215// | |------------->|
7216// | | |
7217// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007218// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007219// | RESTNotif (fail)| |
7220// |<----------------| |
7221// | | SubDelReq |
7222// | |------------->|
7223// | | |
7224// | | SubDelResp |
7225// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007226// | | |
7227// | [SUBS DELETE] |
7228// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007229//
7230//-----------------------------------------------------------------------------
7231func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007232
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007233 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007234
Anssi Mannila21782182021-12-10 10:56:02 +02007235 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7236 Counter{cRestSubReqFromXapp, 1},
7237 Counter{cRestSubRespToXapp, 1},
7238 Counter{cSubReqToE2, 1},
7239 Counter{cSubReqTimerExpiry, 2},
7240 Counter{cSubReReqToE2, 1},
7241 Counter{cSubFailFromE2, 2},
7242 Counter{cRestSubFailNotifToXapp, 1},
7243 Counter{cRestSubDelReqFromXapp, 1},
7244 Counter{cRestSubDelRespToXapp, 1},
7245 Counter{cSubDelReqToE2, 1},
7246 Counter{cSubDelRespFromE2, 1},
7247 })
7248
Anssi Mannila51122392021-05-25 11:51:31 +03007249 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007250 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007251 restSubId := xappConn1.SendRESTSubsReq(t, params)
7252
7253 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7254
Anssi Mannila21782182021-12-10 10:56:02 +02007255 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007256 fparams := &teststube2ap.E2StubSubsFailParams{}
7257 fparams.Set(crereq)
7258 fparams.Fail.RequestId.InstanceId = 0
7259 e2termConn1.SendSubsFail(t, fparams, cremsg)
7260
7261 _, cremsg = e2termConn1.RecvSubsReq(t)
7262
Markku Virtanen55d2a282021-06-04 14:46:56 +03007263 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007264
Anssi Mannila21782182021-12-10 10:56:02 +02007265 // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03007266 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7267 e2termConn1.SendSubsFail(t, fparams, cremsg)
7268
7269 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7270 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7271
7272 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007273 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007274
Anssi Mannilab43397e2021-11-16 12:06:16 +02007275 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7276
Anssi Mannila51122392021-05-25 11:51:31 +03007277 // Wait that subs is cleaned
7278 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7279
7280 xappConn1.TestMsgChanEmpty(t)
7281 e2termConn1.TestMsgChanEmpty(t)
7282 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007283 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007284 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007285}
7286
7287//-----------------------------------------------------------------------------
7288// TestRESTUnpackSubscriptionFailureNoTransaction
7289//
7290// stub stub
7291// +-------+ +---------+ +---------+
7292// | xapp | | submgr | | e2term |
7293// +-------+ +---------+ +---------+
7294// | | |
7295// | RestSubReq | |
7296// |---------------->| |
7297// | | |
7298// | RESTSubResp | |
7299// |<----------------| |
7300// | | |
7301// | | SubReq |
7302// | |------------->|
7303// | | |
7304// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007305// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007306// | | |
7307// | | SubReq |
7308// | |------------->|
7309// | | |
7310// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007311// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007312// | RESTNotif (fail)| |
7313// |<----------------| |
7314// | | SubDelReq |
7315// | |------------->|
7316// | | |
7317// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007318// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7319// | | |
7320// | | SubDelReq |
7321// | |------------->|
7322// | | |
7323// | | SubDelResp |
7324// | |<-------------| Ongoing transaction not found.
7325// | | |
7326// | [SUBS DELETE] |
7327// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007328//
7329//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007330
Anssi Mannila51122392021-05-25 11:51:31 +03007331func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007332
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007333 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007334
Anssi Mannila21782182021-12-10 10:56:02 +02007335 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7336 Counter{cRestSubReqFromXapp, 1},
7337 Counter{cRestSubRespToXapp, 1},
7338 Counter{cSubReqToE2, 1},
7339 Counter{cSubReqTimerExpiry, 2},
7340 Counter{cSubReReqToE2, 1},
7341 Counter{cSubFailFromE2, 2},
7342 Counter{cRestSubFailNotifToXapp, 1},
7343 Counter{cRestSubDelReqFromXapp, 1},
7344 Counter{cRestSubDelRespToXapp, 1},
7345 Counter{cSubDelReqToE2, 1},
7346 Counter{cSubDelReqTimerExpiry, 2},
7347 Counter{cSubDelReReqToE2, 1},
7348 Counter{cSubDelRespFromE2, 2},
7349 })
7350
Anssi Mannila51122392021-05-25 11:51:31 +03007351 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007352 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007353 restSubId := xappConn1.SendRESTSubsReq(t, params)
7354
7355 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7356
7357 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7358
7359 // No transaction exist for this response which will result resending original request
7360 fparams := &teststube2ap.E2StubSubsFailParams{}
7361 fparams.Set(crereq)
7362 e2termConn1.SendSubsFail(t, fparams, cremsg)
7363
7364 _, cremsg = e2termConn1.RecvSubsReq(t)
7365
Markku Virtanen55d2a282021-06-04 14:46:56 +03007366 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007367
7368 // Subscription already created in E2 Node.
7369 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7370 e2termConn1.SendSubsFail(t, fparams, cremsg)
7371
7372 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7373 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7374
7375 // Resending happens because there no transaction
7376 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7377 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7378
7379 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007380 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007381
Anssi Mannilab43397e2021-11-16 12:06:16 +02007382 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7383
Anssi Mannila51122392021-05-25 11:51:31 +03007384 // Wait that subs is cleaned
7385 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7386
7387 xappConn1.TestMsgChanEmpty(t)
7388 e2termConn1.TestMsgChanEmpty(t)
7389 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007390 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007391 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007392}
7393
7394//-----------------------------------------------------------------------------
7395// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7396//
7397// stub stub
7398// +-------+ +---------+ +---------+
7399// | xapp | | submgr | | e2term |
7400// +-------+ +---------+ +---------+
7401// | | |
7402// | [SUBS CREATE] |
7403// | | |
7404// | | |
7405// | RESTSubDelReq | |
7406// |---------------->| |
7407// | | |
7408// | RESTSubDelResp | |
7409// |<----------------| |
7410// | | |
7411// | | SubDelReq |
7412// | |------------->|
7413// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007414// | | SubDelResp | ASN.1 decode fails.
7415// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007416// | | |
7417// | | SubDelReq |
7418// | |------------->|
7419// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007420// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007421// | |<-------------|
7422// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007423// | [SUBS DELETE] |
7424// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007425//
7426//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007427
Anssi Mannila51122392021-05-25 11:51:31 +03007428func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007429
Anssi Mannila21782182021-12-10 10:56:02 +02007430 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7431 Counter{cRestSubReqFromXapp, 1},
7432 Counter{cRestSubRespToXapp, 1},
7433 Counter{cSubReqToE2, 1},
7434 Counter{cSubRespFromE2, 1},
7435 Counter{cRestSubNotifToXapp, 1},
7436 Counter{cRestSubDelReqFromXapp, 1},
7437 Counter{cRestSubDelRespToXapp, 1},
7438 Counter{cSubDelReqToE2, 1},
7439 Counter{cSubDelReqTimerExpiry, 1},
7440 Counter{cSubDelReReqToE2, 1},
7441 Counter{cSubDelFailFromE2, 1},
7442 Counter{cSubDelRespFromE2, 1},
7443 })
7444
Anssi Mannila51122392021-05-25 11:51:31 +03007445 // Req
7446 var params *teststube2ap.RESTSubsReqParams = nil
7447 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7448
7449 // Del
7450 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7451
7452 // E2t: Receive 1st SubsDelReq
7453 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7454
7455 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02007456 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03007457
7458 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7459 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7460
7461 // Subscription does not exist in in E2 Node.
7462 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7463
7464 // Wait that subs is cleaned
7465 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7466
7467 xappConn1.TestMsgChanEmpty(t)
7468 e2termConn1.TestMsgChanEmpty(t)
7469 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007470 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007471 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007472}
7473
7474//-----------------------------------------------------------------------------
7475// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
7476//
7477// stub stub
7478// +-------+ +---------+ +---------+
7479// | xapp | | submgr | | e2term |
7480// +-------+ +---------+ +---------+
7481// | | |
7482// | [SUBS CREATE] |
7483// | | |
7484// | | |
7485// | RESTSubDelReq | |
7486// |---------------->| |
7487// | | |
7488// | RESTSubDelResp | |
7489// |<----------------| |
7490// | | |
7491// | | SubDelReq |
7492// | |------------->|
7493// | | |
7494// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007495// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007496// | | |
7497// | | SubDelReq |
7498// | |------------->|
7499// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007500// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007501// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007502// | | |
7503// | [SUBS DELETE] |
7504// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007505//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007506
Anssi Mannila51122392021-05-25 11:51:31 +03007507func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007508
Anssi Mannila21782182021-12-10 10:56:02 +02007509 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7510 Counter{cRestSubReqFromXapp, 1},
7511 Counter{cRestSubRespToXapp, 1},
7512 Counter{cSubReqToE2, 1},
7513 Counter{cSubRespFromE2, 1},
7514 Counter{cRestSubNotifToXapp, 1},
7515 Counter{cRestSubDelReqFromXapp, 1},
7516 Counter{cRestSubDelRespToXapp, 1},
7517 Counter{cSubDelReqToE2, 1},
7518 Counter{cSubDelReqTimerExpiry, 1},
7519 Counter{cSubDelReReqToE2, 1},
7520 Counter{cSubDelRespFromE2, 1},
7521 Counter{cSubDelFailFromE2, 1},
7522 })
7523
Anssi Mannila51122392021-05-25 11:51:31 +03007524 // Req
7525 var params *teststube2ap.RESTSubsReqParams = nil
7526 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7527
7528 // Del
7529 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7530
7531 // E2t: Receive 1st SubsDelReq
7532 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7533
7534 // Unknown instanceId in this response which will result resending original request
7535 delreq.RequestId.InstanceId = 0
7536 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7537
7538 // E2t: Receive 2nd SubsDelReq
7539 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7540
7541 // Subscription does not exist in in E2 Node.
7542 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7543
7544 // Wait that subs is cleaned
7545 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7546
7547 xappConn1.TestMsgChanEmpty(t)
7548 e2termConn1.TestMsgChanEmpty(t)
7549 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007550 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007551 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007552}
7553
7554//-----------------------------------------------------------------------------
7555// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
7556//
7557// stub stub
7558// +-------+ +---------+ +---------+
7559// | xapp | | submgr | | e2term |
7560// +-------+ +---------+ +---------+
7561// | | |
7562// | [SUBS CREATE] |
7563// | | |
7564// | | |
7565// | RESTSubDelReq | |
7566// |---------------->| |
7567// | | |
7568// | RESTSubDelResp | |
7569// |<----------------| |
7570// | | |
7571// | | SubDelReq |
7572// | |------------->|
7573// | | |
7574// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007575// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007576// | | |
7577// | | SubDelReq |
7578// | |------------->|
7579// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007580// | | SubDelFail | Subscription does exist any more in E2 node
7581// | |<-------------| Ongoing transaction not found. This will result timer expiry
7582// | | |
7583// | [SUBS DELETE] |
7584// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007585//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007586
Anssi Mannila51122392021-05-25 11:51:31 +03007587func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007588
Anssi Mannila21782182021-12-10 10:56:02 +02007589 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7590 Counter{cRestSubReqFromXapp, 1},
7591 Counter{cRestSubRespToXapp, 1},
7592 Counter{cSubReqToE2, 1},
7593 Counter{cSubRespFromE2, 1},
7594 Counter{cRestSubNotifToXapp, 1},
7595 Counter{cRestSubDelReqFromXapp, 1},
7596 Counter{cRestSubDelRespToXapp, 1},
7597 Counter{cSubDelReqToE2, 1},
7598 Counter{cSubDelReqTimerExpiry, 2},
7599 Counter{cSubDelReReqToE2, 1},
7600 Counter{cSubDelRespFromE2, 1},
7601 Counter{cSubDelFailFromE2, 1},
7602 })
7603
Anssi Mannila51122392021-05-25 11:51:31 +03007604 // Req
7605 var params *teststube2ap.RESTSubsReqParams = nil
7606 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7607
7608 // Del
7609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7610
7611 // E2t: Receive 1st SubsDelReq
7612 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7613
7614 mainCtrl.MakeTransactionNil(t, e2SubsId)
7615
7616 // No transaction exist for this response which will result resending original request
7617 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7618
7619 // E2t: Receive 2nd SubsDelReq
7620 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7621
7622 // Subscription does not exist in in E2 Node.
7623 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7624
7625 // Wait that subs is cleaned
7626 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7627
7628 xappConn1.TestMsgChanEmpty(t)
7629 e2termConn1.TestMsgChanEmpty(t)
7630 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007631 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007632 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007633}
7634
7635//-----------------------------------------------------------------------------
7636// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
7637//
7638// stub stub
7639// +-------+ +---------+ +---------+
7640// | xapp | | submgr | | e2term |
7641// +-------+ +---------+ +---------+
7642// | | |
7643// | [SUBS CREATE] |
7644// | | |
7645// | | |
7646// | RESTSubDelReq | |
7647// |---------------->| |
7648// | | |
7649// | RESTSubDelResp | |
7650// |<----------------| |
7651// | | |
7652// | | SubDelReq |
7653// | |------------->|
7654// | | |
7655// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007656// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007657// | | |
7658// | | SubDelReq |
7659// | |------------->|
7660// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007661// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007662// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007663// | | |
7664// | [SUBS DELETE] |
7665// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007666//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007667
Anssi Mannila51122392021-05-25 11:51:31 +03007668func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007669
Anssi Mannila21782182021-12-10 10:56:02 +02007670 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7671 Counter{cRestSubReqFromXapp, 1},
7672 Counter{cRestSubRespToXapp, 1},
7673 Counter{cSubReqToE2, 1},
7674 Counter{cSubRespFromE2, 1},
7675 Counter{cRestSubNotifToXapp, 1},
7676 Counter{cRestSubDelReqFromXapp, 1},
7677 Counter{cRestSubDelRespToXapp, 1},
7678 Counter{cSubDelReqToE2, 1},
7679 Counter{cSubDelReqTimerExpiry, 1},
7680 Counter{cSubDelReReqToE2, 1},
7681 Counter{cSubDelFailFromE2, 2},
7682 })
7683
Anssi Mannila51122392021-05-25 11:51:31 +03007684 // Req
7685 var params *teststube2ap.RESTSubsReqParams = nil
7686 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7687
7688 // Del
7689 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7690
7691 // E2t: Receive 1st SubsDelReq
7692 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7693
7694 // Decode of this response fails which will result resending original request
7695 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
7696
7697 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7698 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7699
7700 // Subscription does not exist in in E2 Node.
7701 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7702
7703 // Wait that subs is cleaned
7704 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7705
7706 xappConn1.TestMsgChanEmpty(t)
7707 e2termConn1.TestMsgChanEmpty(t)
7708 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007709 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007710 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007711}
7712
7713//-----------------------------------------------------------------------------
7714// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
7715//
7716// stub stub
7717// +-------+ +---------+ +---------+
7718// | xapp | | submgr | | e2term |
7719// +-------+ +---------+ +---------+
7720// | | |
7721// | [SUBS CREATE] |
7722// | | |
7723// | | |
7724// | RESTSubDelReq | |
7725// |---------------->| |
7726// | | |
7727// | RESTSubDelResp | |
7728// |<----------------| |
7729// | | |
7730// | | SubDelReq |
7731// | |------------->|
7732// | | |
7733// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007734// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007735// | | |
7736// | | SubDelReq |
7737// | |------------->|
7738// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007739// | | SubDelFail | Subscription does exist any more in E2 node
7740// | |<-------------| No valid subscription found with subIds [0].
7741// | | |
7742// | [SUBS DELETE] |
7743// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007744//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007745
Anssi Mannila51122392021-05-25 11:51:31 +03007746func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007747
Anssi Mannila21782182021-12-10 10:56:02 +02007748 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7749 Counter{cRestSubReqFromXapp, 1},
7750 Counter{cRestSubRespToXapp, 1},
7751 Counter{cSubReqToE2, 1},
7752 Counter{cSubRespFromE2, 1},
7753 Counter{cRestSubNotifToXapp, 1},
7754 Counter{cRestSubDelReqFromXapp, 1},
7755 Counter{cRestSubDelRespToXapp, 1},
7756 Counter{cSubDelReqToE2, 1},
7757 Counter{cSubDelReqTimerExpiry, 1},
7758 Counter{cSubDelReReqToE2, 1},
7759 Counter{cSubDelFailFromE2, 2},
7760 })
7761
Anssi Mannila51122392021-05-25 11:51:31 +03007762 // Req
7763 var params *teststube2ap.RESTSubsReqParams = nil
7764 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7765
7766 // Del
7767 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7768
7769 // E2t: Receive 1st SubsDelReq
7770 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7771
Anssi Mannila21782182021-12-10 10:56:02 +02007772 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007773 delreq.RequestId.InstanceId = 0
7774 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7775
7776 // E2t: Receive 2nd SubsDelReq
7777 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7778
Anssi Mannila21782182021-12-10 10:56:02 +02007779 // Subscription does not exist in in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03007780 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7781
7782 // Wait that subs is cleaned
7783 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7784
7785 xappConn1.TestMsgChanEmpty(t)
7786 e2termConn1.TestMsgChanEmpty(t)
7787 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007788 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007789 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007790}
7791
7792//-----------------------------------------------------------------------------
7793// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
7794//
7795// stub stub
7796// +-------+ +---------+ +---------+
7797// | xapp | | submgr | | e2term |
7798// +-------+ +---------+ +---------+
7799// | | |
7800// | [SUBS CREATE] |
7801// | | |
7802// | | |
7803// | RESTSubDelReq | |
7804// |---------------->| |
7805// | | |
7806// | RESTSubDelResp | |
7807// |<----------------| |
7808// | | |
7809// | | SubDelReq |
7810// | |------------->|
7811// | | |
7812// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007813// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007814// | | |
7815// | | SubDelReq |
7816// | |------------->|
7817// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007818// | | SubDelFail | Subscription does exist any more in E2 node
7819// | |<-------------| Ongoing transaction not found. This will result timer expiry
7820// | | |
7821// | [SUBS DELETE] |
7822// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007823//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007824
Anssi Mannila51122392021-05-25 11:51:31 +03007825func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007826
Anssi Mannila21782182021-12-10 10:56:02 +02007827 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7828 Counter{cRestSubReqFromXapp, 1},
7829 Counter{cRestSubRespToXapp, 1},
7830 Counter{cSubReqToE2, 1},
7831 Counter{cSubRespFromE2, 1},
7832 Counter{cRestSubNotifToXapp, 1},
7833 Counter{cRestSubDelReqFromXapp, 1},
7834 Counter{cRestSubDelRespToXapp, 1},
7835 Counter{cSubDelReqToE2, 1},
7836 Counter{cSubDelReqTimerExpiry, 2},
7837 Counter{cSubDelReReqToE2, 1},
7838 Counter{cSubDelFailFromE2, 2},
7839 })
7840
Anssi Mannila51122392021-05-25 11:51:31 +03007841 // Req
7842 var params *teststube2ap.RESTSubsReqParams = nil
7843 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7844
7845 // Del
7846 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7847
7848 // E2t: Receive 1st SubsDelReq
7849 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7850
7851 mainCtrl.MakeTransactionNil(t, e2SubsId)
7852
7853 // No transaction exist for this response which will result resending original request
7854 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7855
7856 // E2t: Receive 2nd SubsDelReq
7857 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7858
7859 // Subscription does not exist in in E2 Node.
7860 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7861
7862 // Wait that subs is cleaned
7863 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7864
7865 xappConn1.TestMsgChanEmpty(t)
7866 e2termConn1.TestMsgChanEmpty(t)
7867 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007868 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007869 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007870}
7871
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007872//-----------------------------------------------------------------------------
7873// TestRESTSubReqFailAsn1PackSubReqError
7874//
7875// stub stub
7876// +-------+ +---------+ +---------+
7877// | xapp | | submgr | | e2term |
7878// +-------+ +---------+ +---------+
7879// | | |
7880// | RESTSubReq | |
7881// |---------------->| |
7882// | | |
7883// | RESTSubResp | |
7884// |<----------------| |
7885// | | |
7886// | ASN.1 encode fails |
7887// | | |
7888// | | SubDelReq |
7889// | |------------->|
7890// | | |
7891// | | SubDelFail |
7892// | |<-------------|
7893// | | |
7894// | RESTNotif | |
7895// | unsuccess | |
7896// |<----------------| |
7897// | | |
7898// | [SUBS DELETE] |
7899// | | |
7900//
7901//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007902
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007903func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
7904
7905 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007906 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007907 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007908 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02007909 Counter{cRestSubDelReqFromXapp, 1},
7910 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007911 })
7912
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007913 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007914
7915 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007916 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007917 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
7918
7919 // Req
7920 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007921 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007922
7923 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03007924 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007925
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007926 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007927 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007928
7929 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007930
7931 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7932
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007933 // Wait that subs is cleaned
7934 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007935 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007936 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007937}
7938
Anssi Mannila27385172021-12-22 09:41:54 +02007939//-----------------------------------------------------------------------------
7940// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
7941//
7942// stub stub
7943// +-------+ +---------+ +---------+
7944// | xapp | | submgr | | e2term |
7945// +-------+ +---------+ +---------+
7946// | | |
7947// | RESTSubReq | |
7948// |---------------->| |
7949// | | |
7950// | RESTSubResp | |
7951// |<----------------| |
7952// | | SubReq |
7953// | |------------->|
7954// | | |
7955// | | SubResp |
7956// | |<-------------|
7957// | | |
7958// | RESTNotif | |
7959// |<----------------| |
7960// | | |
7961// | RESTSubReq | | Policy modification
7962// |---------------->| |
7963// | | |
7964// | RESTSubResp | |
7965// |<----------------| |
7966// | | SubReq |
7967// | |------------->|
7968// | | |
7969// | | |
7970// | RESTNotif(Unsuccessful) | E2 timeout
7971// |<----------------| |
7972// | | |
7973// | RESTSubDelReq | |
7974// |---------------->| |
7975// | | |
7976// | | SubDelReq |
7977// | |------------->|
7978// | | |
7979// | | SubDelResp |
7980// | |<-------------|
7981// | | |
7982// | RESTSubDelResp | |
7983// |<----------------| |
7984//
7985//-----------------------------------------------------------------------------
7986
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007987func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007988
7989 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7990 Counter{cRestSubReqFromXapp, 2},
7991 Counter{cRestSubRespToXapp, 2},
7992 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02007993 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007994 Counter{cSubRespFromE2, 1},
7995 Counter{cRestSubNotifToXapp, 1},
7996 Counter{cRestSubFailNotifToXapp, 1},
7997 Counter{cRestSubDelReqFromXapp, 1},
7998 Counter{cSubDelReqToE2, 1},
7999 Counter{cSubDelRespFromE2, 1},
8000 Counter{cRestSubDelRespToXapp, 1},
8001 })
8002
8003 const e2Timeout int64 = 1
8004 const e2RetryCount int64 = 0
8005 const routingNeeded bool = false
8006
8007 // Req1
8008 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8009 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8010
8011 // Subs Create
8012 restSubId := xappConn1.SendRESTSubsReq(t, params)
8013 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8014
8015 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8016 xappConn1.ExpectRESTNotification(t, restSubId)
8017 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8018 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8019 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8020
8021 // Policy change
8022 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8023 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8024 params.SetSubscriptionID(&restSubId)
8025 params.SetTimeToWait("w200ms")
8026 restSubId = xappConn1.SendRESTSubsReq(t, params)
8027 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8028
8029 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8030 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008031 // SubsResp is missing, e2SubsId will be 0
8032 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8033 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008034
8035 // Del
8036 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8037 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8038 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8039
8040 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008041 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008042 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008043}
8044
8045//-----------------------------------------------------------------------------
8046// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8047//
8048// stub stub
8049// +-------+ +---------+ +---------+
8050// | xapp | | submgr | | e2term |
8051// +-------+ +---------+ +---------+
8052// | | |
8053// | RESTSubReq | |
8054// |---------------->| |
8055// | | |
8056// | RESTSubResp | |
8057// |<----------------| |
8058// | | SubReq |
8059// | |------------->|
8060// | | |
8061// | | SubResp |
8062// | |<-------------|
8063// | | |
8064// | RESTNotif | |
8065// |<----------------| |
8066// | | |
8067// | RESTSubReq | |
8068// |---------------->| |
8069// | | |
8070// | RESTSubResp | |
8071// |<----------------| |
8072// | | SubReq |
8073// | |------------->|
8074// | |
8075// | Submgr restart |
8076// | | |
8077// | RESTSubDelReq | |
8078// |---------------->| |
8079// | | |
8080// | | SubDelReq |
8081// | |------------->|
8082// | | |
8083// | | SubDelResp |
8084// | |<-------------|
8085// | | |
8086// | RESTSubDelResp | |
8087// |<----------------| |
8088//
8089//-----------------------------------------------------------------------------
8090
8091func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008092
8093 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8094 Counter{cRestSubReqFromXapp, 2},
8095 Counter{cRestSubRespToXapp, 2},
8096 Counter{cSubReqToE2, 2},
8097 Counter{cSubRespFromE2, 1},
8098 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008099 Counter{cRestSubDelReqFromXapp, 1},
8100 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008101 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008102 Counter{cRestSubDelRespToXapp, 1},
8103 })
8104
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008105 const e2Timeout int64 = 1
8106 const e2RetryCount int64 = 0
8107 const routingNeeded bool = false
8108
8109 // Req1
8110 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8111 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8112 // Create subscription
8113 restSubId := xappConn1.SendRESTSubsReq(t, params)
8114 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8115
8116 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8117 xappConn1.ExpectRESTNotification(t, restSubId)
8118 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8119 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8120 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8121
8122 // Check subscription
8123 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8124
8125 // Policy change
8126 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8127 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8128 params.SetSubscriptionID(&restSubId)
8129 params.SetTimeToWait("w200ms")
8130 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8131 restSubId = xappConn1.SendRESTSubsReq(t, params)
8132 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8133
8134 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8135 mainCtrl.SetResetTestFlag(t, false)
8136
8137 // SubsResp is missing due to submgr restart
8138
8139 mainCtrl.SimulateRestart(t)
8140 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8141
Anssi Mannila54838ed2021-11-19 11:25:01 +02008142 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8143 // That needs to be completed before successful subscription query is possible
8144 <-time.After(time.Second * 1)
8145
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008146 // Check subscription
8147 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8148
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008149 // Delete subscription
8150 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8151 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8152 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8153
8154 //Wait that subs is cleaned
8155 waitSubsCleanup(t, e2SubsId, 10)
8156
8157 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008158 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008159}
8160
archaggeafbf95f2021-04-14 08:54:05 +03008161////////////////////////////////////////////////////////////////////////////////////
8162// Services for UT cases
8163////////////////////////////////////////////////////////////////////////////////////
8164const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008165const host string = "localhost"
8166
8167func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8168 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008169 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008170 }
8171 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008172 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008173
8174 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8175 fromXappConn.ExpectRESTNotification(t, restSubId)
8176 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8177 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008178 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008179
8180 return restSubId, e2SubsId
8181}
8182
8183func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8184
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008185 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008186 if meid != "" {
8187 params.SetMeid(meid)
8188 }
8189 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8190 restSubId := xappConn2.SendRESTSubsReq(t, params)
8191 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008192 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008193 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008194 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008195
8196 return restSubId, e2SubsId
8197}
8198
8199func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008200
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008201 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008202 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008203 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008204
8205 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8206 xappConn1.ExpectRESTNotification(t, restSubId)
8207 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8208 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008209 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008210
8211 return restSubId, e2SubsId
8212}
8213
8214func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008215 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008216 restSubId := xappConn1.SendRESTSubsReq(t, params)
8217
8218 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8219 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8220 fparams1.Set(crereq1)
8221 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8222
8223 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8224 xappConn1.ExpectRESTNotification(t, restSubId)
8225 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8226 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008227 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008228
8229 return restSubId, e2SubsId
8230}
8231
8232func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8233 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8234 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8235 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8236}
8237
8238func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8239 xappConn1.SendRESTSubsDelReq(t, restSubId)
8240 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8241 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8242}
8243
8244func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8245 xappConn2.SendRESTSubsDelReq(t, restSubId)
8246 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8247 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8248}
8249
8250func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8251 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008252 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8253 assert.Equal(t, meid, resp[0].Meid)
8254 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008255}
8256
8257func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8258 //Wait that subs is cleaned
8259 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8260
8261 xappConn1.TestMsgChanEmpty(t)
8262 xappConn2.TestMsgChanEmpty(t)
8263 e2termConn1.TestMsgChanEmpty(t)
8264 mainCtrl.wait_registry_empty(t, timeout)
8265}
8266
8267func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8268
8269 var e2SubsId []uint32
8270
8271 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008272 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008273 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8274 fromXappConn.ExpectRESTNotification(t, restSubId)
8275 toE2termConn.SendSubsResp(t, crereq, cremsg)
8276 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8277 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008278 xapp.Logger.Debug("TEST: %v", e2SubsId)
8279 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008280 <-time.After(100 * time.Millisecond)
8281 }
8282 return e2SubsId
8283}
8284
8285func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8286
8287 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008288 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008289 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8290 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8291 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008292 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008293 <-time.After(100 * time.Millisecond)
8294 }
8295
8296 // Wait that subs is cleaned
8297 for i := 0; i < len(e2SubsIds); i++ {
8298 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8299 }
8300
8301}