blob: 538e214dba34014b3d39de1542af26a6032dd9d2 [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannila92c38552021-12-29 09:59:24 +020023 "encoding/json"
aditverm323c77e2023-09-20 09:50:47 +053024 "fmt"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000025 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020026 "testing"
27 "time"
28
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000030 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030031 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020032 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020033 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
34 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020035)
36
Anssi Mannila27385172021-12-22 09:41:54 +020037// In below test cases there is done only one retry for E2 messages
38// In Helm chart retry count is currently 2 By default. Retry count
39// used in test cases is defined in submgr-config.yaml file.
40
Markku Virtanenac8bde42021-05-25 09:54:42 +000041func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030042 // The effect of this call shall endure though the UT suite!
43 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000044 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000045 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
46
Anssi Mannila3d80b722021-11-12 13:17:15 +020047 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000048 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030049 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000050
Markku Virtanenac8bde42021-05-25 09:54:42 +000051}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030052func TestRanStatusChangeViaSDLNotification(t *testing.T) {
53
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020054 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
55 Counter{cE2StateChangedToUp, 3},
56 })
57
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030058 // Current UT test cases use these ran names
59 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
60 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
61 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
62
63 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
64 mainCtrl.c.e2IfState.SubscribeChannels()
65
66 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
67 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
68 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020069
70 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030071}
72
73//-----------------------------------------------------------------------------
74// TestRESTSubReqAfterE2ConnBreak
75//
76// stub stub
77// +-------+ +---------+ +---------+
78// | xapp | | submgr | | e2term |
79// +-------+ +---------+ +---------+
80// | | |
81// | [E2 Conn. DOWN] |
82// | | |
83// | RESTSubReq | |
84// |---------------->| |
85// | RESTSubFail | |
86// |<----------------| |
87// | | |
88//
89//-----------------------------------------------------------------------------
90
91func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030092
93 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
94 Counter{cRestSubReqFromXapp, 1},
95 Counter{cRestReqRejDueE2Down, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020096 Counter{cE2StateChangedToDown, 1},
97 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030098 })
99
100 // E2 disconnect after E2term has received response
101 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
102 // Req
103 const subReqCount int = 1
104 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
105 xappConn1.SendRESTSubsReq(t, params)
106
107 // Restore E2 connection for following test cases
108 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
109
Anssi Mannilab43397e2021-11-16 12:06:16 +0200110 mainCtrl.VerifyAllClean(t)
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200111 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300112}
113
114//-----------------------------------------------------------------------------
115// TestRESTSubReqE2ConnBreak
116//
117// stub stub
118// +-------+ +---------+ +---------+
119// | xapp | | submgr | | e2term |
120// +-------+ +---------+ +---------+
121// | | |
122// | RESTSubReq | |
123// |---------------->| |
124// | RESTSubResp | |
125// |<----------------| |
126// | | SubReq |
127// | |------------->|
128// | | SubResp |
129// | |<-------------|
130// | | |
131// | [E2 Conn. DOWN] |
132// | [Int. SUBS DELETE] |
133// | | |
134// | RESTNotif(unsuccessful) |
135// |<----------------| |
136// | | |
137// | | |
138//
139//-----------------------------------------------------------------------------
140func TestRESTSubReqE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300141
142 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
143 Counter{cRestSubReqFromXapp, 1},
144 Counter{cRestSubRespToXapp, 1},
145 Counter{cSubReqToE2, 1},
146 Counter{cSubRespFromE2, 1},
147 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200148 Counter{cE2StateChangedToDown, 1},
149 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300150 })
151
152 // Req
153 const subReqCount int = 1
154 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
155 restSubId := xappConn1.SendRESTSubsReq(t, params)
156
157 crereq, cremsg := e2termConn1.RecvSubsReq(t)
158 xappConn1.ExpectRESTNotification(t, restSubId)
159
160 // E2 disconnect after E2term has received response
161 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
162
163 e2termConn1.SendSubsResp(t, crereq, cremsg)
164 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
165
166 <-time.After(time.Second * 1)
167 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
168 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
169
170 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
171 if err != nil {
172 xapp.Logger.Error("%v", err)
173 } else {
174 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
175 assert.Equal(t, 0, len(register))
176 }
177
178 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
179 if err != nil {
180 xapp.Logger.Error("%v", err)
181 } else {
182 assert.Equal(t, 0, len(restSubscriptions))
183 }
184
185 // Restore E2 connection for following test cases
186 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
187
188 // Wait that subs is cleaned
189 waitSubsCleanup(t, e2SubsId, 10)
190 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200191 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300192}
193
194//-----------------------------------------------------------------------------
195// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
196//
197// stub stub
198// +-------+ +---------+ +---------+
199// | xapp | | submgr | | e2term |
200// +-------+ +---------+ +---------+
201// | | |
202// | [SUBS CREATE] |
203// | | |
204// | [E2 Conn. DOWN] |
205// | | |
206// | RESTSubDelReq | |
207// |---------------->| |
208// | | |
209// | RESTSubDelResp | |
210// |<----------------| |
211// | | |
212// | [No valid subscription found] |
213// | | |
214//
215//-----------------------------------------------------------------------------
216func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
217 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
218
219 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
220 Counter{cRestSubReqFromXapp, 1},
221 Counter{cRestSubRespToXapp, 1},
222 Counter{cSubReqToE2, 1},
223 Counter{cSubRespFromE2, 1},
224 Counter{cRestSubNotifToXapp, 1},
225 Counter{cRestSubDelReqFromXapp, 1},
226 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200227 Counter{cE2StateChangedToDown, 1},
228 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300229 })
230
231 // Req
232 var params *teststube2ap.RESTSubsReqParams = nil
233 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
234
235 // E2 disconnect after E2term has received response
236 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
237
238 // Del
239 xappConn1.SendRESTSubsDelReq(t, &restSubId)
240
241 <-time.After(time.Second * 1)
242 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
243 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
244
245 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
246 if err != nil {
247 xapp.Logger.Error("%v", err)
248 } else {
249 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
250 assert.Equal(t, 0, len(register))
251 }
252
253 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
254 if err != nil {
255 xapp.Logger.Error("%v", err)
256 } else {
257 assert.Equal(t, 0, len(restSubscriptions))
258 }
259
260 // Restore E2 connection for following test cases
261 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
262
263 // Wait that subs is cleaned
264 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
265
266 xappConn1.TestMsgChanEmpty(t)
267 e2termConn1.TestMsgChanEmpty(t)
268 mainCtrl.wait_registry_empty(t, 10)
269 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200270 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300271}
272
273//-----------------------------------------------------------------------------
274// TestRESTOtherE2ConnectionChanges
275//
276
277// stub stub
278// +-------+ +---------+ +---------+
279// | xapp | | submgr | | e2term |
280// +-------+ +---------+ +---------+
281// | | |
282// | [SUBS CREATE] |
283// | | |
284// | [E2 CONNECTED_SETUP_FAILED] |
285// | [E2 CONNECTING] |
286// | [E2 SHUTTING_DOWN] |
287// | [E2 SHUT_DOWN] |
288// | | |
289// | [SUBS DELETE] |
290// | | |
291//
292//-----------------------------------------------------------------------------
293func TestRESTOtherE2ConnectionChanges(t *testing.T) {
294 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
295
296 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
297 Counter{cRestSubReqFromXapp, 1},
298 Counter{cRestSubRespToXapp, 1},
299 Counter{cSubReqToE2, 1},
300 Counter{cSubRespFromE2, 1},
301 Counter{cRestSubNotifToXapp, 1},
302 Counter{cRestSubDelReqFromXapp, 1},
303 Counter{cSubDelReqToE2, 1},
304 Counter{cSubDelRespFromE2, 1},
305 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200306 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300307 })
308
309 // Req
310 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
311 restSubId := xappConn1.SendRESTSubsReq(t, params)
312
313 crereq, cremsg := e2termConn1.RecvSubsReq(t)
314 xappConn1.ExpectRESTNotification(t, restSubId)
315 e2termConn1.SendSubsResp(t, crereq, cremsg)
316 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
317
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200318 // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300319 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
320 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
321 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
322 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
323
324 // Del
325 xappConn1.SendRESTSubsDelReq(t, &restSubId)
326 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
327 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
328
329 // Restore E2 connection for following test cases
330 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
331
332 // Wait that subs is cleaned
333 waitSubsCleanup(t, e2SubsId, 10)
334 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200335 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300336}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000337
338//-----------------------------------------------------------------------------
339// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
340//
341// stub stub stub
342// +-------+ +---------+ +---------+ +---------+
343// | xapp | | submgr | | e2term | | rtmgr |
344// +-------+ +---------+ +---------+ +---------+
345// | | | |
346// | RESTSubReq | | |
347// |---------------->| | |
348// | | RouteCreate | |
349// | |--------------------------->| // The order of these events may vary
350// | | | |
351// | RESTSubResp | | | // The order of these events may vary
352// |<----------------| | |
353// | | RouteResponse| |
354// | |<---------------------------| // The order of these events may vary
355// | | | |
356// | | SubReq | |
357// | |------------->| | // The order of these events may vary
358// | | | |
359// | | SubResp | |
360// | |<-------------| |
361// | RESTNotif1 | | |
362// |<----------------| | |
363// | | | |
364// | RESTSubDelReq | | |
365// |---------------->| | |
366// | | SubDelReq | |
367// | |------------->| |
368// | | | |
369// | RESTSubDelResp| | |
370// |<----------------| | |
371// | | | |
372// | | SubDelResp | |
373// | |<-------------| |
374// | | | |
375// | | | |
376//
377//-----------------------------------------------------------------------------
378func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000379
380 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
381
382 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
383
384 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200385 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000386}
387
Juha Hyttinenfa015662020-01-24 10:05:18 +0200388//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000389// TestRESTSubReqAndE1apDeleteReqPackingError
390//
391// stub stub stub
392// +-------+ +---------+ +---------+ +---------+
393// | xapp | | submgr | | e2term | | rtmgr |
394// +-------+ +---------+ +---------+ +---------+
395// | | | |
396// | RESTSubReq | | |
397// |---------------->| | |
398// | | RouteCreate | |
399// | |--------------------------->| // The order of these events may vary
400// | | | |
401// | RESTSubResp | | | // The order of these events may vary
402// |<----------------| | |
403// | | RouteResponse| |
404// | |<---------------------------| // The order of these events may vary
405// | | | |
406// | | SubReq | |
407// | |------------->| | // The order of these events may vary
408// | | | |
409// | | SubResp | |
410// | |<-------------| |
411// | RESTNotif1 | | |
412// |<----------------| | |
413// | | | |
414// | RESTSubDelReq | | |
415// |---------------->| | |
416// | | | |
417// | RESTSubDelResp| | |
418// |<----------------| | |
419// | | | |
420// | | | |
421//
422//-----------------------------------------------------------------------------
423func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
424
425 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
426
427 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
428 xappConn1.SendRESTSubsDelReq(t, &restSubId)
429 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
430
431 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200432 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000433}
434
435//-----------------------------------------------------------------------------
Anssi Mannila483bd162022-01-20 11:11:48 +0200436// TestRESTSubReqAndE2APDeleteRespUnpackingError
Markku Virtanenac8bde42021-05-25 09:54:42 +0000437//
438// stub stub stub
439// +-------+ +---------+ +---------+ +---------+
440// | xapp | | submgr | | e2term | | rtmgr |
441// +-------+ +---------+ +---------+ +---------+
442// | | | |
443// | RESTSubReq | | |
444// |---------------->| | |
445// | | RouteCreate | |
446// | |--------------------------->| // The order of these events may vary
447// | | | |
448// | RESTSubResp | | | // The order of these events may vary
449// |<----------------| | |
450// | | RouteResponse| |
451// | |<---------------------------| // The order of these events may vary
452// | | | |
453// | | SubReq | |
454// | |------------->| | // The order of these events may vary
455// | | | |
456// | | SubResp | |
457// | |<-------------| |
458// | RESTNotif1 | | |
459// |<----------------| | |
460// | | | |
461// | RESTSubDelReq | | |
462// |---------------->| | |
463// | | SubDelReq | |
464// | |------------->| |
465// | | | |
466// | RESTSubDelResp| | |
467// |<----------------| | | // The order of these events may vary
468// | | | |
469// | | SubDelResp | |
470// | |<-------------| | // 1.st NOK
471// | | | |
472// | | SubDelReq | |
473// | |------------->| |
474// | | | |
475// | | SubDelResp | |
476// | |<-------------| | // 2.nd NOK
477//
478//-----------------------------------------------------------------------------
479
Anssi Mannila483bd162022-01-20 11:11:48 +0200480func TestRESTSubReqAndE2APDeleteRespUnpackingError(t *testing.T) {
Markku Virtanenac8bde42021-05-25 09:54:42 +0000481
482 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
483
484 xappConn1.SendRESTSubsDelReq(t, &restSubId)
485 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
486 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
487 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
488
489 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
490 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
491
492 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
493
494 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200495 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000496}
497
498//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200499// TestSubReqAndRouteNok
500//
501// stub stub
502// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200503// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200504// +-------+ +---------+ +---------+
505// | | |
506// | SubReq | |
507// |------------->| |
508// | | |
509// | | RouteCreate |
510// | |------------->|
511// | | |
512// | | RouteCreate |
513// | | status:400 |
514// | |<-------------|
515// | | |
516// | [SUBS INT DELETE] |
517// | | |
518//
519//-----------------------------------------------------------------------------
520
521func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200522 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200523
Anssi Mannila4abf1802021-01-28 13:06:46 +0200524 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
526 Counter{cSubReqFromXapp, 1},
527 Counter{cRouteCreateFail, 1},
528 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200529
Juha Hyttinenfa015662020-01-24 10:05:18 +0200530 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300531 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200532 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200533 waiter.WaitResult(t)
534
535 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200536 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200537
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200538 xappConn1.TestMsgChanEmpty(t)
539 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200540 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200541 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200542
543 <-time.After(1 * time.Second)
544 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200545}
546
547//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200548// TestSubReqAndRouteUpdateNok
549
550// stub stub
551// +-------+ +-------+ +---------+ +---------+
552// | xapp2 | | xapp1 | | submgr | | rtmgr |
553// +-------+ +-------+ +---------+ +---------+
554// | | | |
555// | [SUBS CREATE] | |
556// | | | |
557// | | | |
558// | | | |
559// | SubReq (mergeable) | |
560// |--------------------------->| | |
561// | | | |
562// | | | RouteUpdate |
563// | | |------------->|
564// | | | |
565// | | | RouteUpdate |
566// | | | status:400 |
567// | | |<-------------|
568// | | | |
569// | [SUBS INT DELETE] | |
570// | | | |
571// | | | |
572// | [SUBS DELETE] | |
573// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300574
Anssi Mannila4abf1802021-01-28 13:06:46 +0200575func TestSubReqAndRouteUpdateNok(t *testing.T) {
576 CaseBegin("TestSubReqAndRouteUpdateNok")
577
578 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200579 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
580 Counter{cSubReqFromXapp, 2},
581 Counter{cSubReqToE2, 1},
582 Counter{cSubRespFromE2, 1},
583 Counter{cSubRespToXapp, 1},
584 Counter{cRouteCreateUpdateFail, 1},
585 Counter{cSubDelReqFromXapp, 1},
586 Counter{cSubDelReqToE2, 1},
587 Counter{cSubDelRespFromE2, 1},
588 Counter{cSubDelRespToXapp, 1},
589 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200590
591 cretrans := xappConn1.SendSubsReq(t, nil, nil)
592 crereq, cremsg := e2termConn1.RecvSubsReq(t)
593 e2termConn1.SendSubsResp(t, crereq, cremsg)
594 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
595
596 resp, _ := xapp.Subscription.QuerySubscriptions()
597 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
598 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300599 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200600
601 waiter := rtmgrHttp.AllocNextEvent(false)
602 newSubsId := mainCtrl.get_registry_next_subid(t)
603 xappConn2.SendSubsReq(t, nil, nil)
604 waiter.WaitResult(t)
605
606 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
607 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
608
609 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
610 xappConn1.RecvSubsDelResp(t, deltrans)
611
612 //Wait that subs is cleaned
613 mainCtrl.wait_subs_clean(t, newSubsId, 10)
614 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
615
616 xappConn1.TestMsgChanEmpty(t)
617 xappConn2.TestMsgChanEmpty(t)
618 e2termConn1.TestMsgChanEmpty(t)
619 mainCtrl.wait_registry_empty(t, 10)
620
621 mainCtrl.VerifyCounterValues(t)
622}
623
624//-----------------------------------------------------------------------------
625// TestSubDelReqAndRouteDeleteNok
626//
627// stub stub
628// +-------+ +---------+ +---------+ +---------+
629// | xapp | | submgr | | e2term | | rtmgr |
630// +-------+ +---------+ +---------+ +---------+
631// | | | |
632// | [SUBS CREATE] | |
633// | | | |
634// | | | |
635// | | | |
636// | SubDelReq | | |
637// |------------->| | |
638// | | SubDelReq | |
639// | |------------->| |
640// | | SubDelRsp | |
641// | |<-------------| |
642// | SubDelRsp | | |
643// |<-------------| | |
644// | | RouteDelete | |
645// | |---------------------------->|
646// | | | |
647// | | RouteDelete | |
648// | | status:400 | |
649// | |<----------------------------|
650// | | | |
651func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
652 CaseBegin("TestSubDelReqAndRouteDeleteNok")
653
654 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200655 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
656 Counter{cSubReqFromXapp, 1},
657 Counter{cSubReqToE2, 1},
658 Counter{cSubRespFromE2, 1},
659 Counter{cSubRespToXapp, 1},
660 Counter{cSubDelReqFromXapp, 1},
661 Counter{cRouteDeleteFail, 1},
662 Counter{cSubDelReqToE2, 1},
663 Counter{cSubDelRespFromE2, 1},
664 Counter{cSubDelRespToXapp, 1},
665 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200666
667 cretrans := xappConn1.SendSubsReq(t, nil, nil)
668 crereq, cremsg := e2termConn1.RecvSubsReq(t)
669 e2termConn1.SendSubsResp(t, crereq, cremsg)
670 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
671
672 resp, _ := xapp.Subscription.QuerySubscriptions()
673 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
674 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300675 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200676
677 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
678 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
679
680 waiter := rtmgrHttp.AllocNextEvent(false)
681 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
682 waiter.WaitResult(t)
683
684 xappConn1.RecvSubsDelResp(t, deltrans)
685
686 //Wait that subs is cleaned
687 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
688
689 xappConn1.TestMsgChanEmpty(t)
690 xappConn2.TestMsgChanEmpty(t)
691 e2termConn1.TestMsgChanEmpty(t)
692 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200693 mainCtrl.VerifyCounterValues(t)
694}
695
696//-----------------------------------------------------------------------------
697// TestSubMergeDelAndRouteUpdateNok
698// stub stub
699// +-------+ +-------+ +---------+ +---------+
700// | xapp2 | | xapp1 | | submgr | | e2term |
701// +-------+ +-------+ +---------+ +---------+
702// | | | |
703// | | | |
704// | | | |
705// | | SubReq1 | |
706// | |------------->| |
707// | | | |
708// | | | SubReq1 |
709// | | |------------->|
710// | | | SubResp1 |
711// | | |<-------------|
712// | | SubResp1 | |
713// | |<-------------| |
714// | | | |
715// | SubReq2 | |
716// |--------------------------->| |
717// | | | |
718// | SubResp2 | |
719// |<---------------------------| |
720// | | | |
721// | | SubDelReq 1 | |
722// | |------------->| |
723// | | | RouteUpdate |
724// | | |-----> rtmgr |
725// | | | |
726// | | | RouteUpdate |
727// | | | status:400 |
728// | | |<----- rtmgr |
729// | | | |
730// | | SubDelResp 1 | |
731// | |<-------------| |
732// | | | |
733// | SubDelReq 2 | |
734// |--------------------------->| |
735// | | | |
736// | | | SubDelReq 2 |
737// | | |------------->|
738// | | | |
739// | | | SubDelReq 2 |
740// | | |------------->|
741// | | | |
742// | SubDelResp 2 | |
743// |<---------------------------| |
744//
745//-----------------------------------------------------------------------------
746func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
747 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
748
749 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200750 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
751 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200752 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200753 Counter{cSubReqToE2, 1},
754 Counter{cSubRespFromE2, 1},
755 Counter{cSubRespToXapp, 2},
756 Counter{cSubDelReqFromXapp, 2},
757 Counter{cRouteDeleteUpdateFail, 1},
758 Counter{cSubDelReqToE2, 1},
759 Counter{cSubDelRespFromE2, 1},
760 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200761 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200762 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200763
764 //Req1
765 rparams1 := &teststube2ap.E2StubSubsReqParams{}
766 rparams1.Init()
767 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
768 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
769 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
770 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
771
772 //Req2
773 rparams2 := &teststube2ap.E2StubSubsReqParams{}
774 rparams2.Init()
775 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
776 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
777
778 resp, _ := xapp.Subscription.QuerySubscriptions()
779 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
780 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300781 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200782
783 //Del1
784 waiter := rtmgrHttp.AllocNextEvent(false)
785 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
786 waiter.WaitResult(t)
787
788 xappConn1.RecvSubsDelResp(t, deltrans1)
789
790 //Del2
791 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
792 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
793 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
794 xappConn2.RecvSubsDelResp(t, deltrans2)
795 //Wait that subs is cleaned
796 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
797
798 xappConn1.TestMsgChanEmpty(t)
799 xappConn2.TestMsgChanEmpty(t)
800 e2termConn1.TestMsgChanEmpty(t)
801 mainCtrl.wait_registry_empty(t, 10)
802
803 mainCtrl.VerifyCounterValues(t)
804}
805
806//-----------------------------------------------------------------------------
807
808//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200809// TestSubReqAndSubDelOk
810//
811// stub stub
812// +-------+ +---------+ +---------+
813// | xapp | | submgr | | e2term |
814// +-------+ +---------+ +---------+
815// | | |
816// | SubReq | |
817// |------------->| |
818// | | |
819// | | SubReq |
820// | |------------->|
821// | | |
822// | | SubResp |
823// | |<-------------|
824// | | |
825// | SubResp | |
826// |<-------------| |
827// | | |
828// | | |
829// | SubDelReq | |
830// |------------->| |
831// | | |
832// | | SubDelReq |
833// | |------------->|
834// | | |
835// | | SubDelResp |
836// | |<-------------|
837// | | |
838// | SubDelResp | |
839// |<-------------| |
840//
841//-----------------------------------------------------------------------------
842func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200843 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200844
Anssi Mannila4abf1802021-01-28 13:06:46 +0200845 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200846 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
847 Counter{cSubReqFromXapp, 1},
848 Counter{cSubReqToE2, 1},
849 Counter{cSubRespFromE2, 1},
850 Counter{cSubRespToXapp, 1},
851 Counter{cSubDelReqFromXapp, 1},
852 Counter{cSubDelReqToE2, 1},
853 Counter{cSubDelRespFromE2, 1},
854 Counter{cSubDelRespToXapp, 1},
855 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200856
857 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200858 crereq, cremsg := e2termConn1.RecvSubsReq(t)
859 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200860 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200861
862 resp, _ := xapp.Subscription.QuerySubscriptions()
863 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
864 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300865 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200866
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200867 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200868 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200869
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200871 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200872
873 //Wait that subs is cleaned
874 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
875
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200876 xappConn1.TestMsgChanEmpty(t)
877 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200878 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200879 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200880
881 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200882}
883
884//-----------------------------------------------------------------------------
Himanshu Puorhit84662c42023-08-29 15:46:18 +0530885
886//-----------------------------------------------------------------------------
887// TestSubReqAndSubDelOkOutofOrderIEs
888//
889// stub stub
890// +-------+ +---------+ +---------+
891// | xapp | | submgr | | e2term |
892// +-------+ +---------+ +---------+
893// | | |
894// | SubReq | |
895// |------------->| |
896// | | |
897// | | SubReq |
898// | |------------->|
899// | | |
900// | | SubResp | (Out of Order IEs)
901// | |<-------------|
902// | | |
903// | SubResp | |
904// |<-------------| |
905// | | |
906// | | |
907// | SubDelReq | |
908// |------------->| |
909// | | |
910// | | SubDelReq |
911// | |------------->|
912// | | |
913// | | SubDelResp |
914// | |<-------------|
915// | | |
916// | SubDelResp | |
917// |<-------------| |
918//
919//-----------------------------------------------------------------------------
920
921func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
922 CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs")
923
924 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
925 // Init counter check
926 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
927 Counter{cSubReqFromXapp, 1},
928 Counter{cSubReqToE2, 1},
929 Counter{cSubRespFromE2, 1},
930 Counter{cSubRespToXapp, 1},
931 Counter{cSubDelReqFromXapp, 1},
932 Counter{cSubDelReqToE2, 1},
933 Counter{cSubDelRespFromE2, 1},
934 Counter{cSubDelRespToXapp, 1},
935 })
936
937 cretrans := xappConn1.SendSubsReq(t, nil, nil)
938 if cretrans == nil {
939 t.Logf("Could not send SubsReq")
940 t.FailNow()
941 }
942 crereq, cremsg := e2termConn1.RecvSubsReq(t)
943 if crereq == nil || cremsg == nil {
944 t.Logf("Could not recieve SubsReq")
945 t.FailNow()
946 }
947
948 e2termConn1.SendSubsResp(t, crereq, cremsg)
949
Himanshu Puorhit84662c42023-08-29 15:46:18 +0530950 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
951 resp, _ := xapp.Subscription.QuerySubscriptions()
952 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
953 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
954 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
955
956 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
957 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
958
959 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
960 xappConn1.RecvSubsDelResp(t, deltrans)
961
962 //Wait that subs is cleaned
963 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
964
965 xappConn1.TestMsgChanEmpty(t)
966 xappConn2.TestMsgChanEmpty(t)
967 e2termConn1.TestMsgChanEmpty(t)
968 mainCtrl.wait_registry_empty(t, 10)
969
970 mainCtrl.VerifyCounterValues(t)
971 mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
972}
973
974//-----------------------------------------------------------------------------
975
976//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200977// TestSubReqRetransmission
978//
979// stub stub
980// +-------+ +---------+ +---------+
981// | xapp | | submgr | | e2term |
982// +-------+ +---------+ +---------+
983// | | |
984// | SubReq | |
985// |------------->| |
986// | | |
987// | | SubReq |
988// | |------------->|
989// | | |
990// | SubReq | |
991// | (retrans) | |
992// |------------->| |
993// | | |
994// | | SubResp |
995// | |<-------------|
996// | | |
997// | SubResp | |
998// |<-------------| |
999// | | |
1000// | [SUBS DELETE] |
1001// | | |
1002//
1003//-----------------------------------------------------------------------------
1004func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001005 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006
1007 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001008 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001009 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001010
1011 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001012 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001013 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1014
Juha Hyttinen1683f912020-04-17 10:39:57 +03001015 // hack as there is no real way to see has message be handled.
1016 // Previuos counter check just tells that is has been received by submgr
1017 // --> artificial delay
1018 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001019 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001020 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001021
1022 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001023 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001024 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1025 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001026 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001027
1028 //Wait that subs is cleaned
1029 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1030
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001031 xappConn1.TestMsgChanEmpty(t)
1032 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001033 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001034 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001035}
1036
1037//-----------------------------------------------------------------------------
1038// TestSubDelReqRetransmission
1039//
1040// stub stub
1041// +-------+ +---------+ +---------+
1042// | xapp | | submgr | | e2term |
1043// +-------+ +---------+ +---------+
1044// | | |
1045// | [SUBS CREATE] |
1046// | | |
1047// | | |
1048// | SubDelReq | |
1049// |------------->| |
1050// | | |
1051// | | SubDelReq |
1052// | |------------->|
1053// | | |
1054// | SubDelReq | |
1055// | (same sub) | |
1056// | (same xid) | |
1057// |------------->| |
1058// | | |
1059// | | SubDelResp |
1060// | |<-------------|
1061// | | |
1062// | SubDelResp | |
1063// |<-------------| |
1064//
1065//-----------------------------------------------------------------------------
1066func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001067 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001068
1069 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001070 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001071 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1072 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001073 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074
1075 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001076 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001077 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001078
1079 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001080 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001081 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1082
Juha Hyttinen1683f912020-04-17 10:39:57 +03001083 // hack as there is no real way to see has message be handled.
1084 // Previuos counter check just tells that is has been received by submgr
1085 // --> artificial delay
1086 <-time.After(1 * time.Second)
1087
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001088 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001089 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001090
1091 //Wait that subs is cleaned
1092 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1093
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001094 xappConn1.TestMsgChanEmpty(t)
1095 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001096 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001097 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001098}
1099
1100//-----------------------------------------------------------------------------
1101// TestSubDelReqCollision
1102//
1103// stub stub
1104// +-------+ +---------+ +---------+
1105// | xapp | | submgr | | e2term |
1106// +-------+ +---------+ +---------+
1107// | | |
1108// | [SUBS CREATE] |
1109// | | |
1110// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001111// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001112// |------------->| |
1113// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001114// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001115// | |------------->|
1116// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001117// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001118// | (same sub) | |
1119// | (diff xid) | |
1120// |------------->| |
1121// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001122// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001123// | |<-------------|
1124// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001125// | SubDelResp 1 | |
1126// |<-------------| |
1127// | | |
1128// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001129// |<-------------| |
1130//
1131//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001132
Juha Hyttinenfa015662020-01-24 10:05:18 +02001133func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001134 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001135
1136 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001137 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001138 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1139 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001140 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001141
1142 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001143 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001144 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001145
Juha Hyttinen3944a222020-01-24 11:51:46 +02001146 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001148 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1149 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001150 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1151
Juha Hyttinen1683f912020-04-17 10:39:57 +03001152 // hack as there is no real way to see has message be handled.
1153 // Previuos counter check just tells that is has been received by submgr
1154 // --> artificial delay
1155 <-time.After(1 * time.Second)
1156
Juha Hyttinen3944a222020-01-24 11:51:46 +02001157 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001158 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001159
1160 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001161 xappConn1.RecvSubsDelResp(t, nil)
1162 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001163
1164 //Wait that subs is cleaned
1165 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1166
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001167 xappConn1.TestMsgChanEmpty(t)
1168 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001169 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001170 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001171}
1172
1173//-----------------------------------------------------------------------------
1174// TestSubReqAndSubDelOkTwoParallel
1175//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001176// stub stub stub
1177// +-------+ +-------+ +---------+ +---------+
1178// | xapp | | xapp | | submgr | | e2term |
1179// +-------+ +-------+ +---------+ +---------+
1180// | | | |
1181// | | | |
1182// | | | |
1183// | | SubReq1 | |
1184// | |------------->| |
1185// | | | |
1186// | | | SubReq1 |
1187// | | |------------->|
1188// | | | |
1189// | SubReq2 | |
1190// |------------------------>| |
1191// | | | |
1192// | | | SubReq2 |
1193// | | |------------->|
1194// | | | |
1195// | | | SubResp1 |
1196// | | |<-------------|
1197// | | SubResp1 | |
1198// | |<-------------| |
1199// | | | |
1200// | | | SubResp2 |
1201// | | |<-------------|
1202// | SubResp2 | |
1203// |<------------------------| |
1204// | | | |
1205// | | [SUBS 1 DELETE] |
1206// | | | |
1207// | | [SUBS 2 DELETE] |
1208// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001209//
1210//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001211
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001213 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001214
1215 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001216 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001217 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001219 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001220
1221 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001222 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001223 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001224
1225 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1226 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1227 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1228
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001229 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001230 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001231
1232 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001233 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001234 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001235
1236 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001237 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001238 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001239
1240 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001241 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001242 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1243 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001244 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001245 //Wait that subs is cleaned
1246 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1247
1248 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001249 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001250 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1251 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001252 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001253 //Wait that subs is cleaned
1254 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1255
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001256 xappConn1.TestMsgChanEmpty(t)
1257 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001258 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001259 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001260}
1261
1262//-----------------------------------------------------------------------------
1263// TestSameSubsDiffRan
1264// Same subscription to different RANs
1265//
1266// stub stub
1267// +-------+ +---------+ +---------+
1268// | xapp | | submgr | | e2term |
1269// +-------+ +---------+ +---------+
1270// | | |
1271// | | |
1272// | | |
1273// | SubReq(r1) | |
1274// |------------->| |
1275// | | |
1276// | | SubReq(r1) |
1277// | |------------->|
1278// | | |
1279// | | SubResp(r1) |
1280// | |<-------------|
1281// | | |
1282// | SubResp(r1) | |
1283// |<-------------| |
1284// | | |
1285// | SubReq(r2) | |
1286// |------------->| |
1287// | | |
1288// | | SubReq(r2) |
1289// | |------------->|
1290// | | |
1291// | | SubResp(r2) |
1292// | |<-------------|
1293// | | |
1294// | SubResp(r2) | |
1295// |<-------------| |
1296// | | |
1297// | [SUBS r1 DELETE] |
1298// | | |
1299// | [SUBS r2 DELETE] |
1300// | | |
1301//
1302//-----------------------------------------------------------------------------
1303func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001304 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001305
1306 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001307 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1308 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001309 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1310 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001311 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001312
1313 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001314 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1315 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001316 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1317 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001319
1320 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001321 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1322 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001323 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1324 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001325 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001326 //Wait that subs is cleaned
1327 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1328
1329 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001330 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1331 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001332 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1333 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001334 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001335 //Wait that subs is cleaned
1336 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1337
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001338 xappConn1.TestMsgChanEmpty(t)
1339 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001340 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001341 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001342}
1343
1344//-----------------------------------------------------------------------------
1345// TestSubReqRetryInSubmgr
1346//
1347// stub stub
1348// +-------+ +---------+ +---------+
1349// | xapp | | submgr | | e2term |
1350// +-------+ +---------+ +---------+
1351// | | |
1352// | SubReq | |
1353// |------------->| |
1354// | | |
1355// | | SubReq |
1356// | |------------->|
1357// | | |
1358// | | |
1359// | | SubReq |
1360// | |------------->|
1361// | | |
1362// | | SubResp |
1363// | |<-------------|
1364// | | |
1365// | SubResp | |
1366// |<-------------| |
1367// | | |
1368// | [SUBS DELETE] |
1369// | | |
1370//
1371//-----------------------------------------------------------------------------
1372
1373func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001374 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001375
1376 // Init counter check
1377 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1378 Counter{cSubReqFromXapp, 1},
1379 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001380 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001381 Counter{cSubReReqToE2, 1},
1382 Counter{cSubRespFromE2, 1},
1383 Counter{cSubRespToXapp, 1},
1384 Counter{cSubDelReqFromXapp, 1},
1385 Counter{cSubDelReqToE2, 1},
1386 Counter{cSubDelRespFromE2, 1},
1387 Counter{cSubDelRespToXapp, 1},
1388 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001389
1390 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001391 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001392
1393 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001394 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001395
1396 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001397 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1398 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001399
1400 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001401 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001402
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001403 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001404 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1405 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001406 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001407
1408 // Wait that subs is cleaned
1409 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1410
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001411 xappConn1.TestMsgChanEmpty(t)
1412 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001413 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001414 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001415
1416 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001417}
1418
1419//-----------------------------------------------------------------------------
1420// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1421//
1422// stub stub
1423// +-------+ +---------+ +---------+
1424// | xapp | | submgr | | e2term |
1425// +-------+ +---------+ +---------+
1426// | | |
1427// | SubReq | |
1428// |------------->| |
1429// | | |
1430// | | SubReq |
1431// | |------------->|
1432// | | |
1433// | | |
1434// | | SubReq |
1435// | |------------->|
1436// | | |
1437// | | SubDelReq |
1438// | |------------->|
1439// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001440// | | SubDelResp |
1441// | |<-------------|
1442// | | |
1443//
1444//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001445func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001446 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001447
1448 // Init counter check
1449 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1450 Counter{cSubReqFromXapp, 1},
1451 Counter{cSubReqToE2, 1},
1452 Counter{cSubReReqToE2, 1},
1453 Counter{cSubReqTimerExpiry, 2},
1454 Counter{cSubDelReqToE2, 1},
1455 Counter{cSubDelRespFromE2, 1},
1456 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001457
1458 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001459 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001460
1461 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001462 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001463
1464 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001465 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001466
1467 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001468 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1469 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001470
1471 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001472 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001473
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001474 xappConn1.TestMsgChanEmpty(t)
1475 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001476 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001477 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001478
1479 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001480}
1481
1482//-----------------------------------------------------------------------------
1483// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1484//
1485// stub stub
1486// +-------+ +---------+ +---------+
1487// | xapp | | submgr | | e2term |
1488// +-------+ +---------+ +---------+
1489// | | |
1490// | SubReq | |
1491// |------------->| |
1492// | | |
1493// | | SubReq |
1494// | |------------->|
1495// | | |
1496// | | |
1497// | | SubReq |
1498// | |------------->|
1499// | | |
1500// | | SubDelReq |
1501// | |------------->|
1502// | | |
1503// | | |
1504// | | SubDelReq |
1505// | |------------->|
1506// | | |
1507// | | |
1508//
1509//-----------------------------------------------------------------------------
1510
1511func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001512 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001513
1514 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1515 Counter{cSubReqFromXapp, 1},
1516 Counter{cSubReqToE2, 1},
1517 Counter{cSubReReqToE2, 1},
1518 Counter{cSubReqTimerExpiry, 2},
1519 Counter{cSubDelReqToE2, 1},
1520 Counter{cSubDelReReqToE2, 1},
1521 Counter{cSubDelReqTimerExpiry, 2},
1522 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001523
1524 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001525 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001526
1527 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001528 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001529
1530 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001531 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001532
1533 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001534 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001535
1536 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001537 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001538
1539 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001540 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001541
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001542 xappConn1.TestMsgChanEmpty(t)
1543 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001544 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001545 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001546
1547 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001548}
1549
1550//-----------------------------------------------------------------------------
1551// TestSubReqSubFailRespInSubmgr
1552//
1553// stub stub
1554// +-------+ +---------+ +---------+
1555// | xapp | | submgr | | e2term |
1556// +-------+ +---------+ +---------+
1557// | | |
1558// | SubReq | |
1559// |------------->| |
1560// | | |
1561// | | SubReq |
1562// | |------------->|
1563// | | |
1564// | | SubFail |
1565// | |<-------------|
1566// | | |
1567// | SubFail | |
1568// |<-------------| |
1569// | | |
1570//
1571//-----------------------------------------------------------------------------
1572
1573func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001574 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001575
1576 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1577 Counter{cSubReqFromXapp, 1},
1578 Counter{cSubReqToE2, 1},
1579 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001580 Counter{cSubFailToXapp, 1},
1581 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001582
1583 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001584 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001585
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001586 // E2t: Receive SubsReq and send SubsFail (first)
1587 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1588 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1589 fparams1.Set(crereq1)
1590 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1591
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001592 // Xapp: Receive SubsFail
1593 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1594
1595 // Wait that subs is cleaned
1596 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1597
1598 xappConn1.TestMsgChanEmpty(t)
1599 xappConn2.TestMsgChanEmpty(t)
1600 e2termConn1.TestMsgChanEmpty(t)
1601 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001602
1603 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001604}
1605
1606//-----------------------------------------------------------------------------
Himanshu Puorhitd3fb1602024-01-16 14:37:55 +05301607// TestSubReqSubFailRespInSubmgrOutofOrderIEs
1608//
1609// stub stub
1610// +-------+ +---------+ +---------+
1611// | xapp | | submgr | | e2term |
1612// +-------+ +---------+ +---------+
1613// | | |
1614// | SubReq | |
1615// |------------->| |
1616// | | |
1617// | | SubReq |
1618// | |------------->|
1619// | | |
1620// | | SubFail | (Out of Order IEs)
1621// | |<-------------|
1622// | | |
1623// | SubFail | |
1624// |<-------------| |
1625// | | |
1626//
1627//-----------------------------------------------------------------------------
1628
1629func TestSubReqSubFailRespInSubmgrOutofOrderIEs(t *testing.T) {
1630 CaseBegin("TestSubReqSubFailRespInSubmgrOutofOrderIEs start")
1631
1632 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
1633 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1634 Counter{cSubReqFromXapp, 1},
1635 Counter{cSubReqToE2, 1},
1636 Counter{cSubFailFromE2, 1},
1637 Counter{cSubFailToXapp, 1},
1638 })
1639
1640 // Xapp: Send SubsReq
1641 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1642
1643 // E2t: Receive SubsReq and send SubsFail (first)
1644 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1645 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1646 fparams1.Set(crereq1)
1647 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1648
1649 // Xapp: Receive SubsFail
1650 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1651
1652 // Wait that subs is cleaned
1653 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1654
1655 xappConn1.TestMsgChanEmpty(t)
1656 xappConn2.TestMsgChanEmpty(t)
1657 e2termConn1.TestMsgChanEmpty(t)
1658 mainCtrl.wait_registry_empty(t, 10)
1659
1660 mainCtrl.VerifyCounterValues(t)
1661 mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
1662}
1663
1664//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001665// TestSubDelReqRetryInSubmgr
1666//
1667// stub stub
1668// +-------+ +---------+ +---------+
1669// | xapp | | submgr | | e2term |
1670// +-------+ +---------+ +---------+
1671// | | |
1672// | [SUBS CREATE] |
1673// | | |
1674// | | |
1675// | SubDelReq | |
1676// |------------->| |
1677// | | |
1678// | | SubDelReq |
1679// | |------------->|
1680// | | |
1681// | | SubDelReq |
1682// | |------------->|
1683// | | |
1684// | | SubDelResp |
1685// | |<-------------|
1686// | | |
1687// | SubDelResp | |
1688// |<-------------| |
1689//
1690//-----------------------------------------------------------------------------
1691
1692func TestSubDelReqRetryInSubmgr(t *testing.T) {
1693
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001694 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001695
1696 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001697 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001698 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1699 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001700 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001701
1702 // Subs Delete
1703 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001704 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001705
1706 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001707 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001708
1709 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001710 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1711 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001712
1713 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001714 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001715
1716 // Wait that subs is cleaned
1717 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1718
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001719 xappConn1.TestMsgChanEmpty(t)
1720 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001721 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001722 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001723}
1724
1725//-----------------------------------------------------------------------------
1726// TestSubDelReqTwoRetriesNoRespInSubmgr
1727//
1728// stub stub
1729// +-------+ +---------+ +---------+
1730// | xapp | | submgr | | e2term |
1731// +-------+ +---------+ +---------+
1732// | | |
1733// | [SUBS CREATE] |
1734// | | |
1735// | | |
1736// | SubDelReq | |
1737// |------------->| |
1738// | | |
1739// | | SubDelReq |
1740// | |------------->|
1741// | | |
1742// | | SubDelReq |
1743// | |------------->|
1744// | | |
1745// | | |
1746// | SubDelResp | |
1747// |<-------------| |
1748//
1749//-----------------------------------------------------------------------------
1750
1751func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1752
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001753 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001754
1755 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001756 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001757 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1758 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001759 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001760
1761 // Subs Delete
1762 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001763 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001764
1765 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001766 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001767
1768 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001769 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001770
1771 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001773
1774 // Wait that subs is cleaned
1775 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1776
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001777 xappConn1.TestMsgChanEmpty(t)
1778 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001779 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001780 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001781}
1782
1783//-----------------------------------------------------------------------------
1784// TestSubDelReqSubDelFailRespInSubmgr
1785//
1786// stub stub
1787// +-------+ +---------+ +---------+
1788// | xapp | | submgr | | e2term |
1789// +-------+ +---------+ +---------+
1790// | | |
1791// | [SUBS CREATE] |
1792// | | |
1793// | | |
1794// | SubDelReq | |
1795// |------------->| |
1796// | | |
1797// | | SubDelReq |
1798// | |------------->|
1799// | | |
1800// | | SubDelFail |
1801// | |<-------------|
1802// | | |
1803// | SubDelResp | |
1804// |<-------------| |
1805// | | |
1806//
1807//-----------------------------------------------------------------------------
1808
1809func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001810 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001811
1812 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1813 Counter{cSubReqFromXapp, 1},
1814 Counter{cSubReqToE2, 1},
1815 Counter{cSubRespFromE2, 1},
1816 Counter{cSubRespToXapp, 1},
1817 Counter{cSubDelReqFromXapp, 1},
1818 Counter{cSubDelReqToE2, 1},
1819 Counter{cSubDelFailFromE2, 1},
1820 Counter{cSubDelRespToXapp, 1},
1821 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001822
1823 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001824 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001825 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1826 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001827 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001828
1829 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001830 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001831
1832 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001833 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1834 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001835
1836 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001837 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001838
1839 // Wait that subs is cleaned
1840 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1841
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001842 xappConn1.TestMsgChanEmpty(t)
1843 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001844 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001845 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001846
1847 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001848}
1849
1850//-----------------------------------------------------------------------------
Himanshu Puorhitd3fb1602024-01-16 14:37:55 +05301851// TestSubDelReqSubDelFailRespInSubmgrOutofOrderIEs
1852//
1853// stub stub
1854// +-------+ +---------+ +---------+
1855// | xapp | | submgr | | e2term |
1856// +-------+ +---------+ +---------+
1857// | | |
1858// | [SUBS CREATE] |
1859// | | |
1860// | | |
1861// | SubDelReq | |
1862// |------------->| |
1863// | | |
1864// | | SubDelReq |
1865// | |------------->|
1866// | | |
1867// | | SubDelFail | (Out of Order IEs)
1868// | |<-------------|
1869// | | |
1870// | SubDelResp | |
1871// |<-------------| |
1872// | | |
1873//
1874//-----------------------------------------------------------------------------
1875
1876func TestSubDelReqSubDelFailRespInSubmgrOutofOrderIEs(t *testing.T) {
1877 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
1878
1879 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
1880 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1881 Counter{cSubReqFromXapp, 1},
1882 Counter{cSubReqToE2, 1},
1883 Counter{cSubRespFromE2, 1},
1884 Counter{cSubRespToXapp, 1},
1885 Counter{cSubDelReqFromXapp, 1},
1886 Counter{cSubDelReqToE2, 1},
1887 Counter{cSubDelFailFromE2, 1},
1888 Counter{cSubDelRespToXapp, 1},
1889 })
1890
1891 // Subs Create
1892 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1893 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1894 e2termConn1.SendSubsResp(t, crereq, cremsg)
1895 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1896
1897 // Xapp: Send SubsDelReq
1898 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1899
1900 // E2t: Send receive SubsDelReq and send SubsDelFail
1901 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1902 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
1903
1904 // Xapp: Receive SubsDelResp
1905 xappConn1.RecvSubsDelResp(t, deltrans)
1906
1907 // Wait that subs is cleaned
1908 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1909
1910 xappConn1.TestMsgChanEmpty(t)
1911 xappConn2.TestMsgChanEmpty(t)
1912 e2termConn1.TestMsgChanEmpty(t)
1913 mainCtrl.wait_registry_empty(t, 10)
1914
1915 mainCtrl.VerifyCounterValues(t)
1916 mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
1917}
1918
1919//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001920// TestSubReqAndSubDelOkSameAction
1921//
1922// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001923// +-------+ +-------+ +---------+ +---------+
1924// | xapp2 | | xapp1 | | submgr | | e2term |
1925// +-------+ +-------+ +---------+ +---------+
1926// | | | |
1927// | | | |
1928// | | | |
1929// | | SubReq1 | |
1930// | |------------->| |
1931// | | | |
1932// | | | SubReq1 |
1933// | | |------------->|
1934// | | | SubResp1 |
1935// | | |<-------------|
1936// | | SubResp1 | |
1937// | |<-------------| |
1938// | | | |
1939// | SubReq2 | |
1940// |--------------------------->| |
1941// | | | |
1942// | SubResp2 | |
1943// |<---------------------------| |
1944// | | | |
1945// | | SubDelReq 1 | |
1946// | |------------->| |
1947// | | | |
1948// | | SubDelResp 1 | |
1949// | |<-------------| |
1950// | | | |
1951// | SubDelReq 2 | |
1952// |--------------------------->| |
1953// | | | |
1954// | | | SubDelReq 2 |
1955// | | |------------->|
1956// | | | |
1957// | | | SubDelReq 2 |
1958// | | |------------->|
1959// | | | |
1960// | SubDelResp 2 | |
1961// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001962//
1963//-----------------------------------------------------------------------------
1964func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001965 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001966
Anssi Mannila4abf1802021-01-28 13:06:46 +02001967 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001968 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1969 Counter{cSubReqFromXapp, 2},
1970 Counter{cSubReqToE2, 1},
1971 Counter{cSubRespFromE2, 1},
1972 Counter{cSubRespToXapp, 2},
1973 Counter{cMergedSubscriptions, 1},
1974 Counter{cUnmergedSubscriptions, 1},
1975 Counter{cSubDelReqFromXapp, 2},
1976 Counter{cSubDelReqToE2, 1},
1977 Counter{cSubDelRespFromE2, 1},
1978 Counter{cSubDelRespToXapp, 2},
1979 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001980
Juha Hyttinen3944a222020-01-24 11:51:46 +02001981 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001982 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001983 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001984 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001985 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1986 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001987 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001988
1989 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001990 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001991 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001992 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001993 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001994
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001995 resp, _ := xapp.Subscription.QuerySubscriptions()
1996 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1997 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001998 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001999
Juha Hyttinen3944a222020-01-24 11:51:46 +02002000 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002001 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002002 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002003
2004 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002005 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002006 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2007 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002008 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002009 //Wait that subs is cleaned
2010 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2011
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002012 xappConn1.TestMsgChanEmpty(t)
2013 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002014 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002015 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02002016
2017 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002018}
2019
2020//-----------------------------------------------------------------------------
2021// TestSubReqAndSubDelOkSameActionParallel
2022//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002023// stub stub stub
2024// +-------+ +-------+ +---------+ +---------+
2025// | xapp2 | | xapp1 | | submgr | | e2term |
2026// +-------+ +-------+ +---------+ +---------+
2027// | | | |
2028// | | | |
2029// | | | |
2030// | | SubReq1 | |
2031// | |------------->| |
2032// | | | |
2033// | | | SubReq1 |
2034// | | |------------->|
2035// | SubReq2 | |
2036// |--------------------------->| |
2037// | | | SubResp1 |
2038// | | |<-------------|
2039// | | SubResp1 | |
2040// | |<-------------| |
2041// | | | |
2042// | SubResp2 | |
2043// |<---------------------------| |
2044// | | | |
2045// | | SubDelReq 1 | |
2046// | |------------->| |
2047// | | | |
2048// | | SubDelResp 1 | |
2049// | |<-------------| |
2050// | | | |
2051// | SubDelReq 2 | |
2052// |--------------------------->| |
2053// | | | |
2054// | | | SubDelReq 2 |
2055// | | |------------->|
2056// | | | |
2057// | | | SubDelReq 2 |
2058// | | |------------->|
2059// | | | |
2060// | SubDelResp 2 | |
2061// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02002062//
2063//-----------------------------------------------------------------------------
2064func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002065 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002066
2067 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002068 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002069 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002070 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002071 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002072
2073 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002074 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002075 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002076 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002077
2078 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002079 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002080 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002081
2082 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002083 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002084
2085 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002086 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2087 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002088
2089 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002090 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002091 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2092 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002093 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002094
2095 //Wait that subs is cleaned
2096 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2097
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002098 xappConn1.TestMsgChanEmpty(t)
2099 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002100 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002101 mainCtrl.wait_registry_empty(t, 10)
2102}
2103
2104//-----------------------------------------------------------------------------
2105// TestSubReqAndSubDelNokSameActionParallel
2106//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002107// stub stub stub
2108// +-------+ +-------+ +---------+ +---------+
2109// | xapp2 | | xapp1 | | submgr | | e2term |
2110// +-------+ +-------+ +---------+ +---------+
2111// | | | |
2112// | | | |
2113// | | | |
2114// | | SubReq1 | |
2115// | |------------->| |
2116// | | | |
2117// | | | SubReq1 |
2118// | | |------------->|
2119// | SubReq2 | |
2120// |--------------------------->| |
2121// | | | SubFail1 |
2122// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002123// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002124// | | SubFail1 | |
2125// | |<-------------| |
2126// | | | |
2127// | SubFail2 | |
2128// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02002129//
2130//-----------------------------------------------------------------------------
2131func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002132 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002133
2134 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002135 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002136 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002137 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002138
2139 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002140 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002141
2142 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002143 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002144 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002145 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002146 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002147 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002148
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002149 // E2t: send SubsFail (first)
2150 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2151 fparams1.Set(crereq1)
2152 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2153
Juha Hyttinen3944a222020-01-24 11:51:46 +02002154 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002155 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002156 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002157 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002158
2159 //Wait that subs is cleaned
2160 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
2161
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002162 xappConn1.TestMsgChanEmpty(t)
2163 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002164 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002165 mainCtrl.wait_registry_empty(t, 10)
2166}
2167
2168//-----------------------------------------------------------------------------
2169// TestSubReqAndSubDelNoAnswerSameActionParallel
2170//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002171// stub stub stub
2172// +-------+ +-------+ +---------+ +---------+
2173// | xapp2 | | xapp1 | | submgr | | e2term |
2174// +-------+ +-------+ +---------+ +---------+
2175// | | | |
2176// | | | |
2177// | | | |
2178// | | SubReq1 | |
2179// | |------------->| |
2180// | | | |
2181// | | | SubReq1 |
2182// | | |------------->|
2183// | | SubReq2 | |
2184// |--------------------------->| |
2185// | | | |
2186// | | | SubReq1 |
2187// | | |------------->|
2188// | | | |
2189// | | | |
2190// | | | SubDelReq |
2191// | | |------------->|
2192// | | | |
2193// | | | SubDelResp |
2194// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02002195//
2196//-----------------------------------------------------------------------------
2197func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002198 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002199
2200 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002201 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002202 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002203 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002204
Juha Hyttinen1683f912020-04-17 10:39:57 +03002205 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002206
2207 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002208 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002209 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002210 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002211 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002212 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002213
2214 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002215 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002216
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002217 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2218 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002219
2220 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002221 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002222
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002223 xappConn1.TestMsgChanEmpty(t)
2224 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002225 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002226 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002227}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002228
2229//----------------------------- Policy cases ---------------------------------
2230//-----------------------------------------------------------------------------
2231// TestSubReqPolicyAndSubDelOk
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 TestSubReqPolicyAndSubDelOk(t *testing.T) {
2265 CaseBegin("TestSubReqAndSubDelOk")
2266
2267 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2268 rparams1.Init()
2269 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2270 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2271
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002272 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2273 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002274 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2275 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002276 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002277
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002278 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002279 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002280
2281 //Wait that subs is cleaned
2282 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2283
2284 xappConn1.TestMsgChanEmpty(t)
2285 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002286 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002287 mainCtrl.wait_registry_empty(t, 10)
2288}
2289
2290//-----------------------------------------------------------------------------
2291// TestSubReqPolicyChangeAndSubDelOk
2292//
2293// stub stub
2294// +-------+ +---------+ +---------+
2295// | xapp | | submgr | | e2term |
2296// +-------+ +---------+ +---------+
2297// | | |
2298// | SubReq | |
2299// |------------->| |
2300// | | |
2301// | | SubReq |
2302// | |------------->|
2303// | | |
2304// | | SubResp |
2305// | |<-------------|
2306// | | |
2307// | SubResp | |
2308// |<-------------| |
2309// | | |
2310// | SubReq | |
2311// |------------->| |
2312// | | |
2313// | | SubReq |
2314// | |------------->|
2315// | | |
2316// | | SubResp |
2317// | |<-------------|
2318// | | |
2319// | SubResp | |
2320// |<-------------| |
2321// | | |
2322// | SubDelReq | |
2323// |------------->| |
2324// | | |
2325// | | SubDelReq |
2326// | |------------->|
2327// | | |
2328// | | SubDelResp |
2329// | |<-------------|
2330// | | |
2331// | SubDelResp | |
2332// |<-------------| |
2333//
2334//-----------------------------------------------------------------------------
2335
2336func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2337 CaseBegin("TestSubReqAndSubDelOk")
2338
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002339 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2340 rparams1.Init()
2341 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2342 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002343
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002344 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2345 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002346 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2347
2348 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002349 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002350 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2351 xappConn1.SendSubsReq(t, rparams1, cretrans)
2352
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002353 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2354 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002355 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2356 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002357 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002358
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002359 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002360 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002361
2362 //Wait that subs is cleaned
2363 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2364
2365 xappConn1.TestMsgChanEmpty(t)
2366 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002367 e2termConn1.TestMsgChanEmpty(t)
2368 mainCtrl.wait_registry_empty(t, 10)
2369}
2370
2371//-----------------------------------------------------------------------------
2372// TestSubReqAndSubDelOkTwoE2termParallel
2373//
2374// stub stub stub
2375// +-------+ +---------+ +---------+ +---------+
2376// | xapp | | submgr | | e2term1 | | e2term2 |
2377// +-------+ +---------+ +---------+ +---------+
2378// | | | |
2379// | | | |
2380// | | | |
2381// | SubReq1 | | |
2382// |------------->| | |
2383// | | | |
2384// | | SubReq1 | |
2385// | |------------->| |
2386// | | | |
2387// | SubReq2 | | |
2388// |------------->| | |
2389// | | | |
2390// | | SubReq2 | |
2391// | |---------------------------->|
2392// | | | |
2393// | | SubResp1 | |
2394// | |<-------------| |
2395// | SubResp1 | | |
2396// |<-------------| | |
2397// | | SubResp2 | |
2398// | |<----------------------------|
2399// | SubResp2 | | |
2400// |<-------------| | |
2401// | | | |
2402// | [SUBS 1 DELETE] | |
2403// | | | |
2404// | [SUBS 2 DELETE] | |
2405// | | | |
2406//
2407//-----------------------------------------------------------------------------
2408func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2409 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2410
2411 //Req1
2412 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2413 xappConn1.SendSubsReq(t, nil, cretrans1)
2414 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2415
2416 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2417 xappConn1.SendSubsReq(t, nil, cretrans2)
2418 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2419
2420 //Resp1
2421 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2422 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2423
2424 //Resp2
2425 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2426 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2427
2428 //Del1
2429 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2430 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2431 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2432 xappConn1.RecvSubsDelResp(t, deltrans1)
2433 //Wait that subs is cleaned
2434 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2435
2436 //Del2
2437 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2438 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2439 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2440 xappConn1.RecvSubsDelResp(t, deltrans2)
2441 //Wait that subs is cleaned
2442 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2443
2444 xappConn1.TestMsgChanEmpty(t)
2445 xappConn2.TestMsgChanEmpty(t)
2446 e2termConn1.TestMsgChanEmpty(t)
2447 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002448 mainCtrl.wait_registry_empty(t, 10)
2449}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002450
2451//-----------------------------------------------------------------------------
2452// TestSubReqInsertAndSubDelOk
2453//
2454// stub stub
2455// +-------+ +---------+ +---------+
2456// | xapp | | submgr | | e2term |
2457// +-------+ +---------+ +---------+
2458// | | |
2459// | SubReq | |
2460// |------------->| |
2461// | | |
2462// | | SubReq |
2463// | |------------->|
2464// | | |
2465// | | SubResp |
2466// | |<-------------|
2467// | | |
2468// | SubResp | |
2469// |<-------------| |
2470// | | |
2471// | | |
2472// | SubDelReq | |
2473// |------------->| |
2474// | | |
2475// | | SubDelReq |
2476// | |------------->|
2477// | | |
2478// | | SubDelResp |
2479// | |<-------------|
2480// | | |
2481// | SubDelResp | |
2482// |<-------------| |
2483//
2484//-----------------------------------------------------------------------------
2485func TestSubReqInsertAndSubDelOk(t *testing.T) {
2486 CaseBegin("TestInsertSubReqAndSubDelOk")
2487
2488 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2489 rparams1.Init()
2490 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2491 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2492
2493 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2494 e2termConn1.SendSubsResp(t, crereq, cremsg)
2495 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2496 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2497 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2498
2499 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2500 xappConn1.RecvSubsDelResp(t, deltrans)
2501
2502 //Wait that subs is cleaned
2503 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2504
2505 xappConn1.TestMsgChanEmpty(t)
2506 xappConn2.TestMsgChanEmpty(t)
2507 e2termConn1.TestMsgChanEmpty(t)
2508 mainCtrl.wait_registry_empty(t, 10)
2509}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002510
2511//-----------------------------------------------------------------------------
2512// TestSubReqRetransmissionWithSameSubIdDiffXid
2513//
2514// This case simulates case where xApp restarts and starts sending same
2515// subscription requests which have already subscribed successfully
2516
2517// stub stub
2518// +-------+ +---------+ +---------+
2519// | xapp | | submgr | | e2term |
2520// +-------+ +---------+ +---------+
2521// | | |
2522// | SubReq | |
2523// |------------->| |
2524// | | |
2525// | | SubReq |
2526// | |------------->|
2527// | | |
2528// | | SubResp |
2529// | |<-------------|
2530// | | |
2531// | SubResp | |
2532// |<-------------| |
2533// | | |
2534// | xApp restart | |
2535// | | |
2536// | SubReq | |
2537// | (retrans with same xApp generated subid but diff xid)
2538// |------------->| |
2539// | | |
2540// | SubResp | |
2541// |<-------------| |
2542// | | |
2543// | [SUBS DELETE] |
2544// | | |
2545//
2546//-----------------------------------------------------------------------------
2547func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2548 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2549
2550 //Subs Create
2551 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2552 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2553 e2termConn1.SendSubsResp(t, crereq, cremsg)
2554 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2555
2556 // xApp restart here
2557 // --> artificial delay
2558 <-time.After(1 * time.Second)
2559
2560 //Subs Create
2561 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2562 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2563
2564 //Subs Delete
2565 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2566 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2567 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2568 xappConn1.RecvSubsDelResp(t, deltrans)
2569
2570 //Wait that subs is cleaned
2571 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2572
2573 xappConn1.TestMsgChanEmpty(t)
2574 xappConn2.TestMsgChanEmpty(t)
2575 e2termConn1.TestMsgChanEmpty(t)
2576 mainCtrl.wait_registry_empty(t, 10)
2577}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002578
2579//-----------------------------------------------------------------------------
2580// TestSubReqNokAndSubDelOkWithRestartInMiddle
2581//
2582// stub stub
2583// +-------+ +---------+ +---------+
2584// | xapp | | submgr | | e2term |
2585// +-------+ +---------+ +---------+
2586// | | |
2587// | SubReq | |
2588// |------------->| |
2589// | | |
2590// | | SubReq |
2591// | |------------->|
2592// | | |
2593// | | SubResp |
2594// | <----|
2595// | |
2596// | Submgr restart |
2597// | |
2598// | | |
2599// | | SubDelReq |
2600// | |------------->|
2601// | | |
2602// | | SubDelResp |
2603// | |<-------------|
2604// | | |
2605//
2606//-----------------------------------------------------------------------------
2607
2608func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2609 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2610
Anssi Mannilac92b4212020-12-07 14:59:34 +02002611 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2612 xappConn1.SendSubsReq(t, nil, nil)
2613 e2termConn1.RecvSubsReq(t)
2614 mainCtrl.SetResetTestFlag(t, false)
2615
2616 resp, _ := xapp.Subscription.QuerySubscriptions()
2617 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002618 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002619 e2SubsId := uint32(resp[0].SubscriptionID)
2620 t.Logf("e2SubsId = %v", e2SubsId)
2621
archaggeafbf95f2021-04-14 08:54:05 +03002622 mainCtrl.SimulateRestart(t)
2623 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002624
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002625 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002626 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2627 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2628
2629 // Wait that subs is cleaned
2630 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2631
2632 xappConn1.TestMsgChanEmpty(t)
2633 xappConn2.TestMsgChanEmpty(t)
2634 e2termConn1.TestMsgChanEmpty(t)
2635 mainCtrl.wait_registry_empty(t, 10)
2636}
2637
2638//-----------------------------------------------------------------------------
2639// TestSubReqAndSubDelOkWithRestartInMiddle
2640//
2641// stub stub
2642// +-------+ +---------+ +---------+
2643// | xapp | | submgr | | e2term |
2644// +-------+ +---------+ +---------+
2645// | | |
2646// | SubReq | |
2647// |------------->| |
2648// | | |
2649// | | SubReq |
2650// | |------------->|
2651// | | |
2652// | | SubResp |
2653// | |<-------------|
2654// | | |
2655// | SubResp | |
2656// |<-------------| |
2657// | | |
2658// | |
2659// | Submgr restart |
2660// | |
2661// | SubDelReq | |
2662// |------------->| |
2663// | | |
2664// | | SubDelReq |
2665// | |------------->|
2666// | | |
2667// | | SubDelResp |
2668// | |<-------------|
2669// | | |
2670// | SubDelResp | |
2671// |<-------------| |
2672//
2673//-----------------------------------------------------------------------------
2674
2675func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2676 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2677
2678 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2679 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2680 e2termConn1.SendSubsResp(t, crereq, cremsg)
2681 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2682
2683 // Check subscription
2684 resp, _ := xapp.Subscription.QuerySubscriptions()
2685 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2686 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002687 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002688
2689 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002690 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002691
Anssi Mannila54838ed2021-11-19 11:25:01 +02002692 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2693 // That needs to be completed before successful subscription query is possible
2694 <-time.After(time.Second * 1)
2695
Anssi Mannilac92b4212020-12-07 14:59:34 +02002696 // Check that subscription is restored correctly after restart
2697 resp, _ = xapp.Subscription.QuerySubscriptions()
2698 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2699 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002700 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002701
2702 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2703 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2704 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2705 xappConn1.RecvSubsDelResp(t, deltrans)
2706
2707 //Wait that subs is cleaned
2708 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2709
2710 xappConn1.TestMsgChanEmpty(t)
2711 xappConn2.TestMsgChanEmpty(t)
2712 e2termConn1.TestMsgChanEmpty(t)
2713 mainCtrl.wait_registry_empty(t, 10)
2714}
2715
2716//-----------------------------------------------------------------------------
2717// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2718//
2719// stub stub
2720// +-------+ +-------+ +---------+ +---------+
2721// | xapp2 | | xapp1 | | submgr | | e2term |
2722// +-------+ +-------+ +---------+ +---------+
2723// | | | |
2724// | | | |
2725// | | | |
2726// | | SubReq1 | |
2727// | |------------->| |
2728// | | | |
2729// | | | SubReq1 |
2730// | | |------------->|
2731// | | | SubResp1 |
2732// | | |<-------------|
2733// | | SubResp1 | |
2734// | |<-------------| |
2735// | | | |
2736// | |
2737// | submgr restart |
2738// | |
2739// | | | |
2740// | | | |
2741// | SubReq2 | |
2742// |--------------------------->| |
2743// | | | |
2744// | SubResp2 | |
2745// |<---------------------------| |
2746// | | | |
2747// | | SubDelReq 1 | |
2748// | |------------->| |
2749// | | | |
2750// | | SubDelResp 1 | |
2751// | |<-------------| |
2752// | | | |
2753// | | | |
2754// | |
2755// | submgr restart |
2756// | |
2757// | | | |
2758// | SubDelReq 2 | |
2759// |--------------------------->| |
2760// | | | |
2761// | | | SubDelReq 2 |
2762// | | |------------->|
2763// | | | |
2764// | | | SubDelReq 2 |
2765// | | |------------->|
2766// | | | |
2767// | SubDelResp 2 | |
2768// |<---------------------------| |
2769//
2770//-----------------------------------------------------------------------------
2771
2772func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2773 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2774
2775 //Req1
2776 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2777 rparams1.Init()
2778 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2779 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2780 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2781 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2782
2783 //Req2
2784 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2785 rparams2.Init()
2786 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2787 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2788
2789 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002790 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002791 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2792 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002793 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002794
2795 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002796 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002797
Anssi Mannila54838ed2021-11-19 11:25:01 +02002798 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2799 // That needs to be completed before successful subscription query is possible
2800 <-time.After(time.Second * 1)
2801
Anssi Mannilac92b4212020-12-07 14:59:34 +02002802 // Check that subscription is restored correctly after restart
2803 resp, _ = xapp.Subscription.QuerySubscriptions()
2804 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2805 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002806 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002807
2808 //Del1
2809 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2810 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2811 xappConn1.RecvSubsDelResp(t, deltrans1)
2812 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2813
2814 mainCtrl.SimulateRestart(t)
2815 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2816
Anssi Mannila54838ed2021-11-19 11:25:01 +02002817 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2818 // Submgr need be ready before successful subscription deletion is possible
2819 <-time.After(time.Second * 1)
2820
Anssi Mannilac92b4212020-12-07 14:59:34 +02002821 //Del2
2822 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2823 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2824
2825 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2826 xappConn2.RecvSubsDelResp(t, deltrans2)
2827
2828 //Wait that subs is cleaned
2829 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2830
2831 xappConn1.TestMsgChanEmpty(t)
2832 xappConn2.TestMsgChanEmpty(t)
2833 e2termConn1.TestMsgChanEmpty(t)
2834 mainCtrl.wait_registry_empty(t, 10)
2835}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002836
archaggeafbf95f2021-04-14 08:54:05 +03002837//*****************************************************************************
2838// REST interface test cases
2839//*****************************************************************************
2840
Anssi Mannila47518ae2021-04-16 09:27:07 +03002841//-----------------------------------------------------------------------------
2842// Test debug GET and POST requests
2843//
2844// curl
2845// +-------+ +---------+
2846// | user | | submgr |
2847// +-------+ +---------+
2848// | |
2849// | GET/POST Req |
2850// |------------->|
2851// | Resp |
2852// |<-------------|
2853// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002854func TestGetSubscriptions(t *testing.T) {
2855
Anssi Mannila92c38552021-12-29 09:59:24 +02002856 mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002857}
2858
2859func TestGetSymptomData(t *testing.T) {
2860
Anssi Mannila92c38552021-12-29 09:59:24 +02002861 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002862}
2863
2864func TestPostdeleteSubId(t *testing.T) {
2865
Anssi Mannila92c38552021-12-29 09:59:24 +02002866 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002867}
2868
2869func TestPostEmptyDb(t *testing.T) {
2870
Anssi Mannila92c38552021-12-29 09:59:24 +02002871 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002872}
archaggeafbf95f2021-04-14 08:54:05 +03002873
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002874func TestGetRestSubscriptions(t *testing.T) {
2875
Anssi Mannila92c38552021-12-29 09:59:24 +02002876 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2877}
2878
2879//-----------------------------------------------------------------------------
2880// TestDelAllE2nodeSubsViaDebugIf
2881//
2882// stub stub stub
2883// +-------+ +---------+ +---------+ +---------+
2884// | xapp | | submgr | | e2term | | rtmgr |
2885// +-------+ +---------+ +---------+ +---------+
2886// | | | |
2887// | RESTSubReq | | |
2888// |---------------->| | |
2889// | RESTSubResp | | |
2890// |<----------------| | |
2891// | | RouteCreate | |
2892// | |--------------------------->|
2893// | | RouteResponse| |
2894// | |<---------------------------|
2895// | | SubReq | |
2896// | |------------->| |
2897// | | SubResp | |
2898// | |<-------------| |
2899// | RESTNotif1 | | |
2900// |<----------------| | |
2901// | | | |
2902// | REST get_all_e2nodes | |
2903// |---------------->| | |
2904// | OK 200 | | |
2905// |<----------------| | |
2906// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1
2907// |---------------->| | |
2908// | OK 200 | | |
2909// |<----------------| | |
2910// | | SubDelReq | |
2911// | |------------->| |
2912// | | SubDelResp | |
2913// | |<-------------| |
2914// | | | |
2915// | | RouteDelete | |
2916// | |--------------------------->|
2917// | | RouteResponse| |
2918// | |<---------------------------|
2919//
2920//-----------------------------------------------------------------------------
2921
2922func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
2923
2924 // Init counter check
2925 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2926 Counter{cRestSubReqFromXapp, 1},
2927 Counter{cRestSubRespToXapp, 1},
2928 Counter{cSubReqToE2, 1},
2929 Counter{cSubRespFromE2, 1},
2930 Counter{cRestSubNotifToXapp, 1},
2931 Counter{cRestSubDelReqFromXapp, 1},
2932 Counter{cSubDelReqToE2, 1},
2933 Counter{cSubDelRespFromE2, 1},
2934 Counter{cRestSubDelRespToXapp, 1},
2935 })
2936
2937 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2938 restSubId := xappConn1.SendRESTSubsReq(t, params)
2939 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2940
2941 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2942 xappConn1.ExpectRESTNotification(t, restSubId)
2943 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2944 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2945 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2946
2947 e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes")
2948
2949 var e2nodesList []string
2950 err := json.Unmarshal(e2nodesJson, &e2nodesList)
2951 if err != nil {
2952 t.Errorf("Unmarshal error: %s", err)
2953 }
2954 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList))
2955
2956 e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2957 var e2RestSubsMap map[string]RESTSubscription
2958 err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap)
2959 if err != nil {
2960 t.Errorf("Unmarshal error: %s", err)
2961 }
2962
2963 if len(e2RestSubsMap) != 1 {
2964 t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap))
2965 }
2966
2967 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002968 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
Anssi Mannila92c38552021-12-29 09:59:24 +02002969 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2970 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2971
2972 // Wait that subs is cleaned
2973 waitSubsCleanup(t, e2SubsId, 10)
2974 mainCtrl.VerifyCounterValues(t)
2975 mainCtrl.VerifyAllClean(t)
2976}
2977
2978//-----------------------------------------------------------------------------
2979// TestDelAllxAppSubsViaDebugIf
2980//
2981// stub stub stub
2982// +-------+ +---------+ +---------+ +---------+
2983// | xapp | | submgr | | e2term | | rtmgr |
2984// +-------+ +---------+ +---------+ +---------+
2985// | | | |
2986// | RESTSubReq | | |
2987// |---------------->| | |
2988// | RESTSubResp | | |
2989// |<----------------| | |
2990// | | RouteCreate | |
2991// | |--------------------------->|
2992// | | RouteResponse| |
2993// | |<---------------------------|
2994// | | SubReq | |
2995// | |------------->| |
2996// | | SubResp | |
2997// | |<-------------| |
2998// | RESTNotif1 | | |
2999// |<----------------| | |
3000// | | | |
3001// | REST get_all_xapps | |
3002// |---------------->| | |
3003// | OK 200 | | |
3004// |<----------------| | |
3005// | REST delete_all_xapp_subscriptions | xappServiceName = localhost
3006// |---------------->| | |
3007// | OK 200 | | |
3008// |<----------------| | |
3009// | | SubDelReq | |
3010// | |------------->| |
3011// | | SubDelResp | |
3012// | |<-------------| |
3013// | | | |
3014// | | RouteDelete | |
3015// | |--------------------------->|
3016// | | RouteResponse| |
3017// | |<---------------------------|
3018//
3019//-----------------------------------------------------------------------------
3020
3021func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
3022
3023 // Init counter check
3024 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3025 Counter{cRestSubReqFromXapp, 1},
3026 Counter{cRestSubRespToXapp, 1},
3027 Counter{cSubReqToE2, 1},
3028 Counter{cSubRespFromE2, 1},
3029 Counter{cRestSubNotifToXapp, 1},
3030 Counter{cRestSubDelReqFromXapp, 1},
3031 Counter{cSubDelReqToE2, 1},
3032 Counter{cSubDelRespFromE2, 1},
3033 Counter{cRestSubDelRespToXapp, 1},
3034 })
3035
3036 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3037 restSubId := xappConn1.SendRESTSubsReq(t, params)
3038 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3039
3040 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3041 xappConn1.ExpectRESTNotification(t, restSubId)
3042 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3043 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3044 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
3045
3046 xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps")
3047
3048 var xappList []string
3049 err := json.Unmarshal(xappsJson, &xappList)
3050 if err != nil {
3051 t.Errorf("Unmarshal error: %s", err)
3052 }
3053 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
3054
3055 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02003056 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
Anssi Mannila92c38552021-12-29 09:59:24 +02003057 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3058 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3059
3060 // Wait that subs is cleaned
3061 waitSubsCleanup(t, e2SubsId, 10)
3062 mainCtrl.VerifyCounterValues(t)
3063 mainCtrl.VerifyAllClean(t)
3064}
3065
3066//-----------------------------------------------------------------------------
3067// TestDelViaxAppSubsIf
3068//
3069// stub stub stub
3070// +-------+ +---------+ +---------+ +---------+
3071// | xapp | | submgr | | e2term | | rtmgr |
3072// +-------+ +---------+ +---------+ +---------+
3073// | | | |
3074// | RESTSubReq | | |
3075// |---------------->| | |
3076// | RESTSubResp | | |
3077// |<----------------| | |
3078// | | RouteCreate | |
3079// | |--------------------------->|
3080// | | RouteResponse| |
3081// | |<---------------------------|
3082// | | SubReq | |
3083// | |------------->| |
3084// | | SubResp | |
3085// | |<-------------| |
3086// | RESTNotif1 | | |
3087// |<----------------| | |
3088// | | | |
3089// | REST get_xapp_rest_restsubscriptions |
3090// |---------------->| | |
3091// | OK 200 | | |
3092// |<----------------| | |
3093// | RESTSudDel | | |
3094// |---------------->| | | Via user curl command (port 8088)
3095// | RESTSudDel | | |
3096// |<----------------| | |
3097// | | SubDelReq | |
3098// | |------------->| |
3099// | | SubDelResp | |
3100// | |<-------------| |
3101// | | | |
3102// | | RouteDelete | |
3103// | |--------------------------->|
3104// | | RouteResponse| |
3105// | |<---------------------------|
3106//
3107//-----------------------------------------------------------------------------
3108
3109func TestDelViaxAppSubsIf(t *testing.T) {
3110
3111 // Init counter check
3112 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3113 Counter{cRestSubReqFromXapp, 1},
3114 Counter{cRestSubRespToXapp, 1},
3115 Counter{cSubReqToE2, 1},
3116 Counter{cSubRespFromE2, 1},
3117 Counter{cRestSubNotifToXapp, 1},
3118 Counter{cRestSubDelReqFromXapp, 1},
3119 Counter{cSubDelReqToE2, 1},
3120 Counter{cSubDelRespFromE2, 1},
3121 Counter{cRestSubDelRespToXapp, 1},
3122 })
3123
3124 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3125 restSubId := xappConn1.SendRESTSubsReq(t, params)
3126 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3127
3128 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3129 xappConn1.ExpectRESTNotification(t, restSubId)
3130 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3131 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3132 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
3133
3134 restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName
3135
3136 var restSubsMap map[string]RESTSubscription
3137 err := json.Unmarshal(restSubsListJson, &restSubsMap)
3138 if err != nil {
3139 t.Errorf("Unmarshal error: %s", err)
3140 }
3141 _, ok := restSubsMap[restSubId]
3142 if !ok {
3143 t.Errorf("REST subscription not found. restSubId=%s", restSubId)
3144 }
3145
3146 var e2Subscriptions []Subscription
3147 e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId)
3148 err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions)
3149 if err != nil {
3150 t.Errorf("Unmarshal error: %s", err)
3151 }
3152 if len(e2Subscriptions) != 1 {
3153 t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions))
3154 }
3155
3156 // Simulate deletion through xapp REST test interface
3157 mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId)
3158 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3159 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3160
3161 // Wait that subs is cleaned
3162 waitSubsCleanup(t, e2SubsId, 10)
3163 mainCtrl.VerifyCounterValues(t)
3164 mainCtrl.VerifyAllClean(t)
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03003165}
3166
archaggeafbf95f2021-04-14 08:54:05 +03003167//-----------------------------------------------------------------------------
3168// TestRESTSubReqAndRouteNok
3169//
3170// stub stub
3171// +-------+ +---------+ +---------+
3172// | xapp | | submgr | | rtmgr |
3173// +-------+ +---------+ +---------+
3174// | | |
3175// | RESTSubReq | |
3176// |---------------->| |
3177// | | |
3178// | RESTSubResp | |
3179// |<----------------| |
3180// | | RouteCreate |
3181// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03003182// | | RouteCreate |
3183// | | status:400 |
3184// | |(Bad request) |
3185// | |<-------------|
3186// | RESTNotif | |
3187// |<----------------| |
3188// | | |
3189// | [SUBS INT DELETE] |
3190// | | |
3191// | RESTSubDelReq | |
3192// |---------------->| |
3193// | RESTSubDelResp | |
3194// |<----------------| |
3195//
3196//-----------------------------------------------------------------------------
3197func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003198
3199 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003200 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003201 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003202 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003203 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003204 Counter{cRestSubDelReqFromXapp, 1},
3205 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003206 })
3207
3208 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003209
Markku Virtanenda34eec2021-05-20 08:22:04 +00003210 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
3211 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03003212 newSubsId := mainCtrl.get_registry_next_subid(t)
3213
3214 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003215 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003216 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003217 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03003218 waiter.WaitResult(t)
3219
archaggeafbf95f2021-04-14 08:54:05 +03003220 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003221 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003222
3223 // Del
3224 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3225
3226 // Wait that subs is cleaned
3227 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3228 waitSubsCleanup(t, e2SubsId, 10)
3229 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003230 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003231}
3232
Anssi Mannila27385172021-12-22 09:41:54 +02003233//-----------------------------------------------------------------------------
3234// TestRESTSubReqAndRouteUpdateNok
3235//
3236// stub stub stub stub
3237// +-------+ +-------+ +---------+ +---------+ +---------+
3238// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3239// +-------+ +-------+ +---------+ +---------+ +---------+
3240// | | | | |
3241// | RESTSubReq1 | | |
3242// |------------------------>| | |
3243// | RESTSubResp2 | | |
3244// |<------------------------| | |
3245// | | | | |
3246// | | | RouteCreate | |
3247// | | |------------->| |
3248// | | | CreateResp | |
3249// | | |<-------------| |
3250// | | | SubReq | |
3251// | | |---------------------------->|
3252// | | | SubResp | |
3253// | | |<----------------------------|
3254// | RESTNotif1 | | |
3255// |<------------------------| | |
3256// | | | | |
3257// | | RESTSubReq2 | | |
3258// | |------------>| | |
3259// | | RESTSubResp2| | |
3260// | |<------------| | |
3261// | | | RouteUpdate | |
3262// | | |------------->| |
3263// | | | RouteUpdate | |
3264// | | | status:400 | |
3265// | | |(Bad request) | |
3266// | | |<-------------| |
3267// | | RESTNotif2(unsuccessful) | |
3268// | |<------------| | |
3269// | | | | |
3270// | [SUBS INT DELETE] | |
3271// | | | | |
3272// | RESTSubDelReq1 | | |
3273// |------------------------>| | |
3274// | RESTSubDelResp1 | | |
3275// |<------------------------| | |
3276// | | | | |
3277// | | | [SUBS DELETE] |
3278//
3279//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003280func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003281
3282 //Init counter check
3283 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003284 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003285 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003286 Counter{cSubReqToE2, 1},
3287 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003288 Counter{cRestSubNotifToXapp, 1},
3289 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003290 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003291 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003292 Counter{cSubDelReqToE2, 1},
3293 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003294 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003295 })
3296
3297 var params *teststube2ap.RESTSubsReqParams = nil
3298
Anssi Mannila27385172021-12-22 09:41:54 +02003299 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03003300 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3301
3302 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3303
3304 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
3305 waiter := rtmgrHttp.AllocNextEvent(false)
3306 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003307 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003308 params.SetMeid("RAN_NAME_1")
3309 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003310 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003311 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003312 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003313 xappConn2.WaitRESTNotification(t, restSubId2)
3314
3315 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3316
3317 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003318 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003319
3320 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3321 //Wait that subs is cleaned
3322 waitSubsCleanup(t, e2SubsId, 10)
3323
3324 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003325 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003326}
3327
Anssi Mannila27385172021-12-22 09:41:54 +02003328//-----------------------------------------------------------------------------
3329// TestRESTSubDelReqAndRouteDeleteNok
3330//
3331// stub stub stub
3332// +-------+ +---------+ +---------+ +---------+
3333// | xapp | | submgr | | rtmgr | | e2term |
3334// +-------+ +---------+ +---------+ +---------+
3335// | | | |
3336// | RESTSubReq | | |
3337// |---------------->| | |
3338// | | | |
3339// | RESTSubResp | | |
3340// |<----------------| | |
3341// | | SubReq | |
3342// | |---------------------------->|
3343// | | SubResp | |
3344// | |<----------------------------|
3345// | RESTNotif | | |
3346// |<----------------| | |
3347// | | | |
3348// | | | |
3349// | RESTSubDelReq | | |
3350// |---------------->| | |
3351// | RESTSubDelResp | | |
3352// |<----------------| | |
3353// | | SubSelReq | |
3354// | |---------------------------->|
3355// | | SubSelResp | |
3356// | |<----------------------------|
3357// | | RouteDelete | |
3358// | |------------->| |
3359// | | Routedelete | |
3360// | | status:400 | |
3361// | |(Bad request) | |
3362// | |<-------------| |
3363//
3364//-----------------------------------------------------------------------------
3365
archaggeafbf95f2021-04-14 08:54:05 +03003366func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003367
3368 // Init counter check
3369 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003370 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003371 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003372 Counter{cSubReqToE2, 1},
3373 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003374 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003375 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003376 Counter{cRouteDeleteFail, 1},
3377 Counter{cSubDelReqToE2, 1},
3378 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003379 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003380 })
3381
3382 var params *teststube2ap.RESTSubsReqParams = nil
3383
3384 //Subs Create
3385 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3386
3387 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3388
3389 waiter := rtmgrHttp.AllocNextEvent(false)
3390 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3391 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3392 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3393 waiter.WaitResult(t)
3394
3395 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003396 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003397 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003398}
3399
Anssi Mannila27385172021-12-22 09:41:54 +02003400//-----------------------------------------------------------------------------
3401// TestRESTSubMergeDelAndRouteUpdateNok
3402//
3403// stub stub stub stub
3404// +-------+ +-------+ +---------+ +---------+ +---------+
3405// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3406// +-------+ +-------+ +---------+ +---------+ +---------+
3407// | | | | |
3408// | RESTSubReq1 | | |
3409// |------------------------>| | |
3410// | RESTSubResp2 | | |
3411// |<------------------------| | |
3412// | | | | |
3413// | | | RouteCreate | |
3414// | | |------------->| |
3415// | | | CreateResp | |
3416// | | |<-------------| |
3417// | | | SubReq | |
3418// | | |---------------------------->|
3419// | | | SubResp | |
3420// | | |<----------------------------|
3421// | RESTNotif1 | | |
3422// |<------------------------| | |
3423// | | | | |
3424// | | RESTSubReq2 | | |
3425// | |------------>| | |
3426// | | RESTSubResp2| | |
3427// | |<------------| | |
3428// | | | RouteCreate | |
3429// | | |------------->| |
3430// | | | CreateResp | |
3431// | | |<-------------| |
3432// | | | SubReq | |
3433// | | |---------------------------->|
3434// | | | SubResp | |
3435// | | |<----------------------------|
3436// | | RESTNotif2 | | |
3437// | |<------------| | |
3438// | | | | |
3439// | [SUBS INT DELETE] | |
3440// | | | | |
3441// | RESTSubDelReq1 | | |
3442// |------------------------>| | |
3443// | RESTSubDelResp1 | | |
3444// |<------------------------| | |
3445// | | | SubDelReq | |
3446// | | |---------------------------->|
3447// | | | SubDelResp | |
3448// | | |<----------------------------|
3449// | | | RouteUpdate | |
3450// | | |------------->| |
3451// | | | RouteUpdate | |
3452// | | | status:400 | |
3453// | | |(Bad request) | |
3454// | | |<-------------| |
3455// | | | | |
3456// | | RESTSubDelReq2 | |
3457// | |------------>| | |
3458// | | RESTSubDelResp2 | |
3459// | |<------------| | |
3460// | | | SubDelReq | |
3461// | | |---------------------------->|
3462// | | | SubdelResp | |
3463// | | |<----------------------------|
3464// | | | RouteDelete | |
3465// | | |------------->| |
3466// | | | Deleteresp | |
3467// | | |<-------------| |
3468
3469//-----------------------------------------------------------------------------
3470
archaggeafbf95f2021-04-14 08:54:05 +03003471func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003472
3473 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003474 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003475 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003476 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003477 Counter{cSubReqToE2, 1},
3478 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003479 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003480 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003481 Counter{cRouteDeleteUpdateFail, 1},
3482 Counter{cSubDelReqToE2, 1},
3483 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003484 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003485 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003486 })
3487
3488 var params *teststube2ap.RESTSubsReqParams = nil
3489
3490 //Subs Create
3491 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3492
3493 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3494 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
3495
3496 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3497
3498 //Del1, this shall fail on rtmgr side
3499 waiter := rtmgrHttp.AllocNextEvent(false)
3500 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3501 waiter.WaitResult(t)
3502
3503 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
3504
3505 //Del2
3506 deleteXapp2Subscription(t, &restSubId2)
3507
3508 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003509 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003510 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003511}
3512
3513//-----------------------------------------------------------------------------
3514// TestRESTSubReqRetransmission
3515//
3516// stub stub
3517// +-------+ +---------+ +---------+
3518// | xapp | | submgr | | e2term |
3519// +-------+ +---------+ +---------+
3520// | | |
3521// | RESTSubReq1 | |
3522// |---------------->| |
3523// | | |
3524// | RESTSubResp | |
3525// |<----------------| |
3526// | | SubReq1 |
3527// | |------------->|
3528// | | |
3529// | RESTSubReq2 | |
3530// | (retrans) | |
3531// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003532// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003533// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003534// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003535// | | SubResp1 |
3536// | |<-------------|
3537// | RESTNotif1 | |
3538// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003539// | | |
3540// | [SUBS DELETE] |
3541// | | |
3542//
3543//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003544
archaggeafbf95f2021-04-14 08:54:05 +03003545func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003546
3547 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003548 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003549 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003550 Counter{cSubReqToE2, 1},
3551 Counter{cSubRespFromE2, 1},
3552 Counter{cRestSubNotifToXapp, 1},
3553 Counter{cRestSubDelReqFromXapp, 1},
3554 Counter{cSubDelReqToE2, 1},
3555 Counter{cSubDelRespFromE2, 1},
3556 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003557 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003558 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003559 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3560 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3561
3562 // Subs Create
3563 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003564
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003565 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003566 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003567
Anssi Mannilab43397e2021-11-16 12:06:16 +02003568 xappConn1.SendRESTSubsReq(t, params)
3569 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003570
Anssi Mannilab43397e2021-11-16 12:06:16 +02003571 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003572
3573 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003574 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003575 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3576 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003577
Anssi Mannilab43397e2021-11-16 12:06:16 +02003578 e2SubsId := <-xappConn1.ListedRESTNotifications
3579
3580 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003581
3582 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003583 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003584 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3585 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3586
Anssi Mannilab43397e2021-11-16 12:06:16 +02003587 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003588
3589 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003590 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003591}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003592
Markku Virtanen42723e22021-06-15 10:09:23 +03003593//-----------------------------------------------------------------------------
3594// stub stub stub
3595// +-------+ +---------+ +---------+ +---------+
3596// | xapp | | submgr | | e2term | | rtmgr |
3597// +-------+ +---------+ +---------+ +---------+
3598// | | | |
3599// | RESTSubReq | | |
3600// |---------------->| | |
3601// | RESTSubResp | | |
3602// |<----------------| | |
3603// | | RouteCreate | |
3604// | |--------------------------->|
3605// | | RouteResponse| |
3606// | |<---------------------------| // The order of these events may vary
3607// | | SubReq | |
3608// | |------------->| | // The order of these events may vary
3609// | | SubResp | |
3610// | |<-------------| |
3611// | RESTNotif1 | | |
3612// |<----------------| | |
3613// | RESTSubReq | | |
3614// | [RETRANS1] | | |
3615// |---------------->| | |
3616// | RESTNotif1 | | |
3617// |<----------------| | |
3618// | RESTSubReq | | |
3619// | [RETRANS2] | | |
3620// |---------------->| | |
3621// | RESTNotif1 | | |
3622// |<----------------| | |
3623// | RESTSubDelReq | | |
3624// |---------------->| | |
3625// | | SubDelReq | |
3626// | |------------->| |
3627// | RESTSubDelResp| | |
3628// |<----------------| | |
3629// | | SubDelResp | |
3630// | |<-------------| |
3631// | | | |
3632//
3633//-----------------------------------------------------------------------------
3634
3635func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003636
3637 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3638 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003639 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003640 Counter{cRestSubRespToXapp, 3},
3641 Counter{cSubReqToE2, 1},
3642 Counter{cSubRespFromE2, 1},
3643 Counter{cRestSubNotifToXapp, 3},
3644 Counter{cRestSubDelReqFromXapp, 1},
3645 Counter{cSubDelReqToE2, 1},
3646 Counter{cSubDelRespFromE2, 1},
3647 Counter{cRestSubDelRespToXapp, 1},
3648 })
3649
3650 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3651
3652 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3653
3654 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3655
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003656 mainCtrl.WaitOngoingRequestMapEmpty()
3657
Markku Virtanen42723e22021-06-15 10:09:23 +03003658 //1.st resend
3659 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3660
3661 assert.Equal(t, restSubId_resend, restSubId)
3662
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003663 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003664
3665 //2.nd resend
3666 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3667
3668 assert.Equal(t, restSubId_resend2, restSubId)
3669
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003670 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003671
3672 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3673
3674 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003675 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003676 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003677}
3678
3679//-----------------------------------------------------------------------------
3680// stub stub stub
3681// +-------+ +---------+ +---------+ +---------+
3682// | xapp | | submgr | | e2term | | rtmgr |
3683// +-------+ +---------+ +---------+ +---------+
3684// | | | |
3685// | RESTSubReq | | |
3686// |---------------->| | |
3687// | RESTSubResp | | |
3688// |<----------------| | |
3689// | | RouteCreate | |
3690// | |--------------------------->|
3691// | | RouteResponse| |
3692// | |<---------------------------| // The order of these events may vary
3693// | | SubReq | |
3694// | |------------->| | // The order of these events may vary
3695// | | SubResp | |
3696// | |<-------------| |
3697// | RESTNotif1 | | |
3698// |<----------------| | |
3699// | RESTSubReq | | |
3700// | [RETRANS, with RESTsubsId] | |
3701// |---------------->| | |
3702// | RESTNotif1 | | |
3703// |<----------------| | |
3704// | RESTSubReq | | |
3705// | [RETRANS, without RESTsubsId] | |
3706// |---------------->| | |
3707// | RESTNotif1 | | |
3708// |<----------------| | |
3709// | RESTSubDelReq | | |
3710// |---------------->| | |
3711// | | SubDelReq | |
3712// | |------------->| |
3713// | RESTSubDelResp| | |
3714// |<----------------| | |
3715// | | SubDelResp | |
3716// | |<-------------| |
3717// | | | |
3718//
3719//-----------------------------------------------------------------------------
3720func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003721
3722 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3723 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003724 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003725 Counter{cRestSubRespToXapp, 3},
3726 Counter{cSubReqToE2, 1},
3727 Counter{cSubRespFromE2, 1},
3728 Counter{cRestSubNotifToXapp, 3},
3729 Counter{cRestSubDelReqFromXapp, 1},
3730 Counter{cSubDelReqToE2, 1},
3731 Counter{cSubDelRespFromE2, 1},
3732 Counter{cRestSubDelRespToXapp, 1},
3733 })
3734
3735 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3736
3737 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3738
3739 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3740
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003741 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003742
3743 //1.st resend with subscription ID
3744 params.SetSubscriptionID(&restSubId)
3745 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3746
3747 assert.Equal(t, restSubId_resend, restSubId)
3748
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003749 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003750
3751 //2.nd resend without subscription ID (faking app restart)
3752 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3753 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3754
3755 assert.Equal(t, restSubId_resend2, restSubId)
3756
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003757 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003758
3759 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3760
3761 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003762 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003763 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003764}
3765
3766//-----------------------------------------------------------------------------
3767// stub stub stub
3768// +-------+ +---------+ +---------+ +---------+
3769// | xapp | | submgr | | e2term | | rtmgr |
3770// +-------+ +---------+ +---------+ +---------+
3771// | | | |
3772// | RESTSubReq | | |
3773// |---------------->| | |
3774// | RESTSubResp | | |
3775// |<----------------| | |
3776// | | RouteCreate | |
3777// | |--------------------------->|
3778// | | RouteResponse| |
3779// | |<---------------------------|
3780// | | SubReq | |
3781// | |------------->| |
3782// | | SubResp | |
3783// | |<-------------| |
3784// | RESTNotif1 | | |
3785// |<----------------| | |
3786// | RESTSubReq | | |
3787// | [with RestSUbsId + one additional e2 subDetail]
3788// |---------------->| | |
3789// | RESTNotif1 | | |
3790// | [for initial e2 subDetail] | |
3791// |<----------------| | |
3792// | | RouteCreate | |
3793// | |--------------------------->|
3794// | | RouteResponse| |
3795// | |<---------------------------|
3796// | | SubReq | |
3797// | |------------->| |
3798// | | SubResp | |
3799// | |<-------------| |
3800// | RESTNotif1 | | |
3801// |<----------------| | |
3802// | RESTSubReq | | |
3803// | [with RESTsubsId initial request] |
3804// |---------------->| | |
3805// | RESTNotif1 | | |
3806// |<----------------| | |
3807// | RESTSubDelReq | | |
3808// |---------------->| | |
3809// | RESTSubDelResp| | |
3810// |<----------------| | |
3811// | | SubDelReq | |
3812// | |------------->| |
3813// | | SubDelResp | |
3814// | |<-------------| |
3815// | | SubDelReq | |
3816// | |------------->| |
3817// | | SubDelResp | |
3818// | |<-------------| |
3819// | | | |
3820//
3821//-----------------------------------------------------------------------------
3822
3823func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003824
3825 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3826 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003827 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003828 Counter{cRestSubRespToXapp, 3},
3829 Counter{cSubReqToE2, 2},
3830 Counter{cSubRespFromE2, 2},
3831 Counter{cRestSubNotifToXapp, 4},
3832 Counter{cRestSubDelReqFromXapp, 1},
3833 Counter{cSubDelReqToE2, 2},
3834 Counter{cSubDelRespFromE2, 2},
3835 Counter{cRestSubDelRespToXapp, 1},
3836 })
3837
3838 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3839
3840 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3841
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003842 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003843
3844 // Send modified requst, this time with e2 subscriptions.
3845 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3846 params2.SetSubscriptionID(&restSubId)
3847
3848 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003849 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003850 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3851 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003852 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3853 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003854
3855 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3856
Markku Virtanen2b512b62021-07-30 12:04:00 +00003857 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003858 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3859 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3860 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3861 assert.NotEqual(t, e2SubsId2, 0)
3862
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003863 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003864
3865 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3866 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3867 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003868 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003869 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3870 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3871 assert.Equal(t, restSubId_resend, restSubId_resend2)
3872
Markku Virtanen2b512b62021-07-30 12:04:00 +00003873 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3874 assert.Equal(t, e2SubsId, e2SubsId1)
3875
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003876 mainCtrl.WaitOngoingRequestMapEmpty()
3877
Markku Virtanen42723e22021-06-15 10:09:23 +03003878 // Delete both e2 subscriptions
3879 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3880 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3881 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3882
3883 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003884 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003885 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003886}
3887
3888//-----------------------------------------------------------------------------
3889// stub stub stub
3890// +-------+ +---------+ +---------+ +---------+
3891// | xapp | | submgr | | e2term | | rtmgr |
3892// +-------+ +---------+ +---------+ +---------+
3893// | | | |
3894// | RESTSubReq | | |
3895// |---------------->| | |
3896// | RESTSubResp | | |
3897// |<----------------| | |
3898// | | RouteCreate | |
3899// | |--------------------------->|
3900// | | RouteResponse| |
3901// | |<---------------------------|
3902// | | SubReq | |
3903// | |------------->| |
3904// | | SubResp | |
3905// | |<-------------| |
3906// | RESTNotif1 | | |
3907// |<----------------| | |
3908// | RESTSubReq | | |
3909// | [with RestSUbsId + one additional e2 subDetail]
3910// |---------------->| | |
3911// | RESTNotif1 | | |
3912// | [for initial e2 subDetail] | |
3913// |<----------------| | |
3914// | | RouteCreate | |
3915// | |--------------------------->|
3916// | | RouteResponse| |
3917// | |<---------------------------|
3918// | | SubReq | |
3919// | |------------->| |
3920// | | SubResp | |
3921// | |<-------------| |
3922// | RESTNotif1 | | |
3923// |<----------------| | |
3924// | RESTSubReq | | |
3925// | [without RESTsubsId initial request] |
3926// |---------------->| | |
3927// | RESTNotif1 | | |
3928// |<----------------| | |
3929// | RESTSubDelReq | | |
3930// |---------------->| | |
3931// | RESTSubDelResp| | |
3932// |<----------------| | |
3933// | | SubDelReq | |
3934// | |------------->| |
3935// | | SubDelResp | |
3936// | |<-------------| |
3937// | | SubDelReq | |
3938// | |------------->| |
3939// | | SubDelResp | |
3940// | |<-------------| |
3941// | | | |
3942//
3943//-----------------------------------------------------------------------------
3944
3945func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003946
3947 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3948 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003949 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003950 Counter{cRestSubRespToXapp, 3},
3951 Counter{cSubReqToE2, 2},
3952 Counter{cSubRespFromE2, 2},
3953 Counter{cRestSubNotifToXapp, 4},
3954 Counter{cRestSubDelReqFromXapp, 1},
3955 Counter{cSubDelReqToE2, 2},
3956 Counter{cSubDelRespFromE2, 2},
3957 Counter{cRestSubDelRespToXapp, 1},
3958 })
3959
3960 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3961
3962 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3963
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003964 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003965
Anssi Mannila21782182021-12-10 10:56:02 +02003966 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003967 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3968 params2.SetSubscriptionID(&restSubId)
3969
3970 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003971 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003972 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3973 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3974
Markku Virtanen2b512b62021-07-30 12:04:00 +00003975 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3976 assert.Equal(t, e2SubsId, e2SubsId1)
3977 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3978 xappConn1.DecrementRequestCount()
3979
Markku Virtanen42723e22021-06-15 10:09:23 +03003980 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3981
3982 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3983 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3984 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3985 assert.NotEqual(t, e2SubsId2, 0)
3986
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003987 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003988
3989 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3990 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003991 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003992 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3993 // md5sum shall find the original request
3994 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3995 assert.Equal(t, restSubId_resend, restSubId_resend2)
3996
Markku Virtanen2b512b62021-07-30 12:04:00 +00003997 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3998 assert.Equal(t, e2SubsId, e2SubsId1)
3999
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004000 mainCtrl.WaitOngoingRequestMapEmpty()
4001
Markku Virtanen42723e22021-06-15 10:09:23 +03004002 // Delete both e2 subscriptions
4003 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4004 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
4005 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4006
4007 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03004008 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004009 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03004010}
4011
4012//-----------------------------------------------------------------------------
4013// stub stub stub
4014// +-------+ +---------+ +---------+ +---------+
4015// | xapp | | submgr | | e2term | | rtmgr |
4016// +-------+ +---------+ +---------+ +---------+
4017// | | | |
4018// | RESTSubReq | | |
4019// |---------------->| | |
4020// | RESTSubResp | | |
4021// |<----------------| | |
4022// | | RouteCreate | |
4023// | |--------------------------->|
4024// | | RouteResponse| |
4025// | |<---------------------------|
4026// | | SubReq | |
4027// | |------------->| |
4028// | | SubResp | |
4029// | |<-------------| |
4030// | RESTNotif1 | | |
4031// |<----------------| | |
4032// | RESTSubReq | | |
4033// | [with RestSUbsId + one additional e2 subDetail]
4034// |---------------->| | |
4035// | RESTNotif1 | | |
4036// | [for initial e2 subDetail] | |
4037// |<----------------| | |
4038// | | RouteCreate | |
4039// | |--------------------------->|
4040// | | RouteResponse| |
4041// | |<---------------------------|
4042// | | SubReq | |
4043// | |------------->| |
4044// | | SubResp | |
4045// | |<-------------| |
4046// | RESTNotif1 | | |
4047// |<----------------| | |
4048// | RESTSubDelReq | | |
4049// |---------------->| | |
4050// | RESTSubDelResp| | |
4051// |<----------------| | |
4052// | | SubDelReq | |
4053// | |------------->| |
4054// | | SubDelResp | |
4055// | |<-------------| |
4056// | | SubDelReq | |
4057// | |------------->| |
4058// | | SubDelResp | |
4059// | |<-------------| |
4060// | RESTSubReq | | |
4061// | [with RESTsubsId initial request] |
4062// |---------------->| | |
4063// | RESTSubResp | | |
4064// |<----------------| | |
4065// | | RouteCreate | |
4066// | |--------------------------->|
4067// | | RouteResponse| |
4068// | |<---------------------------|
4069// | | SubReq | |
4070// | |------------->| |
4071// | | SubResp | |
4072// | |<-------------| |
4073// | RESTNotif1 | | |
4074// |<----------------| | |
4075// | | | |
4076//
4077//-----------------------------------------------------------------------------
4078func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03004079
4080 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4081 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004082 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03004083 Counter{cRestSubRespToXapp, 3},
4084 Counter{cSubReqToE2, 3},
4085 Counter{cSubRespFromE2, 3},
4086 Counter{cRestSubNotifToXapp, 4},
4087 Counter{cRestSubDelReqFromXapp, 2},
4088 Counter{cSubDelReqToE2, 3},
4089 Counter{cSubDelRespFromE2, 3},
4090 Counter{cRestSubDelRespToXapp, 2},
4091 })
4092
4093 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4094
4095 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4096
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004097 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03004098
4099 // Send modified requst, this time with e2 subscriptions.
4100 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
4101 params2.SetSubscriptionID(&restSubId)
4102
4103 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004104 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03004105 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
4106 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
4107
Markku Virtanen2b512b62021-07-30 12:04:00 +00004108 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
4109 assert.Equal(t, e2SubsId, e2SubsId1)
4110
Markku Virtanen42723e22021-06-15 10:09:23 +03004111 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4112
4113 xappConn1.ExpectRESTNotification(t, restSubId_resend)
4114 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4115 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
4116 assert.NotEqual(t, e2SubsId2, 0)
4117
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004118 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03004119
4120 // Delete both e2 subscriptions
4121 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4122 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
4123 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4124
4125 waitSubsCleanup(t, e2SubsId, 10)
4126
4127 // Resend the original request, we shall find it's previous md5sum/restsubs
4128 // but the restsubscription has been already removed. This shall trigger a
4129 // fresh create.
4130 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4131
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004132 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03004133
4134 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4135
4136 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03004137 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004138 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03004139}
4140
Anssi Mannila27385172021-12-22 09:41:54 +02004141//-----------------------------------------------------------------------------
4142// TestRESTSubDelReqRetransmission
4143//
4144// stub stub
4145// +-------+ +---------+ +---------+
4146// | xapp | | submgr | | e2term |
4147// +-------+ +---------+ +---------+
4148// | | |
4149// | RESTSubReq | |
4150// |---------------->| |
4151// | | |
4152// | RESTSubResp | |
4153// |<----------------| |
4154// | | SubReq |
4155// | |------------->|
4156// | | SubResp |
4157// | |<-------------|
4158// | RESTNotif1 | |
4159// |<----------------| |
4160// | | |
4161// | RESTSubDelReq | |
4162// |---------------->| |
4163// | RESTSubDelResp | |
4164// |<----------------| |
4165// | | SubDelReq |
4166// | |------------->|
4167// | RESTSubDelReq | |
4168// |---------------->| |
4169// | RESTSubDelResp | |
4170// |<----------------| |
4171// | | SubDelResp |
4172// | |<-------------|
4173// | | |
4174//
4175//-----------------------------------------------------------------------------
4176
archaggeafbf95f2021-04-14 08:54:05 +03004177func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004178
4179 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004180 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004181 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004182 Counter{cSubReqToE2, 1},
4183 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004184 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004185 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004186 Counter{cSubDelReqToE2, 1},
4187 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004188 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004189 })
4190
4191 var params *teststube2ap.RESTSubsReqParams = nil
4192
4193 //Subs Create
4194 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4195
4196 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4197
4198 //Subs Delete
4199 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4200 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4201
Anssi Mannila27385172021-12-22 09:41:54 +02004202 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03004203 seqBef := mainCtrl.get_msgcounter(t)
4204 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4205 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
4206
Anssi Mannila27385172021-12-22 09:41:54 +02004207 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03004208 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4209
4210 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004211 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004212 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004213}
4214
4215//-----------------------------------------------------------------------------
4216// TestRESTSubReqDelReq
4217//
4218// stub stub
4219// +-------+ +---------+ +---------+
4220// | xapp | | submgr | | e2term |
4221// +-------+ +---------+ +---------+
4222// | | |
4223// | RESTSubReq | |
4224// |---------------->| |
4225// | | |
4226// | RESTSubResp | |
4227// |<----------------| |
4228// | | SubReq |
4229// | |------------->|
4230// | RESTSubDelReq | |
4231// |---------------->| |
4232// | RESTSubDelResp | |
4233// | unsuccess | |
4234// |<----------------| |
4235// | | SubResp |
4236// | |<-------------|
4237// | RESTNotif1 | |
4238// |<----------------| |
4239// | | |
4240// | [SUBS DELETE] |
4241// | | |
4242//
4243//-----------------------------------------------------------------------------
4244func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004245
4246 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004247 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004248 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004249 Counter{cSubReqToE2, 1},
4250 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004251 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004252 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004253 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004254 Counter{cSubDelReqToE2, 1},
4255 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004256 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004257 })
4258
4259 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004260
4261 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004262 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004263 restSubId := xappConn1.SendRESTSubsReq(t, params)
4264
4265 // Del. This will fail as processing of the subscription
4266 // is still ongoing in submgr. Deletion is not allowed before
4267 // subscription creation has been completed.
4268 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4269 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4270 xappConn1.ExpectRESTNotification(t, restSubId)
4271 e2termConn1.SendSubsResp(t, crereq, cremsg)
4272 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4273
4274 // Retry del
4275 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4276
4277 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4278 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4279
4280 // Wait that subs is cleaned
4281 waitSubsCleanup(t, e2SubsId, 10)
4282 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004283 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004284}
4285
Anssi Mannila27385172021-12-22 09:41:54 +02004286//-----------------------------------------------------------------------------
4287// TestRESTSubReqAndSubDelOkTwoParallel
4288//
4289// stub stub stub
4290// +-------+ +-------+ +---------+ +---------+
4291// | xapp2 | | xapp1 | | submgr | | e2term |
4292// +-------+ +-------+ +---------+ +---------+
4293// | | | |
4294// | | RESTSubReq1 | |
4295// | |------------->| |
4296// | | RESTSubResp1 | |
4297// | |<-------------| |
4298// | | | |
4299// | | | SubReq1 |
4300// | | |------------->|
4301// | | | |
4302// | RESTSubReq2 | |
4303// |------------------------>| |
4304// | RESTSubResp2 | |
4305// |<------------------------| |
4306// | | | |
4307// | | | SubReq2 |
4308// | | |------------->|
4309// | | | |
4310// | | | SubResp1 |
4311// | | |<-------------|
4312// | | RESTNotif1 | |
4313// | |<-------------| |
4314// | | | |
4315// | | | SubResp2 |
4316// | | |<-------------|
4317// | RESTNotif2 | |
4318// |<------------------------| |
4319// | | | |
4320// | | [SUBS 1 DELETE] |
4321// | | | |
4322// | | [SUBS 2 DELETE] |
4323// | | | |
4324//
4325//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004326
4327func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004328
4329 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004330 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004331 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004332 Counter{cSubReqToE2, 2},
4333 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004334 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004335 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004336 Counter{cSubDelReqToE2, 2},
4337 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004338 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004339 })
4340
4341 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004342 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004343 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004344 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004345
4346 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004347 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004348 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004349 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004350
4351 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4352 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4353
4354 //XappConn1 receives both of the responses
4355 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4356
4357 //Resp1
4358 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4359 //Resp2
4360 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4361
4362 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004363 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004364 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004365 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004366
4367 //Del1
4368 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4369 //Del2
4370 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
4371
4372 //Wait that subs is cleaned
4373 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
4374 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4375
4376 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004377 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004378}
4379
Anssi Mannila27385172021-12-22 09:41:54 +02004380//-----------------------------------------------------------------------------
4381// TestRESTSameSubsDiffRan
4382// Same subscription to different RANs
4383//
4384// stub stub
4385// +-------+ +---------+ +---------+
4386// | xapp | | submgr | | e2term |
4387// +-------+ +---------+ +---------+
4388// | | |
4389// | RESTSubReq(r1) | |
4390// |---------------->| |
4391// | RESTSubResp(r1) | |
4392// |<----------------| |
4393// | | |
4394// | | SubReq(r1) |
4395// | |------------->|
4396// | | |
4397// | | SubResp(r1) |
4398// | |<-------------|
4399// | | |
4400// | RESTNotif(r1) | |
4401// |<----------------| |
4402// | | |
4403// | RESTSubReq(r2) | |
4404// |---------------->| |
4405// | | |
4406// | RESTSubResp(r2) | |
4407// |<----------------| |
4408// | | SubReq(r2) |
4409// | |------------->|
4410// | | |
4411// | | SubResp(r2) |
4412// | |<-------------|
4413// | | |
4414// | RESTNotif(r2) | |
4415// |<----------------| |
4416// | | |
4417// | [SUBS r1 DELETE] |
4418// | | |
4419// | [SUBS r2 DELETE] |
4420// | | |
4421//
4422//-----------------------------------------------------------------------------
4423
archaggeafbf95f2021-04-14 08:54:05 +03004424func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004425
4426 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004427 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004428 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004429 Counter{cSubReqToE2, 2},
4430 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004431 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004432 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004433 Counter{cSubDelReqToE2, 2},
4434 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004435 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004436 })
4437
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004438 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004439 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004440 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004441
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004442 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004443 params.SetMeid("RAN_NAME_2")
4444 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004445 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004446
4447 //Del1
4448 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4449 //Del2
4450 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
4451
4452 //Wait that subs is cleaned
4453 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4454 waitSubsCleanup(t, e2SubsId2, 10)
4455
4456 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004457 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004458}
4459
Anssi Mannila27385172021-12-22 09:41:54 +02004460//-----------------------------------------------------------------------------
4461// TestRESTSubReqRetryInSubmgr
4462//
4463// stub stub
4464// +-------+ +---------+ +---------+
4465// | xapp | | submgr | | e2term |
4466// +-------+ +---------+ +---------+
4467// | | |
4468// | RESTSubReq | |
4469// |---------------->| |
4470// | RESTSubResp | |
4471// |<----------------| |
4472// | | SubReq |
Anssi Mannila92c38552021-12-29 09:59:24 +02004473// | |------------->|
Anssi Mannila27385172021-12-22 09:41:54 +02004474// | | |
4475// | | |
4476// | | SubReq |
4477// | |------------->|
4478// | | SubResp |
4479// | |<-------------|
4480// | | |
4481// | RESTNotif | |
4482// |<----------------| |
4483// | | |
4484// | [SUBS DELETE] |
4485// | | |
4486//
4487//-----------------------------------------------------------------------------
4488
archaggeafbf95f2021-04-14 08:54:05 +03004489func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004490
4491 // Init counter check
4492 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004493 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004494 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004495 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004496 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004497 Counter{cSubReReqToE2, 1},
4498 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004499 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004500 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004501 Counter{cSubDelReqToE2, 1},
4502 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004503 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004504 })
4505
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004506 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004507 restSubId := xappConn1.SendRESTSubsReq(t, params)
4508
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004509 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004510
4511 // Catch the first message and ignore it
4512 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004513 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004514
4515 // The second request is being handled normally
4516 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4517 xappConn1.ExpectRESTNotification(t, restSubId)
4518 e2termConn1.SendSubsResp(t, crereq, cremsg)
4519 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4520
4521 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4522
Anssi Mannila27385172021-12-22 09:41:54 +02004523 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004524 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4525
4526 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4527 //Wait that subs is cleaned
4528 waitSubsCleanup(t, e2SubsId, 10)
4529
4530 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004531 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004532}
4533
4534//-----------------------------------------------------------------------------
4535// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4536//
4537// stub stub
4538// +-------+ +---------+ +---------+
4539// | xapp | | submgr | | e2term |
4540// +-------+ +---------+ +---------+
4541// | | |
4542// | RESTSubReq | |
4543// |---------------->| |
4544// | | |
4545// | RESTSubResp | |
4546// |<----------------| |
4547// | | SubReq |
4548// | |------------->|
4549// | | |
4550// | | |
4551// | | SubReq |
4552// | |------------->|
4553// | | |
4554// | | SubDelReq |
4555// | |------------->|
4556// | | |
4557// | | |
4558// | | SubDelReq |
4559// | |------------->|
4560// | | |
4561// | | |
4562// | | SubDelResp |
4563// | |<-------------|
4564// | RESTNotif | |
4565// | unsuccess | |
4566// |<----------------| |
4567// | | |
4568// | [SUBS DELETE] |
4569// | | |
4570//
4571//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004572
archaggeafbf95f2021-04-14 08:54:05 +03004573func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004574
4575 // Init counter check
4576 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004577 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004578 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004579 Counter{cSubReqToE2, 1},
4580 Counter{cSubReReqToE2, 1},
4581 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004582 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004583 Counter{cSubDelReqToE2, 1},
4584 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004585 Counter{cRestSubDelReqFromXapp, 1},
4586 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004587 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004588
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004589 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004590 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004591 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004592
4593 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004594 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004595
4596 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004597 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004598
4599 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004600 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004601 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004602 xappConn1.WaitRESTNotification(t, restSubId)
4603
Anssi Mannilab43397e2021-11-16 12:06:16 +02004604 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4605
archaggeafbf95f2021-04-14 08:54:05 +03004606 // Wait that subs is cleaned
4607 waitSubsCleanup(t, delreq.RequestId.InstanceId, 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
Anssi Mannila27385172021-12-22 09:41:54 +02004612//-----------------------------------------------------------------------------
4613// TestREST2eTermNotRespondingToSubReq
4614//
4615// stub stub
4616// +-------+ +---------+ +---------+
4617// | xapp | | submgr | | e2term |
4618// +-------+ +---------+ +---------+
4619// | | |
4620// | RESTSubReq | |
4621// |---------------->| |
4622// | RESTSubResp | |
4623// |<----------------| |
4624// | | SubReq |
4625// | |------------->|
4626// | | |
4627// | | SubReq |
4628// | |------------->|
4629// | | |
4630// | | SubDelReq |
4631// | |------------->|
4632// | | |
4633// | | SubDelReq |
4634// | |------------->|
4635// | RESTNotif(Unsuccessful) |
4636// |<----------------| |
4637// | | |
4638// | RESTSubDelReq | |
4639// |---------------->| |
4640// | RESTSubDelResp | |
4641// |<----------------| |
4642// | | |
4643//
4644//-----------------------------------------------------------------------------
4645
archaggeafbf95f2021-04-14 08:54:05 +03004646func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004647
4648 // Init counter check
4649 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004650 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004651 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004652 Counter{cSubReqToE2, 1},
4653 Counter{cSubReReqToE2, 1},
4654 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004655 Counter{cSubDelReReqToE2, 1},
4656 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004657 Counter{cSubDelReqToE2, 1},
4658 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004659 Counter{cRestSubDelReqFromXapp, 1},
4660 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004661 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004662
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004663 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004664 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004665 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004666
4667 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004668 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004669
4670 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004671 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004672
4673 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004674 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004675
Markku Virtanen55d2a282021-06-04 14:46:56 +03004676 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004677 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004678 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004679
4680 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4681
Anssi Mannilab43397e2021-11-16 12:06:16 +02004682 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004683
Anssi Mannilab43397e2021-11-16 12:06:16 +02004684 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004685 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004686 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004687}
4688
4689//-----------------------------------------------------------------------------
4690// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4691//
4692// stub stub
4693// +-------+ +---------+ +---------+
4694// | xapp | | submgr | | e2term |
4695// +-------+ +---------+ +---------+
4696// | | |
4697// | RESTSubReq | |
4698// |---------------->| |
4699// | | |
4700// | RESTSubResp | |
4701// |<----------------| |
4702// | | SubReq |
4703// | |------------->|
4704// | | |
4705// | | |
4706// | | SubReq |
4707// | |------------->|
4708// | | |
4709// | | SubDelReq |
4710// | |------------->|
4711// | | |
4712// | | |
4713// | | SubDelReq |
4714// | |------------->|
4715// | | |
4716// | | |
4717// | | SubDelResp |
4718// | |<-------------|
4719// | RESTNotif | |
4720// | unsuccess | |
4721// |<----------------| |
4722// | | |
4723// | [SUBS DELETE] |
4724// | | |
4725//
4726//-----------------------------------------------------------------------------
4727func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004728
4729 // Init counter check
4730 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004731 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004732 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004733 Counter{cSubReqToE2, 1},
4734 Counter{cSubReReqToE2, 1},
4735 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004736 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004737 Counter{cSubDelReqToE2, 1},
4738 Counter{cSubDelReReqToE2, 1},
4739 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004740 Counter{cRestSubDelReqFromXapp, 1},
4741 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004742 })
4743
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004744 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004745 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004746 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004747
4748 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004749 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004750
4751 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004752 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004753
4754 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004755 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004756
Markku Virtanen55d2a282021-06-04 14:46:56 +03004757 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004758 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004759 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004760
4761 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4762
Anssi Mannilab43397e2021-11-16 12:06:16 +02004763 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004764
Anssi Mannilab43397e2021-11-16 12:06:16 +02004765 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004766 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004767 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004768}
4769
4770//-----------------------------------------------------------------------------
4771// TestRESTSubReqSubFailRespInSubmgr
4772//
4773// stub stub
4774// +-------+ +---------+ +---------+
4775// | xapp | | submgr | | e2term |
4776// +-------+ +---------+ +---------+
4777// | | |
4778// | RESTSubReq | |
4779// |---------------->| |
4780// | | |
4781// | RESTSubResp | |
4782// |<----------------| |
4783// | | SubReq |
4784// | |------------->|
4785// | | |
4786// | | SubFail |
4787// | |<-------------|
4788// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004789// | RESTNotif | |
4790// | unsuccess | |
4791// |<----------------| |
4792// | | |
4793// | [SUBS DELETE] |
4794// | | |
4795//
4796//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004797
archaggeafbf95f2021-04-14 08:54:05 +03004798func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004799
4800 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004801 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004802 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004803 Counter{cSubReqToE2, 1},
4804 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004805 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004806 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004807 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004808 })
4809
4810 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004811 const e2Timeout int64 = 2
4812 const e2RetryCount int64 = 1
4813 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004814
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004815 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004816 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004817 restSubId := xappConn1.SendRESTSubsReq(t, params)
4818
4819 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4820 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4821 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004822 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004823 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4824
archaggeafbf95f2021-04-14 08:54:05 +03004825 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004826 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004827
4828 // REST subscription sill there to be deleted
4829 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4830
4831 // Wait that subs is cleaned
4832 waitSubsCleanup(t, e2SubsId, 10)
4833
4834 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004835 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004836}
4837
4838//-----------------------------------------------------------------------------
Anssi Mannila56233b02022-01-24 13:26:42 +02004839// TestRESTSubReqPartialResp
4840//
4841// stub stub
4842// +-------+ +---------+ +---------+
4843// | xapp | | submgr | | e2term |
4844// +-------+ +---------+ +---------+
4845// | | |
4846// | RESTSubReq | |
4847// |---------------->| |
4848// | RESTSubResp | |
4849// |<----------------| |
4850// | | SubReq |
4851// | |------------->|
4852// | | SubResp | Partially accepted
4853// | |<-------------|
4854// | | |
4855// | RESTNotif | |
4856// |<----------------| |
4857// | | |
4858// | [SUBS DELETE] |
4859// | | |
4860//
4861//-----------------------------------------------------------------------------
4862
4863func TestRESTSubReqPartialResp(t *testing.T) {
4864
4865 // Init counter check
4866 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4867 Counter{cRestSubReqFromXapp, 1},
4868 Counter{cRestSubRespToXapp, 1},
4869 Counter{cSubReqToE2, 1},
4870 Counter{cSubRespFromE2, 1},
4871 Counter{cPartialSubRespFromE2, 1},
4872 Counter{cRestSubNotifToXapp, 1},
4873 Counter{cRestSubDelReqFromXapp, 1},
4874 Counter{cSubDelReqToE2, 1},
4875 Counter{cSubDelRespFromE2, 1},
4876 Counter{cRestSubDelRespToXapp, 1},
4877 })
4878
4879 // Req
4880 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4881
4882 actionId := int64(2)
4883 actionType := "report"
4884 actionDefinition := []int64{5678, 1}
4885 subsequestActionType := "continue"
4886 timeToWait := "w10ms"
4887 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4888
4889 restSubId := xappConn1.SendRESTSubsReq(t, params)
4890 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4891 xappConn1.ExpectRESTNotification(t, restSubId)
4892
4893 actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{}
4894 actionNotAdmittedItem.ActionId = 1
4895 actionNotAdmittedItem.Cause.Content = 1
4896 actionNotAdmittedItem.Cause.Value = 8
4897 actionNotAdmittedList := e2ap.ActionNotAdmittedList{}
4898 actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem)
4899 e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList)
4900 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4901
4902 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4903
4904 // Del
4905 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4906
4907 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4908 //Wait that subs is cleaned
4909 waitSubsCleanup(t, e2SubsId, 10)
4910
4911 mainCtrl.VerifyCounterValues(t)
4912 mainCtrl.VerifyAllClean(t)
4913}
4914
4915//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004916// TestRESTSubDelReqRetryInSubmgr
4917//
4918// stub stub
4919// +-------+ +---------+ +---------+
4920// | xapp | | submgr | | e2term |
4921// +-------+ +---------+ +---------+
4922// | | |
4923// | [SUBS CREATE] |
4924// | | |
4925// | | |
4926// | RESTSubDelReq | |
4927// |---------------->| |
4928// | | |
4929// | RESTSubDelResp | |
4930// |<----------------| |
4931// | | SubDelReq |
4932// | |------------->|
4933// | | |
4934// | | SubDelReq |
4935// | |------------->|
4936// | | |
4937// | | SubDelResp |
4938// | |<-------------|
4939// | | |
4940//
4941//-----------------------------------------------------------------------------
4942func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004943
4944 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004945 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004946 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004947 Counter{cSubReqToE2, 1},
4948 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004949 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004950 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004951 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004952 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004953 Counter{cSubDelReReqToE2, 1},
4954 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004955 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004956 })
4957 // Req
4958 var params *teststube2ap.RESTSubsReqParams = nil
4959 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4960
4961 // Del
4962 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4963
4964 // E2t: Receive 1st SubsDelReq
4965 e2termConn1.RecvSubsDelReq(t)
4966
4967 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4968 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4969 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4970
4971 //Wait that subs is cleaned
4972 waitSubsCleanup(t, e2SubsId, 10)
4973
4974 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004975 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004976}
4977
4978//-----------------------------------------------------------------------------
4979// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4980//
4981// stub stub
4982// +-------+ +---------+ +---------+
4983// | xapp | | submgr | | e2term |
4984// +-------+ +---------+ +---------+
4985// | | |
4986// | [SUBS CREATE] |
4987// | | |
4988// | | |
4989// | RESTSubDelReq | |
4990// |---------------->| |
4991// | | |
4992// | RESTSubDelResp | |
4993// |<----------------| |
4994// | | SubDelReq |
4995// | |------------->|
4996// | | |
4997// | | SubDelReq |
4998// | |------------->|
4999// | | |
5000// | | |
5001//
5002//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005003
archaggeafbf95f2021-04-14 08:54:05 +03005004func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005005
5006 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005007 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005008 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005009 Counter{cSubReqToE2, 1},
5010 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005011 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005012 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005013 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005014 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005015 Counter{cSubDelReReqToE2, 1},
5016 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005017 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005018 })
5019
5020 // Req
5021 var params *teststube2ap.RESTSubsReqParams = nil
5022 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5023
5024 // Del
5025 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5026
5027 // E2t: Receive 1st SubsDelReq
5028 e2termConn1.RecvSubsDelReq(t)
5029
5030 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5031 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5032 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5033
5034 //Wait that subs is cleaned
5035 waitSubsCleanup(t, e2SubsId, 10)
5036
5037 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005038 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005039}
5040
5041//-----------------------------------------------------------------------------
5042// TestRESTSubDelReqSubDelFailRespInSubmgr
5043//
5044// stub stub
5045// +-------+ +---------+ +---------+
5046// | xapp | | submgr | | e2term |
5047// +-------+ +---------+ +---------+
5048// | | |
5049// | [SUBS CREATE] |
5050// | | |
5051// | | |
5052// | RESTSubDelReq | |
5053// |---------------->| |
5054// | | |
5055// | RESTSubDelResp | |
5056// |<----------------| |
5057// | | SubDelReq |
5058// | |------------->|
5059// | | |
5060// | | SubDelFail |
5061// | |<-------------|
5062// | | |
5063//
5064//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005065
archaggeafbf95f2021-04-14 08:54:05 +03005066func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005067
5068 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005069 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005070 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005071 Counter{cSubReqToE2, 1},
5072 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005073 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005074 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005075 Counter{cSubDelReqToE2, 1},
5076 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005077 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005078 })
5079
5080 // Req
5081 var params *teststube2ap.RESTSubsReqParams = nil
5082 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5083
5084 // Del
5085 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5086
5087 // E2t: Send receive SubsDelReq and send SubsDelFail
5088 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5089 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5090
5091 //Wait that subs is cleaned
5092 waitSubsCleanup(t, e2SubsId, 10)
5093
5094 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005095 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005096}
5097
5098//-----------------------------------------------------------------------------
5099// TestRESTSubReqAndSubDelOkSameAction
5100//
5101// stub stub
5102// +-------+ +-------+ +---------+ +---------+
5103// | xapp2 | | xapp1 | | submgr | | e2term |
5104// +-------+ +-------+ +---------+ +---------+
5105// | | | |
5106// | | RESTSubReq1 | |
5107// | |---------------->| |
5108// | | | |
5109// | | RESTSubResp1 | |
5110// | |<----------------| |
5111// | | | |
5112// | | | SubReq1 |
5113// | | |------------->|
5114// | | | SubResp1 |
5115// | | |<-------------|
5116// | | RESTNotif1 | |
5117// | |<----------------| |
5118// | | | |
5119// | RESTSubReq2 | |
5120// |------------------------------>| |
5121// | | | |
5122// | RESTSubResp2 | |
5123// |<------------------------------| |
5124// | | | |
5125// | | RESTNotif2 | |
5126// |<------------------------------| |
5127// | | | |
5128// | | RESTSubDelReq1 | |
5129// | |---------------->| |
5130// | | | |
5131// | | RESTSubDelResp1 | |
5132// | |<----------------| |
5133// | | | |
5134// | RESTSubDelReq2 | |
5135// |------------------------------>| |
5136// | | | |
5137// | RESTSubDelResp2 | |
5138// |<------------------------------| |
5139// | | | |
5140// | | | SubDelReq2 |
5141// | | |------------->|
5142// | | | |
5143// | | | SubDelResp2 |
5144// | | |<-------------|
5145// | | | |
5146//
5147//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005148
archaggeafbf95f2021-04-14 08:54:05 +03005149func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005150
5151 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005152 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005153 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005154 Counter{cSubReqToE2, 1},
5155 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005156 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005157 Counter{cMergedSubscriptions, 1},
5158 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005159 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005160 Counter{cSubDelReqToE2, 1},
5161 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005162 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005163 })
5164
5165 // Req1
5166 var params *teststube2ap.RESTSubsReqParams = nil
5167
5168 //Subs Create
5169 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5170 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5171
5172 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005173 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005174 params.SetMeid("RAN_NAME_1")
5175
5176 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005177 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005178 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03005179 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005180 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005181 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005182 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005183 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005184
5185 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5186
5187 // Del1
5188 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5189
5190 // Del2
5191 deleteXapp2Subscription(t, &restSubId2)
5192
5193 //Wait that subs is cleaned
5194 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005195 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005196 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005197}
5198
5199//-----------------------------------------------------------------------------
5200// TestSubReqAndSubDelOkSameActionParallel
5201//
5202// stub stub stub
5203// +-------+ +-------+ +---------+ +---------+
5204// | xapp2 | | xapp1 | | submgr | | e2term |
5205// +-------+ +-------+ +---------+ +---------+
5206// | | | |
5207// | | | |
5208// | | | |
5209// | | SubReq1 | |
5210// | |------------->| |
5211// | | | |
5212// | | | SubReq1 |
5213// | | |------------->|
5214// | SubReq2 | |
5215// |--------------------------->| |
5216// | | | SubResp1 |
5217// | | |<-------------|
5218// | | SubResp1 | |
5219// | |<-------------| |
5220// | | | SubReq2 |
5221// | | |------------->|
5222// | | | |
5223// | | | SubResp2 |
5224// | | |<-------------|
5225// | SubResp2 | |
5226// |<---------------------------| |
5227// | | | |
5228// | | SubDelReq 1 | |
5229// | |------------->| |
5230// | | | |
5231// | | SubDelResp 1 | |
5232// | |<-------------| |
5233// | | | |
5234// | SubDelReq 2 | |
5235// |--------------------------->| |
5236// | | | |
5237// | | | SubDelReq 2 |
5238// | | |------------->|
5239// | | | |
5240// | | | SubDelReq 2 |
5241// | | |------------->|
5242// | | | |
5243// | SubDelResp 2 | |
5244// |<---------------------------| |
5245//
5246func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005247
5248 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005249 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005250 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005251 Counter{cSubReqToE2, 2},
5252 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005253 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005254 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005255 Counter{cSubDelReqToE2, 2},
5256 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005257 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005258 })
5259
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005260 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005261 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5262 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5263
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005264 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005265 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5266
5267 xappConn1.ExpectRESTNotification(t, restSubId1)
5268 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5269 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
5270
5271 xappConn2.ExpectRESTNotification(t, restSubId2)
5272 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
5273 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
5274 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5275
5276 // Del1
5277 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5278 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5279 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5280 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5281
5282 // Del2
5283 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5284 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
5285 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
5286
5287 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005288 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005289 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005290}
5291
5292//-----------------------------------------------------------------------------
5293// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
5294//
5295// stub stub stub
5296// +-------+ +-------+ +---------+ +---------+
5297// | xapp2 | | xapp1 | | submgr | | e2term |
5298// +-------+ +-------+ +---------+ +---------+
5299// | | | |
5300// | | | |
5301// | | | |
5302// | | RESTSubReq1 | |
5303// | |---------------->| |
5304// | | | |
5305// | | RESTSubResp1 | |
5306// | |<----------------| |
5307// | | | SubReq1 |
5308// | | |------------->|
5309// | RESTSubReq2 | |
5310// |------------------------------>| |
5311// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005312// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005313// |<------------------------------| |
5314// | | | SubReq1 |
5315// | | |------------->|
5316// | | | |
5317// | | | |
5318// | | | SubDelReq |
5319// | | |------------->|
5320// | | | |
5321// | | | SubDelResp |
5322// | | |<-------------|
5323// | | RESTNotif1 | |
5324// | | unsuccess | |
5325// | |<----------------| |
5326// | RESTNotif2 | |
5327// | | unsuccess | |
5328// |<------------------------------| |
5329// | | | |
5330// | | RESTSubDelReq1 | |
5331// | |---------------->| |
5332// | | | |
5333// | | RESTSubDelResp1 | |
5334// | |<----------------| |
5335// | | | |
5336// | RESTSubDelReq2 | |
5337// |------------------------------>| |
5338// | | | |
5339// | RESTSubDelResp2 | |
5340// |<------------------------------| |
5341//
5342//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005343
archaggeafbf95f2021-04-14 08:54:05 +03005344func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005345
5346 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005347 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005348 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005349 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005350 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005351 Counter{cSubReqTimerExpiry, 2},
5352 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005353 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005354 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005355 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005356 Counter{cSubDelReqToE2, 1},
5357 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005358 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005359 })
archaggeafbf95f2021-04-14 08:54:05 +03005360 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005361
5362 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005363 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005364 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5365 crereq1, _ := e2termConn1.RecvSubsReq(t)
5366
5367 // Req2
5368 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005369 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005370 params2.SetMeid("RAN_NAME_1")
5371 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5372 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5373
5374 //Req1 (retransmitted)
5375 e2termConn1.RecvSubsReq(t)
5376
5377 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005378
5379 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005380 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5381
Markku Virtanenda34eec2021-05-20 08:22:04 +00005382 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005383 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005384 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005385 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005386
5387 // Del1
5388 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5389
5390 // Del2
5391 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5392
Markku Virtanenda34eec2021-05-20 08:22:04 +00005393 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5394
archaggeafbf95f2021-04-14 08:54:05 +03005395 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005396 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005397 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005398 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005399}
5400
5401//-----------------------------------------------------------------------------
5402// TestRESTSubReqAndSubDelNokSameActionParallel
5403//
5404// stub stub stub
5405// +-------+ +-------+ +---------+ +---------+
5406// | xapp2 | | xapp1 | | submgr | | e2term |
5407// +-------+ +-------+ +---------+ +---------+
5408// | | | |
5409// | | | |
5410// | | | |
5411// | | RESTSubReq1 | |
5412// | |---------------->| |
5413// | | | |
5414// | | RESTSubResp1 | |
5415// | |<----------------| |
5416// | | | SubReq1 |
5417// | | |------------->|
5418// | RESTSubReq2 | |
5419// |------------------------------>| |
5420// | | | |
5421// | RESTSubDelResp2 | |
5422// |<------------------------------| |
5423// | | | SubFail1 |
5424// | | |<-------------|
5425// | | | |
5426// | | RESTNotif1 | |
5427// | | unsuccess | |
5428// | |<----------------| |
5429// | RESTNotif2 | |
5430// | | unsuccess | |
5431// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005432// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005433// | | 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 +03005434// | |---------------->| |
5435// | | | |
5436// | | RESTSubDelResp1 | |
5437// | |<----------------| |
5438// | | | |
5439// | RESTSubDelReq2 | |
5440// |------------------------------>| |
5441// | | | |
5442// | RESTSubDelResp2 | |
5443// |<------------------------------| |
5444//
5445//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005446
archaggeafbf95f2021-04-14 08:54:05 +03005447func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005448
5449 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005450 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005451 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005452 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005453 Counter{cSubReqToE2, 1},
5454 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005455 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005456 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005457 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005458 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005459 })
5460
5461 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005462
5463 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005464 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005465 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5466 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5467
5468 // Req2
5469 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005470 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005471 params2.SetMeid("RAN_NAME_1")
5472 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5473 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5474
5475 // E2t: send SubsFail (first)
5476 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5477 fparams1.Set(crereq1)
5478 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5479
archaggeafbf95f2021-04-14 08:54:05 +03005480 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005481 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005482 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005483 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005484 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005485
5486 // Del1
5487 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5488
5489 // Del2
5490 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5491
5492 //Wait that subs is cleaned
5493 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5494 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005495 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005496 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005497}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005498
Anssi Mannila27385172021-12-22 09:41:54 +02005499//-----------------------------------------------------------------------------
5500// TestRESTSubReqPolicyAndSubDelOk
5501//
5502// stub stub
5503// +-------+ +---------+ +---------+
5504// | xapp | | submgr | | e2term |
5505// +-------+ +---------+ +---------+
5506// | | |
5507// | RESTSubReq | |
5508// |--------------->| |
5509// | RESTSubResp | |
5510// |<---------------| |
5511// | | |
5512// | | SubReq |
5513// | |------------->|
5514// | | |
5515// | | SubResp |
5516// | |<-------------|
5517// | | |
5518// | RESTNotif | |
5519// |<---------------| |
5520// | | |
5521// | | |
5522// | RESTSubDelReq | |
5523// |--------------->| |
5524// | RESTSubDelResp | |
5525// |<---------------| |
5526// | | |
5527// | | SubDelReq |
5528// | |------------->|
5529// | | |
5530// | | SubDelResp |
5531// | |<-------------|
5532// | | |
5533//
5534//-----------------------------------------------------------------------------
5535
archaggeafbf95f2021-04-14 08:54:05 +03005536func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005537
5538 // Init counter check
5539 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005540 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005541 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005542 Counter{cSubReqToE2, 1},
5543 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005544 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005545 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005546 Counter{cSubDelReqToE2, 1},
5547 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005548 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005549 })
5550
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005551 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005552 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005553 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005554
5555 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5556 xappConn1.ExpectRESTNotification(t, restSubId)
5557 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5558 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005559 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005560
5561 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5562 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5563 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5564
5565 // Wait that subs is cleaned
5566 waitSubsCleanup(t, e2SubsId, 10)
5567 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005568 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005569}
5570
5571//-----------------------------------------------------------------------------
5572// TestRESTSubReqPolicyChangeAndSubDelOk
5573//
5574// stub stub
5575// +-------+ +---------+ +---------+
5576// | xapp | | submgr | | e2term |
5577// +-------+ +---------+ +---------+
5578// | | |
5579// | RESTSubReq | |
5580// |---------------->| |
5581// | | |
5582// | RESTSubResp | |
5583// |<----------------| |
5584// | | SubReq |
5585// | |------------->|
5586// | | |
5587// | | SubResp |
5588// | |<-------------|
5589// | | |
5590// | RESTNotif | |
5591// |<----------------| |
5592// | | |
5593// | RESTSubReq | |
5594// |---------------->| |
5595// | | |
5596// | RESTSubResp | |
5597// |<----------------| |
5598// | | SubReq |
5599// | |------------->|
5600// | | |
5601// | | SubResp |
5602// | |<-------------|
5603// | | |
5604// | RESTNotif | |
5605// |<----------------| |
5606// | | |
5607// | RESTSubDelReq | |
5608// |---------------->| |
5609// | | |
5610// | | SubDelReq |
5611// | |------------->|
5612// | | |
5613// | | SubDelResp |
5614// | |<-------------|
5615// | | |
5616// | RESTSubDelResp | |
5617// |<----------------| |
5618//
5619//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005620
archaggeafbf95f2021-04-14 08:54:05 +03005621func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005622
5623 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005624 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005625 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005626 Counter{cSubReqToE2, 2},
5627 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005628 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005629 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005630 Counter{cSubDelReqToE2, 1},
5631 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005632 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005633 })
5634
5635 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005636 const e2Timeout int64 = 1
5637 const e2RetryCount int64 = 0
5638 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005639
5640 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005641 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005642 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005643 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5644
5645 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005646 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005647
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005648 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005649 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005650 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005651 params.SetTimeToWait("w200ms")
5652 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5653
5654 // Del
5655 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5656
5657 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5658 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5659
5660 // Wait that subs is cleaned
5661 waitSubsCleanup(t, e2SubsId, 10)
5662 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005663 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005664}
5665
5666//-----------------------------------------------------------------------------
aditverm323c77e2023-09-20 09:50:47 +05305667// TestRESTSubReqPolicyChangeNokAndSubDelOk
5668//
5669// stub stub
5670// +-------+ +---------+ +---------+
5671// | xapp | | submgr | | e2term |
5672// +-------+ +---------+ +---------+
5673// | | |
5674// | RESTSubReq | |
5675// |---------------->| |
5676// | | |
5677// | RESTSubResp | |
5678// |<----------------| |
5679// | | SubReq |
5680// | |------------->|
5681// | | |
5682// | | SubResp |
5683// | |<-------------|
5684// | | |
5685// | RESTNotif | |
5686// |<----------------| |
5687// | | |
5688// | RESTSubReq | |
5689// |---------------->| |
5690// | | |
5691// | RESTSubResp | |
5692// |<----------------| |
5693// | | SubReq |
5694// | |------------->|
5695// | | |
5696// | | SubFail |
5697// | |<-------------|
5698// | | |
5699// | RESTNotif | |
5700// |<----------------| |
5701// | | |
5702// | RESTSubDelReq | |
5703// |---------------->| |
5704// | | |
5705// | | SubDelReq |
5706// | |------------->|
5707// | | |
5708// | | SubDelResp |
5709// | |<-------------|
5710// | | |
5711// | RESTSubDelResp | |
5712// |<----------------| |
5713//
5714//-----------------------------------------------------------------------------
5715
5716func TestRESTSubReqPolicyChangeNokAndSubDelOk(t *testing.T) {
5717
5718 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5719 Counter{cRestSubReqFromXapp, 2},
5720 Counter{cRestSubRespToXapp, 2},
5721 Counter{cSubReqToE2, 2},
5722 Counter{cSubRespFromE2, 1},
5723 Counter{cSubFailFromE2, 1},
5724 Counter{cRestSubNotifToXapp, 1},
5725 Counter{cRestSubFailNotifToXapp, 1},
5726 Counter{cRestSubDelReqFromXapp, 1},
5727 Counter{cSubDelReqToE2, 1},
5728 Counter{cSubDelRespFromE2, 1},
5729 Counter{cRestSubDelRespToXapp, 1},
5730 })
5731
5732 const subReqCount int = 1
5733 const e2Timeout int64 = 1
5734 const e2RetryCount int64 = 0
5735 const routingNeeded bool = false
5736
5737 // Req
5738 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5739 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5740 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5741 fmt.Printf("restSubId: %v", restSubId)
5742
5743 // Policy change
5744 // GetRESTSubsReqPolicyParams sets some counters on tc side.
5745 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5746 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5747 params.SetSubscriptionID(&restSubId)
5748 params.SetTimeToWait("w200ms")
5749
5750 restSubId = xappConn1.SendRESTSubsReq(t, params)
5751 fmt.Printf("restSubId: %v", restSubId)
5752
5753 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5754 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
5755
5756 // Gnb sends RICSubscriptionFailure
5757 fparams := &teststube2ap.E2StubSubsFailParams{}
5758 fparams.Set(crereq)
5759 fparams.SetCauseVal(0, 1, 5) // CauseRIC / function-resource-limit
5760 e2termConn1.SendSubsFail(t, fparams, cremsg)
5761
5762 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5763 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
5764
5765 // Del
5766 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5767
5768 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5769 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5770
5771 // Wait that subs is cleaned
5772 waitSubsCleanup(t, e2SubsId, 10)
5773 mainCtrl.VerifyCounterValues(t)
5774 mainCtrl.VerifyAllClean(t)
5775}
5776
5777//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005778// TestRESTSubReqPolicyChangeNOk
5779//
5780// stub stub
5781// +-------+ +---------+ +---------+
5782// | xapp | | submgr | | e2term |
5783// +-------+ +---------+ +---------+
5784// | | |
5785// | RESTSubReq | |
5786// |---------------->| |
5787// | | |
5788// | RESTSubResp | |
5789// |<----------------| |
5790// | | SubReq |
5791// | |------------->|
5792// | | |
5793// | | SubResp |
5794// | |<-------------|
5795// | | |
5796// | RESTNotif | |
5797// |<----------------| |
5798// | | |
5799// | RESTSubReq | |
5800// |---------------->| |
5801// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005802// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005803// | | |
5804// | RESTSubDelReq | |
5805// |---------------->| |
5806// | | |
5807// | | SubDelReq |
5808// | |------------->|
5809// | | |
5810// | | SubDelResp |
5811// | |<-------------|
5812// | | |
5813// | RESTSubDelResp | |
5814// |<----------------| |
5815//
5816//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005817
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005818func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005819
5820 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5821 Counter{cRestSubReqFromXapp, 2},
5822 Counter{cRestSubRespToXapp, 1},
5823 Counter{cSubReqToE2, 1},
5824 Counter{cSubRespFromE2, 1},
5825 Counter{cRestSubNotifToXapp, 1},
5826 Counter{cRestSubFailToXapp, 1},
5827 Counter{cRestSubDelReqFromXapp, 1},
5828 Counter{cSubDelReqToE2, 1},
5829 Counter{cSubDelRespFromE2, 1},
5830 Counter{cRestSubDelRespToXapp, 1},
5831 })
5832
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005833 // Req
5834 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5835 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5836
5837 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005838 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5839
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005840 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005841 params.SetSubscriptionID(&restSubIdUpd)
5842 params.SetTimeToWait("w200ms")
5843
5844 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5845 assert.Equal(t, restSubId2, "")
5846
5847 // Del
5848 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5849
5850 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5851 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5852
5853 // Wait that subs is cleaned
5854 waitSubsCleanup(t, e2SubsId, 10)
5855 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005856 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005857}
5858
5859//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005860// TestRESTSubReqAndSubDelOkTwoE2termParallel
5861//
5862// stub stub stub
5863// +-------+ +---------+ +---------+ +---------+
5864// | xapp | | submgr | | e2term1 | | e2term2 |
5865// +-------+ +---------+ +---------+ +---------+
5866// | | | |
5867// | | | |
5868// | | | |
5869// | RESTSubReq1 | | |
5870// |---------------->| | |
5871// | | | |
5872// | RESTSubResp1 | | |
5873// |<----------------| | |
5874// | | SubReq1 | |
5875// | |------------->| |
5876// | | | |
5877// | RESTSubReq2 | | |
5878// |---------------->| | |
5879// | | | |
5880// | RESTSubResp2 | | |
5881// |<----------------| | |
5882// | | SubReq2 | |
5883// | |---------------------------->|
5884// | | | |
5885// | | SubResp1 | |
5886// | |<-------------| |
5887// | RESTNotif1 | | |
5888// |<----------------| | |
5889// | | SubResp2 | |
5890// | |<----------------------------|
5891// | RESTNotif2 | | |
5892// |<----------------| | |
5893// | | | |
5894// | [SUBS 1 DELETE] | |
5895// | | | |
5896// | [SUBS 2 DELETE] | |
5897// | | | |
5898//
5899//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005900
archaggeafbf95f2021-04-14 08:54:05 +03005901func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005902
5903 // Init counter check
5904 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005905 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005906 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005907 Counter{cSubReqToE2, 2},
5908 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005909 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005910 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005911 Counter{cSubDelReqToE2, 2},
5912 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005913 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005914 })
5915
5916 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005917
5918 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005919 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005920 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5921 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5922
5923 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005924 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005925 params.SetMeid("RAN_NAME_11")
5926 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5927 // would not work as notification would not be received
5928 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5929 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5930
5931 // Resp1
5932 xappConn1.ExpectRESTNotification(t, restSubId1)
5933 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5934 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005935 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005936
5937 // Resp2
5938 xappConn2.ExpectRESTNotification(t, restSubId2)
5939 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5940 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005941 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005942
5943 // Delete1
5944 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5945 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5946 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5947
5948 // Wait that subs is cleaned
5949 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5950
5951 // Delete2
5952 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5953 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5954 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5955
5956 // Wait that subs is cleaned
5957 waitSubsCleanup(t, e2SubsId2, 10)
5958
5959 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005960 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005961}
5962
5963//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005964// TestRESTSubReqInsertAndSubDelOk
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// | ... | ... |
5985// | | |
5986// | RESTSubDelReq | |
5987// |---------------->| |
5988// | | |
5989// | | SubDelReq |
5990// | |------------->|
5991// | | |
5992// | | SubDelResp |
5993// | |<-------------|
5994// | | |
5995// | RESTSubDelResp| |
5996// |<----------------| |
5997//
5998//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005999
archaggeafbf95f2021-04-14 08:54:05 +03006000func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006001
6002 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006003 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006004 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006005 Counter{cSubReqToE2, 1},
6006 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006007 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006008 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006009 Counter{cSubDelReqToE2, 1},
6010 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006011 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006012 })
6013
6014 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006015
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006016 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006017 params.SetSubActionTypes("insert")
6018
6019 // Req
6020 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6021
6022 // Del
6023 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6024
6025 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6026 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6027
6028 // Wait that subs is cleaned
6029 waitSubsCleanup(t, e2SubsId, 10)
6030 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006031 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006032}
6033
6034//-----------------------------------------------------------------------------
6035// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
6036//
6037// stub stub
6038// +-------+ +---------+ +---------+
6039// | xapp | | submgr | | e2term |
6040// +-------+ +---------+ +---------+
6041// | | |
6042// | RESTSubReq | |
6043// |------------->| |
6044// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02006045// | RESTSubResp | |
6046// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006047// | | SubReq |
6048// | |------------->|
6049// | | |
6050// | | SubResp |
6051// | <----|
6052// | |
6053// | Submgr restart |
6054// | |
6055// | | |
6056// | | SubDelReq |
6057// | |------------->|
6058// | | |
6059// | | SubDelResp |
6060// | |<-------------|
6061// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02006062// | RESTNotif | |
6063// | unsuccess | |
6064// |<-------------| |
6065// | | |
6066// | RESTSubDelReq| |
6067// |------------->| |
6068// | | |
6069// |RESTSubDelResp| |
6070// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006071//
6072//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02006073
archaggeafbf95f2021-04-14 08:54:05 +03006074func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006075
6076 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006077 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006078 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006079 Counter{cSubReqToE2, 1},
6080 Counter{cSubDelReqFromXapp, 1},
6081 Counter{cSubDelReqToE2, 1},
6082 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006083 Counter{cRestSubDelReqFromXapp, 1},
6084 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006085 })
6086
6087 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006088
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006089 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006090
6091 //Req
6092 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
6093 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006094 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006095
6096 e2termConn1.RecvSubsReq(t)
6097
6098 mainCtrl.SetResetTestFlag(t, false)
6099
6100 mainCtrl.SimulateRestart(t)
6101 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
6102
Anssi Mannilab43397e2021-11-16 12:06:16 +02006103 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03006104 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6105 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6106
Anssi Mannilab43397e2021-11-16 12:06:16 +02006107 //Del
6108 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6109
archaggeafbf95f2021-04-14 08:54:05 +03006110 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03006111 e2termConn1.TestMsgChanEmpty(t)
6112 mainCtrl.wait_registry_empty(t, 10)
6113
6114 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006115 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006116}
6117
6118//-----------------------------------------------------------------------------
6119// TestRESTSubReqAndSubDelOkWithRestartInMiddle
6120//
6121// stub stub
6122// +-------+ +---------+ +---------+
6123// | xapp | | submgr | | e2term |
6124// +-------+ +---------+ +---------+
6125// | | |
6126// | RESTSubReq | |
6127// |---------------->| |
6128// | | |
6129// | RESTSubResp | |
6130// |<----------------| |
6131// | | SubReq |
6132// | |------------->|
6133// | | |
6134// | | SubResp |
6135// | |<-------------|
6136// | | |
6137// | RESTNotif | |
6138// |<----------------| |
6139// | | |
6140// | |
6141// | Submgr restart |
6142// | | |
6143// | RESTSubDelReq | |
6144// |---------------->| |
6145// | | |
6146// | | SubDelReq |
6147// | |------------->|
6148// | | |
6149// | | SubDelResp |
6150// | |<-------------|
6151// | | |
6152// | RESTSubDelResp | |
6153// |<----------------| |
6154//
6155//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006156
archaggeafbf95f2021-04-14 08:54:05 +03006157func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006158
6159 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006160 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006161 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006162 Counter{cSubReqToE2, 1},
6163 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006164 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006165 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006166 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006167 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006168 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006169 })
archaggeafbf95f2021-04-14 08:54:05 +03006170
6171 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02006172 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006173 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006174 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006175
6176 // Check subscription
6177 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6178
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006179 mainCtrl.SimulateRestart(t)
6180 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03006181
Anssi Mannila54838ed2021-11-19 11:25:01 +02006182 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6183 // That needs to be completed before successful subscription query is possible
6184 <-time.After(time.Second * 1)
6185
archaggeafbf95f2021-04-14 08:54:05 +03006186 // Check subscription
6187 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6188
6189 // Delete subscription
6190 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
6191
6192 //Wait that subs is cleaned
6193 waitSubsCleanup(t, e2SubsId, 10)
6194
6195 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006196 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006197}
6198
6199//-----------------------------------------------------------------------------
6200// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
6201//
6202// stub stub
6203// +-------+ +-------+ +---------+ +---------+
6204// | xapp2 | | xapp1 | | submgr | | e2term |
6205// +-------+ +-------+ +---------+ +---------+
6206// | | | |
6207// | | RESTSubReq1 | |
6208// | |---------------->| |
6209// | | | |
6210// | | RESTSubResp1 | |
6211// | |<----------------| |
6212// | | | |
6213// | | | SubReq1 |
6214// | | |------------->|
6215// | | | SubResp1 |
6216// | | |<-------------|
6217// | | RESTNotif1 | |
6218// | |<----------------| |
6219// | | | |
6220// | RESTSubReq2 | |
6221// |------------------------------>| |
6222// | | | |
6223// | RESTSubResp2 | |
6224// |<------------------------------| |
6225// | | | |
6226// | | RESTNotif2 | |
6227// |<------------------------------| |
6228// | | | |
6229// | | Submgr restart |
6230// | | | |
6231// | | RESTSubDelReq1 | |
6232// | |---------------->| |
6233// | | | |
6234// | | RESTSubDelResp1 | |
6235// | |<----------------| |
6236// | | | |
6237// | | Submgr restart |
6238// | | | |
6239// | RESTSubDelReq2 | |
6240// |------------------------------>| |
6241// | | | |
6242// | RESTSubDelResp2 | |
6243// |<------------------------------| |
6244// | | | |
6245// | | | SubDelReq2 |
6246// | | |------------->|
6247// | | | |
6248// | | | SubDelResp2 |
6249// | | |<-------------|
6250// | | | |
6251//
6252//-----------------------------------------------------------------------------
6253func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006254
6255 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006256 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006257 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006258 Counter{cSubReqToE2, 1},
6259 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006260 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006261 Counter{cMergedSubscriptions, 1},
6262 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006263 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006264 Counter{cSubDelReqToE2, 1},
6265 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006266 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006267 })
6268
archaggeafbf95f2021-04-14 08:54:05 +03006269 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02006270 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006271 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006272 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03006273
6274 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006275 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006276 params.SetMeid("RAN_NAME_1")
6277 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006278 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03006279 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006280 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006281 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006282 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03006283
6284 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
6285
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006286 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006287 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
6288
6289 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6290 // That needs to be completed before successful subscription delete is possible
6291 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03006292
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006293 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03006294 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02006295 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006296 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02006297
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006298 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006299 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
6300
6301 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6302 // That needs to be completed before successful subscription query is possible
6303 <-time.After(time.Second * 1)
6304
archaggeafbf95f2021-04-14 08:54:05 +03006305 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
6306
6307 // Delete subscription 2
6308 deleteXapp2Subscription(t, &restSubId2)
6309
6310 //Wait that subs is cleaned
6311 waitSubsCleanup(t, e2SubsId2, 10)
6312
6313 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006314 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006315}
6316
6317//-----------------------------------------------------------------------------
6318// TestRESTReportSubReqAndSubDelOk
6319//
6320// stub stub
6321// +-------+ +---------+ +---------+
6322// | xapp | | submgr | | e2term |
6323// +-------+ +---------+ +---------+
6324// | | |
6325// | RestSubReq | |
6326// |---------------->| |
6327// | | |
6328// | RESTSubResp | |
6329// |<----------------| |
6330// | | |
6331// | | SubReq |
6332// | |------------->|
6333// | | |
6334// | | SubResp |
6335// | |<-------------|
6336// | RESTNotif | |
6337// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02006338// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03006339// | |------------->|
6340// | | |
6341// | | SubResp |
6342// | |<-------------|
6343// | RESTNotif | |
6344// |<----------------| |
6345// | ... | ... |
6346// | | |
6347// | | |
6348// | RESTSubDelReq | |
6349// |---------------->| |
6350// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006351// | RESTSubDelResp| |
6352// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006353// | | SubDelReq |
6354// | |------------->|
6355// | | |
6356// | | SubDelResp |
6357// | |<-------------|
6358// | | |
archaggeafbf95f2021-04-14 08:54:05 +03006359//
6360//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006361
archaggeafbf95f2021-04-14 08:54:05 +03006362func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006363 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006364 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006365 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006366}
6367
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006368func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006369 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006370
Anssi Mannila21782182021-12-10 10:56:02 +02006371 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6372 Counter{cRestSubReqFromXapp, 1},
6373 Counter{cRestSubRespToXapp, 1},
6374 Counter{cSubReqToE2, uint64(subReqCount)},
6375 Counter{cSubRespFromE2, uint64(subReqCount)},
6376 Counter{cRestSubNotifToXapp, 1},
6377 Counter{cRestSubDelReqFromXapp, 1},
6378 Counter{cRestSubDelRespToXapp, 1},
6379 Counter{cSubDelReqToE2, uint64(subReqCount)},
6380 Counter{cSubDelRespFromE2, uint64(subReqCount)},
6381 })
6382
archaggeafbf95f2021-04-14 08:54:05 +03006383 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006384 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006385 restSubId := xappConn1.SendRESTSubsReq(t, params)
6386
6387 var e2SubsId []uint32
6388 for i := 0; i < subReqCount; i++ {
6389 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6390 xappConn1.ExpectRESTNotification(t, restSubId)
6391
6392 e2termConn1.SendSubsResp(t, crereq, cremsg)
6393 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006394 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03006395 e2SubsId = append(e2SubsId, instanceId)
6396 resp, _ := xapp.Subscription.QuerySubscriptions()
6397 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
6398 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
6399 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
6400
6401 }
6402
6403 // Del
6404 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6405
6406 for i := 0; i < subReqCount; i++ {
6407 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6408 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6409 }
6410
6411 // Wait that subs is cleaned
6412 for i := 0; i < subReqCount; i++ {
6413 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6414 }
6415
6416 xappConn1.TestMsgChanEmpty(t)
6417 e2termConn1.TestMsgChanEmpty(t)
6418 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006419 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006420 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006421}
6422
Anssi Mannila27385172021-12-22 09:41:54 +02006423//-----------------------------------------------------------------------------
6424// TestRESTTwoPolicySubReqAndSubDelOk
6425//
6426// stub stub
6427// +-------+ +---------+ +---------+
6428// | xapp | | submgr | | e2term |
6429// +-------+ +---------+ +---------+
6430// | | |
6431// | RestSubReq | |
6432// |---------------->| |
6433// | | |
6434// | RESTSubResp | |
6435// |<----------------| |
6436// | | |
6437// | | SubReq |
6438// | |------------->|
6439// | | |
6440// | | SubResp |
6441// | |<-------------|
6442// | RESTNotif | |
6443// |<----------------| |
6444// | | SubReq |
6445// | |------------->|
6446// | | |
6447// | | SubResp |
6448// | |<-------------|
6449// | RESTNotif | |
6450// |<----------------| |
6451// | | |
6452// | RESTSubDelReq | |
6453// |---------------->| |
6454// | | |
6455// | RESTSubDelResp| |
6456// |<----------------| |
6457// | | SubDelReq |
6458// | |------------->|
6459// | | |
6460// | | SubDelResp |
6461// | |<-------------|
6462// | | |
6463// | | SubDelReq |
6464// | |------------->|
6465// | | |
6466// | | SubDelResp |
6467// | |<-------------|
6468// | | |
6469//
6470//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006471
archaggeafbf95f2021-04-14 08:54:05 +03006472func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6473
archaggeafbf95f2021-04-14 08:54:05 +03006474 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006475 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006476 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006477 Counter{cSubReqToE2, 2},
6478 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006479 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006480 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006481 Counter{cSubDelReqToE2, 2},
6482 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006483 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006484 })
6485
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006486 const subReqCount int = 2
6487
archaggeafbf95f2021-04-14 08:54:05 +03006488 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006489 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006490 restSubId := xappConn1.SendRESTSubsReq(t, params)
6491 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6492
6493 assert.Equal(t, len(e2SubsIds), 2)
6494
6495 // Del
6496 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6497 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6498
6499 xappConn1.TestMsgChanEmpty(t)
6500 e2termConn1.TestMsgChanEmpty(t)
6501 mainCtrl.wait_registry_empty(t, 10)
6502
6503 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006504 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006505}
Anssi Mannila27385172021-12-22 09:41:54 +02006506
6507//-----------------------------------------------------------------------------
6508// TestRESTPolicySubReqAndSubDelOk19E2Subs
6509//
6510// stub stub
6511// +-------+ +---------+ +---------+
6512// | xapp | | submgr | | e2term |
6513// +-------+ +---------+ +---------+
6514// | | |
6515// | RestSubReq | |
6516// |---------------->| |
6517// | | |
6518// | RESTSubResp | |
6519// |<----------------| |
6520// | | | ------
6521// | | SubReq |
6522// | |------------->|
6523// | | | E2 subscription x 19
6524// | | SubResp |
6525// | |<-------------|
6526// | RESTNotif | |
6527// |<----------------| |
6528// | | | ------
6529// | RESTSubDelReq | |
6530// |---------------->| |
6531// | | |
6532// | RESTSubDelResp| |
6533// |<----------------| |
6534// | | SubDelReq | ------
6535// | |------------->|
6536// | | | E2 subscription delete x 19
6537// | | SubDelResp |
6538// | |<-------------|
6539// | | | ------
6540// | | |
6541//
6542//-----------------------------------------------------------------------------
6543
6544func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006545
archaggeafbf95f2021-04-14 08:54:05 +03006546 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006547 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006548 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006549 Counter{cSubReqToE2, 19},
6550 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006551 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006552 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006553 Counter{cSubDelReqToE2, 19},
6554 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006555 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006556 })
6557
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006558 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006559 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006560 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006561 restSubId := xappConn1.SendRESTSubsReq(t, params)
6562 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6563
6564 assert.Equal(t, len(e2SubsIds), 19)
6565
6566 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6567 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6568
6569 xappConn1.TestMsgChanEmpty(t)
6570 e2termConn1.TestMsgChanEmpty(t)
6571 mainCtrl.wait_registry_empty(t, 10)
6572
6573 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006574 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006575}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006576
Anssi Mannila27385172021-12-22 09:41:54 +02006577//-----------------------------------------------------------------------------
6578// TestRESTTwoPolicySubReqAndSubDelOk
6579//
6580// stub stub
6581// +-------+ +---------+ +---------+
6582// | xapp | | submgr | | e2term |
6583// +-------+ +---------+ +---------+
6584// | | |
6585// | RestSubReq | |
6586// |---------------->| |
6587// | | |
6588// | RESTSubResp | |
6589// |<----------------| |
6590// | | |
6591// | | SubReq |
6592// | |------------->|
6593// | | |
6594// | | SubResp |
6595// | |<-------------|
6596// | RESTNotif | |
6597// |<----------------| |
6598// | | SubReq |
6599// | |------------->|
6600// | | |
6601// | | SubResp |
6602// | |<-------------|
6603// | RESTNotif | |
6604// |<----------------| |
6605// | | |
6606// | RESTSubDelReq | |
6607// |---------------->| |
6608// | | |
6609// | RESTSubDelResp| |
6610// |<----------------| |
6611// | | SubDelReq |
6612// | |------------->|
6613// | | |
6614// | | SubDelResp |
6615// | |<-------------|
6616// | | |
6617// | | SubDelReq |
6618// | |------------->|
6619// | | |
6620// | | SubDelResp |
6621// | |<-------------|
6622// | | |
6623//
6624//-----------------------------------------------------------------------------
6625
archaggeafbf95f2021-04-14 08:54:05 +03006626func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6627
6628 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006629
6630 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006631 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006632 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006633 Counter{cSubReqToE2, uint64(subReqCount)},
6634 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006635 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006636 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006637 Counter{cSubDelReqToE2, uint64(subReqCount)},
6638 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006639 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006640 })
6641
6642 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006643 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006644 restSubId := xappConn1.SendRESTSubsReq(t, params)
6645 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6646
6647 assert.Equal(t, len(e2SubsIds), subReqCount)
6648
6649 // Del
6650 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6651 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6652
6653 xappConn1.TestMsgChanEmpty(t)
6654 e2termConn1.TestMsgChanEmpty(t)
6655 mainCtrl.wait_registry_empty(t, 10)
6656
6657 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006658 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006659}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006660
Anssi Mannila27385172021-12-22 09:41:54 +02006661//-----------------------------------------------------------------------------
6662// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6663//
6664// stub stub
6665// +-------+ +---------+ +---------+
6666// | xapp | | submgr | | e2term |
6667// +-------+ +---------+ +---------+
6668// | | |
6669// | RestSubReq | |
6670// |---------------->| |
6671// | | |
6672// | RESTSubResp | |
6673// |<----------------| |
6674// | | |
6675// | | SubReq |
6676// | |------------->|
6677// | | |
6678// | | SubResp |
6679// | |<-------------|
6680// | RESTNotif | |
6681// |<----------------| |
6682// | | SubReq |
6683// | |------------->|
6684// | | |
6685// | | SubResp |
6686// | |<-------------|
6687// | RESTNotif | |
6688// |<----------------| |
6689// | | |
6690// | RESTSubDelReq | |
6691// |---------------->| |
6692// | | |
6693// | RESTSubDelResp| |
6694// |<----------------| |
6695// | | SubDelReq |
6696// | |------------->|
6697// | | |
6698// | | SubDelResp |
6699// | |<-------------|
6700// | | |
6701// | | SubDelReq |
6702// | |------------->|
6703// | | |
6704// | | SubDelResp |
6705// | |<-------------|
6706// | | |
6707//
6708//-----------------------------------------------------------------------------
6709
archaggeafbf95f2021-04-14 08:54:05 +03006710func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6711
6712 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006713
6714 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006715 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006716 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006717 Counter{cSubReqToE2, uint64(subReqCount)},
6718 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006719 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006720 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006721 Counter{cSubDelReqToE2, uint64(subReqCount)},
6722 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006723 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006724 })
6725
6726 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006727 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006728 restSubId := xappConn1.SendRESTSubsReq(t, params)
6729 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6730
6731 assert.Equal(t, len(e2SubsIds), subReqCount)
6732
6733 // Del
6734 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6735 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6736
6737 xappConn1.TestMsgChanEmpty(t)
6738 e2termConn1.TestMsgChanEmpty(t)
6739 mainCtrl.wait_registry_empty(t, 10)
6740
6741 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006742 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006743}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006744
Anssi Mannila27385172021-12-22 09:41:54 +02006745//-----------------------------------------------------------------------------
6746// TestRESTReportSubReqAndSubDelOk19E2Subs
6747//
6748// stub stub
6749// +-------+ +---------+ +---------+
6750// | xapp | | submgr | | e2term |
6751// +-------+ +---------+ +---------+
6752// | | |
6753// | RestSubReq | |
6754// |---------------->| |
6755// | | |
6756// | RESTSubResp | |
6757// |<----------------| |
6758// | | | ------
6759// | | SubReq |
6760// | |------------->|
6761// | | | E2 subscription x 19
6762// | | SubResp |
6763// | |<-------------|
6764// | RESTNotif | |
6765// |<----------------| |
6766// | | | ------
6767// | RESTSubDelReq | |
6768// |---------------->| |
6769// | | |
6770// | RESTSubDelResp| |
6771// |<----------------| |
6772// | | SubDelReq | ------
6773// | |------------->|
6774// | | | E2 subscription delete x 19
6775// | | SubDelResp |
6776// | |<-------------|
6777// | | | ------
6778// | | |
6779//
6780//-----------------------------------------------------------------------------
6781
6782func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006783
6784 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006785
6786 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006787 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006788 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006789 Counter{cSubReqToE2, uint64(subReqCount)},
6790 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006791 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006792 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006793 Counter{cSubDelReqToE2, uint64(subReqCount)},
6794 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006795 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006796 })
6797
6798 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006799 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006800 restSubId := xappConn1.SendRESTSubsReq(t, params)
6801 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6802
6803 assert.Equal(t, len(e2SubsIds), subReqCount)
6804
6805 // Del
6806 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6807 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6808
6809 xappConn1.TestMsgChanEmpty(t)
6810 e2termConn1.TestMsgChanEmpty(t)
6811 mainCtrl.wait_registry_empty(t, 10)
6812
6813 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006814 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006815}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006816
Anssi Mannila27385172021-12-22 09:41:54 +02006817//-----------------------------------------------------------------------------
6818// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6819//
6820// stub stub stub
6821// +-------+ +-------+ +---------+ +---------+
6822// | xapp2 | | xapp1 | | submgr | | e2term |
6823// +-------+ +-------+ +---------+ +---------+
6824// | | | |
6825// | | RESTSubReq1 | |
6826// | |------------->| |
6827// | | RESTSubResp1 | |
6828// | |<-------------| |
6829// | | | |
6830// | | | SubReq1 |
6831// | | |------------->|
6832// | | | |
6833// | RESTSubReq2 | |
6834// |------------------------>| |
6835// | RESTSubResp2 | |
6836// |<------------------------| |
6837// | | | |
6838// | | | SubReq2 |
6839// | | |------------->|
6840// | | | |
6841// | | | SubResp1 |
6842// | | |<-------------|
6843// | | RESTNotif1 | |
6844// | |<-------------| |
6845// | | | |
6846// | | | SubResp2 |
6847// | | |<-------------|
6848// | RESTNotif2 | |
6849// |<------------------------| |
6850// | | | |
6851// | | [SUBS 1 DELETE] |
6852// | | | |
6853// | | [SUBS 2 DELETE] |
6854// | | | |
6855//
6856//-----------------------------------------------------------------------------
6857
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006858func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006859
6860 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006861 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006862 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006863 Counter{cSubReqToE2, 2},
6864 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006865 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006866 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006867 Counter{cSubDelReqToE2, 2},
6868 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006869 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006870 })
6871
6872 // Req1
6873 var params *teststube2ap.RESTSubsReqParams = nil
6874
6875 //Subs Create
6876 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006877 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006878
6879 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6880
6881 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006882 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006883 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006884 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006885 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6886
6887 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006888 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006889 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6890 xappConn2.ExpectRESTNotification(t, restSubId2)
6891 e2termConn1.SendSubsResp(t, crereq, cremsg)
6892 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6893
6894 deleteXapp1Subscription(t, &restSubId1)
6895 deleteXapp2Subscription(t, &restSubId2)
6896
6897 waitSubsCleanup(t, e2SubsId1, 10)
6898 waitSubsCleanup(t, e2SubsId2, 10)
6899
6900 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006901 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006902}
6903
Anssi Mannila27385172021-12-22 09:41:54 +02006904//-----------------------------------------------------------------------------
6905// TestRESTSubReqReportSameActionDiffActionListLen
6906//
6907// stub stub stub
6908// +-------+ +-------+ +---------+ +---------+
6909// | xapp2 | | xapp1 | | submgr | | e2term |
6910// +-------+ +-------+ +---------+ +---------+
6911// | | | |
6912// | | RESTSubReq1 | |
6913// | |------------->| |
6914// | | RESTSubResp1 | |
6915// | |<-------------| |
6916// | | | |
6917// | | | SubReq1 |
6918// | | |------------->|
6919// | | | |
6920// | RESTSubReq2 | |
6921// |------------------------>| |
6922// | RESTSubResp2 | |
6923// |<------------------------| |
6924// | | | |
6925// | | | SubReq2 |
6926// | | |------------->|
6927// | | | |
6928// | | | SubResp1 |
6929// | | |<-------------|
6930// | | RESTNotif1 | |
6931// | |<-------------| |
6932// | | | |
6933// | | | SubResp2 |
6934// | | |<-------------|
6935// | RESTNotif2 | |
6936// |<------------------------| |
6937// | | | |
6938// | | [SUBS 1 DELETE] |
6939// | | | |
6940// | | [SUBS 2 DELETE] |
6941// | | | |
6942//
6943//-----------------------------------------------------------------------------
6944
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006945func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006946
6947 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006948 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006949 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006950 Counter{cSubReqToE2, 2},
6951 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006952 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006953 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006954 Counter{cSubDelReqToE2, 2},
6955 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006956 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006957 })
6958
6959 // Req1
6960 var params *teststube2ap.RESTSubsReqParams = nil
6961
6962 //Subs Create
6963 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006964 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006965
6966 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6967
6968 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006969 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006970 params.SetMeid("RAN_NAME_1")
6971
6972 actionId := int64(1)
6973 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006974 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006975 subsequestActionType := "continue"
6976 timeToWait := "w10ms"
6977 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6978
6979 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006980 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006981 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6982 xappConn2.ExpectRESTNotification(t, restSubId2)
6983 e2termConn1.SendSubsResp(t, crereq, cremsg)
6984 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6985
6986 deleteXapp1Subscription(t, &restSubId1)
6987 deleteXapp2Subscription(t, &restSubId2)
6988
6989 waitSubsCleanup(t, e2SubsId1, 10)
6990 waitSubsCleanup(t, e2SubsId2, 10)
6991
6992 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006993 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006994}
6995
Anssi Mannila27385172021-12-22 09:41:54 +02006996//-----------------------------------------------------------------------------
6997// TestRESTSubReqReportSameActionDiffActionID
6998//
6999// stub stub stub
7000// +-------+ +-------+ +---------+ +---------+
7001// | xapp2 | | xapp1 | | submgr | | e2term |
7002// +-------+ +-------+ +---------+ +---------+
7003// | | | |
7004// | | RESTSubReq1 | |
7005// | |------------->| |
7006// | | RESTSubResp1 | |
7007// | |<-------------| |
7008// | | | |
7009// | | | SubReq1 |
7010// | | |------------->|
7011// | | | |
7012// | RESTSubReq2 | |
7013// |------------------------>| |
7014// | RESTSubResp2 | |
7015// |<------------------------| |
7016// | | | |
7017// | | | SubReq2 |
7018// | | |------------->|
7019// | | | |
7020// | | | SubResp1 |
7021// | | |<-------------|
7022// | | RESTNotif1 | |
7023// | |<-------------| |
7024// | | | |
7025// | | | SubResp2 |
7026// | | |<-------------|
7027// | RESTNotif2 | |
7028// |<------------------------| |
7029// | | | |
7030// | | [SUBS 1 DELETE] |
7031// | | | |
7032// | | [SUBS 2 DELETE] |
7033// | | | |
7034//
7035//-----------------------------------------------------------------------------
7036
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007037func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007038
7039 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007040 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007041 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007042 Counter{cSubReqToE2, 2},
7043 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007044 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007045 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007046 Counter{cSubDelReqToE2, 2},
7047 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007048 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007049 })
7050
7051 // Req1
7052 var params *teststube2ap.RESTSubsReqParams = nil
7053
7054 //Subs Create
7055 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007056 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007057
7058 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7059
7060 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007061 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007062 params.SetMeid("RAN_NAME_1")
7063 params.SetSubActionIDs(int64(2))
7064
7065 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007066 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007067 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7068 xappConn2.ExpectRESTNotification(t, restSubId2)
7069 e2termConn1.SendSubsResp(t, crereq, cremsg)
7070 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7071
7072 deleteXapp1Subscription(t, &restSubId1)
7073 deleteXapp2Subscription(t, &restSubId2)
7074
7075 waitSubsCleanup(t, e2SubsId1, 10)
7076 waitSubsCleanup(t, e2SubsId2, 10)
7077
7078 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007079 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007080}
7081
Anssi Mannila27385172021-12-22 09:41:54 +02007082//-----------------------------------------------------------------------------
7083// TestRESTSubReqDiffActionType
7084//
7085// stub stub stub
7086// +-------+ +-------+ +---------+ +---------+
7087// | xapp2 | | xapp1 | | submgr | | e2term |
7088// +-------+ +-------+ +---------+ +---------+
7089// | | | |
7090// | | RESTSubReq1 | |
7091// | |------------->| |
7092// | | RESTSubResp1 | |
7093// | |<-------------| |
7094// | | | |
7095// | | | SubReq1 |
7096// | | |------------->|
7097// | | | |
7098// | RESTSubReq2 | |
7099// |------------------------>| |
7100// | RESTSubResp2 | |
7101// |<------------------------| |
7102// | | | |
7103// | | | SubReq2 |
7104// | | |------------->|
7105// | | | |
7106// | | | SubResp1 |
7107// | | |<-------------|
7108// | | RESTNotif1 | |
7109// | |<-------------| |
7110// | | | |
7111// | | | SubResp2 |
7112// | | |<-------------|
7113// | RESTNotif2 | |
7114// |<------------------------| |
7115// | | | |
7116// | | [SUBS 1 DELETE] |
7117// | | | |
7118// | | [SUBS 2 DELETE] |
7119// | | | |
7120//
7121//-----------------------------------------------------------------------------
7122
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007123func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007124
7125 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007126 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007127 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007128 Counter{cSubReqToE2, 2},
7129 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007130 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007131 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007132 Counter{cSubDelReqToE2, 2},
7133 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007134 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007135 })
7136
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007137 const e2Timeout int64 = 2
7138 const e2RetryCount int64 = 2
7139 const routingNeeded bool = true
7140
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007141 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007142 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007143 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007144
7145 //Subs Create
7146 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007147 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007148
7149 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7150
7151 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007152 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007153 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007154 params.SetMeid("RAN_NAME_1")
7155
7156 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007157 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007158 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7159 xappConn2.ExpectRESTNotification(t, restSubId2)
7160 e2termConn1.SendSubsResp(t, crereq, cremsg)
7161 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7162
7163 deleteXapp1Subscription(t, &restSubId1)
7164 deleteXapp2Subscription(t, &restSubId2)
7165
7166 waitSubsCleanup(t, e2SubsId1, 10)
7167 waitSubsCleanup(t, e2SubsId2, 10)
7168
7169 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007170 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007171}
7172
Anssi Mannila27385172021-12-22 09:41:54 +02007173//-----------------------------------------------------------------------------
7174// TestRESTSubReqPolicyAndSubDelOkSameAction
7175//
7176// stub stub stub
7177// +-------+ +-------+ +---------+ +---------+
7178// | xapp2 | | xapp1 | | submgr | | e2term |
7179// +-------+ +-------+ +---------+ +---------+
7180// | | | |
7181// | | RESTSubReq1 | |
7182// | |------------->| |
7183// | | RESTSubResp1 | |
7184// | |<-------------| |
7185// | | | |
7186// | | | SubReq1 |
7187// | | |------------->|
7188// | | | |
7189// | RESTSubReq2 | |
7190// |------------------------>| |
7191// | RESTSubResp2 | |
7192// |<------------------------| |
7193// | | | |
7194// | | | SubReq2 |
7195// | | |------------->|
7196// | | | |
7197// | | | SubResp1 |
7198// | | |<-------------|
7199// | | RESTNotif1 | |
7200// | |<-------------| |
7201// | | | |
7202// | | | SubResp2 |
7203// | | |<-------------|
7204// | RESTNotif2 | |
7205// |<------------------------| |
7206// | | | |
7207// | | [SUBS 1 DELETE] |
7208// | | | |
7209// | | [SUBS 2 DELETE] |
7210// | | | |
7211//
7212//-----------------------------------------------------------------------------
7213
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007214func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007215
7216 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007217 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007218 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007219 Counter{cSubReqToE2, 2},
7220 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007221 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007222 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007223 Counter{cSubDelReqToE2, 2},
7224 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007225 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007226 })
7227
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007228 const e2Timeout int64 = 2
7229 const e2RetryCount int64 = 2
7230 const routingNeeded bool = true
7231
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007232 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007233 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007234 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007235
7236 //Subs Create
7237 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007238 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007239
7240 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7241
7242 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007243 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007244 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007245 params.SetMeid("RAN_NAME_1")
7246
7247 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007248 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007249 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7250 xappConn2.ExpectRESTNotification(t, restSubId2)
7251 e2termConn1.SendSubsResp(t, crereq, cremsg)
7252 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7253
7254 deleteXapp1Subscription(t, &restSubId1)
7255 deleteXapp2Subscription(t, &restSubId2)
7256
7257 waitSubsCleanup(t, e2SubsId1, 10)
7258 waitSubsCleanup(t, e2SubsId2, 10)
7259
7260 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007261 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007262}
7263
Anssi Mannila27385172021-12-22 09:41:54 +02007264//-----------------------------------------------------------------------------
7265// TestRESTSubReqReportSameActionDiffActionDefinitionLen
7266//
7267// stub stub stub
7268// +-------+ +-------+ +---------+ +---------+
7269// | xapp2 | | xapp1 | | submgr | | e2term |
7270// +-------+ +-------+ +---------+ +---------+
7271// | | | |
7272// | | RESTSubReq1 | |
7273// | |------------->| |
7274// | | RESTSubResp1 | |
7275// | |<-------------| |
7276// | | | |
7277// | | | SubReq1 |
7278// | | |------------->|
7279// | | | |
7280// | RESTSubReq2 | |
7281// |------------------------>| |
7282// | RESTSubResp2 | |
7283// |<------------------------| |
7284// | | | |
7285// | | | SubReq2 |
7286// | | |------------->|
7287// | | | |
7288// | | | SubResp1 |
7289// | | |<-------------|
7290// | | RESTNotif1 | |
7291// | |<-------------| |
7292// | | | |
7293// | | | SubResp2 |
7294// | | |<-------------|
7295// | RESTNotif2 | |
7296// |<------------------------| |
7297// | | | |
7298// | | [SUBS 1 DELETE] |
7299// | | | |
7300// | | [SUBS 2 DELETE] |
7301// | | | |
7302//
7303//-----------------------------------------------------------------------------
7304
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007305func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007306
7307 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007308 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007309 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007310 Counter{cSubReqToE2, 2},
7311 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007312 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007313 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007314 Counter{cSubDelReqToE2, 2},
7315 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007316 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007317 })
7318
7319 // Req1
7320 var params *teststube2ap.RESTSubsReqParams = nil
7321
7322 //Subs Create
7323 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007324 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007325
7326 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7327
7328 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007329 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007330 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007331 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007332 params.SetSubActionDefinition(actionDefinition)
7333
7334 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007335 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007336 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7337 xappConn2.ExpectRESTNotification(t, restSubId2)
7338 e2termConn1.SendSubsResp(t, crereq, cremsg)
7339 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7340
7341 deleteXapp1Subscription(t, &restSubId1)
7342 deleteXapp2Subscription(t, &restSubId2)
7343
7344 waitSubsCleanup(t, e2SubsId1, 10)
7345 waitSubsCleanup(t, e2SubsId2, 10)
7346
7347 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007348 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007349}
7350
Anssi Mannila27385172021-12-22 09:41:54 +02007351//-----------------------------------------------------------------------------
7352// TestRESTSubReqReportSameActionDiffActionDefinitionContents
7353//
7354// stub stub stub
7355// +-------+ +-------+ +---------+ +---------+
7356// | xapp2 | | xapp1 | | submgr | | e2term |
7357// +-------+ +-------+ +---------+ +---------+
7358// | | | |
7359// | | RESTSubReq1 | |
7360// | |------------->| |
7361// | | RESTSubResp1 | |
7362// | |<-------------| |
7363// | | | |
7364// | | | SubReq1 |
7365// | | |------------->|
7366// | | | |
7367// | RESTSubReq2 | |
7368// |------------------------>| |
7369// | RESTSubResp2 | |
7370// |<------------------------| |
7371// | | | |
7372// | | | SubReq2 |
7373// | | |------------->|
7374// | | | |
7375// | | | SubResp1 |
7376// | | |<-------------|
7377// | | RESTNotif1 | |
7378// | |<-------------| |
7379// | | | |
7380// | | | SubResp2 |
7381// | | |<-------------|
7382// | RESTNotif2 | |
7383// |<------------------------| |
7384// | | | |
7385// | | [SUBS 1 DELETE] |
7386// | | | |
7387// | | [SUBS 2 DELETE] |
7388// | | | |
7389//
7390//-----------------------------------------------------------------------------
7391
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007392func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007393
7394 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007395 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007396 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007397 Counter{cSubReqToE2, 2},
7398 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007399 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007400 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007401 Counter{cSubDelReqToE2, 2},
7402 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007403 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007404 })
7405
7406 // Req1
7407 var params *teststube2ap.RESTSubsReqParams = nil
7408
7409 //Subs Create
7410 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007411 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007412
7413 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7414
7415 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007416 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007417 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007418 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007419 params.SetSubActionDefinition(actionDefinition)
7420
7421 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007422 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007423 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7424 xappConn2.ExpectRESTNotification(t, restSubId2)
7425 e2termConn1.SendSubsResp(t, crereq, cremsg)
7426 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7427
7428 deleteXapp1Subscription(t, &restSubId1)
7429 deleteXapp2Subscription(t, &restSubId2)
7430
7431 waitSubsCleanup(t, e2SubsId1, 10)
7432 waitSubsCleanup(t, e2SubsId2, 10)
7433
7434 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007435 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007436}
7437
Anssi Mannila27385172021-12-22 09:41:54 +02007438//-----------------------------------------------------------------------------
7439// TestRESTSubReqReportSameActionDiffSubsAction
7440//
7441// stub stub stub
7442// +-------+ +-------+ +---------+ +---------+
7443// | xapp2 | | xapp1 | | submgr | | e2term |
7444// +-------+ +-------+ +---------+ +---------+
7445// | | | |
7446// | | RESTSubReq1 | |
7447// | |------------->| |
7448// | | RESTSubResp1 | |
7449// | |<-------------| |
7450// | | | |
7451// | | | SubReq1 |
7452// | | |------------->|
7453// | | | |
7454// | RESTSubReq2 | |
7455// |------------------------>| |
7456// | RESTSubResp2 | |
7457// |<------------------------| |
7458// | | | |
7459// | | | SubReq2 |
7460// | | |------------->|
7461// | | | |
7462// | | | SubResp1 |
7463// | | |<-------------|
7464// | | RESTNotif1 | |
7465// | |<-------------| |
7466// | | | |
7467// | | | SubResp2 |
7468// | | |<-------------|
7469// | RESTNotif2 | |
7470// |<------------------------| |
7471// | | | |
7472// | | [SUBS 1 DELETE] |
7473// | | | |
7474// | | [SUBS 2 DELETE] |
7475// | | | |
7476//
7477//-----------------------------------------------------------------------------
7478
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007479func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007480
7481 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007482 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007483 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007484 Counter{cSubReqToE2, 2},
7485 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007486 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007487 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007488 Counter{cSubDelReqToE2, 2},
7489 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007490 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007491 })
7492
7493 // Req1
7494 var params *teststube2ap.RESTSubsReqParams = nil
7495
7496 //Subs Create
7497 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007498 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007499
7500 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7501
7502 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007503 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007504 params.SetMeid("RAN_NAME_1")
7505 params.SetTimeToWait("w200ms")
7506 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007507 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007508 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7509 xappConn2.ExpectRESTNotification(t, restSubId2)
7510 e2termConn1.SendSubsResp(t, crereq, cremsg)
7511 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7512
7513 deleteXapp1Subscription(t, &restSubId1)
7514 deleteXapp2Subscription(t, &restSubId2)
7515
7516 waitSubsCleanup(t, e2SubsId1, 10)
7517 waitSubsCleanup(t, e2SubsId2, 10)
7518
7519 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007520 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007521}
7522
Anssi Mannila51122392021-05-25 11:51:31 +03007523//-----------------------------------------------------------------------------
7524// TestRESTUnpackSubscriptionResponseDecodeFail
7525//
7526// stub stub
7527// +-------+ +---------+ +---------+
7528// | xapp | | submgr | | e2term |
7529// +-------+ +---------+ +---------+
7530// | | |
7531// | RestSubReq | |
7532// |---------------->| |
7533// | | |
7534// | RESTSubResp | |
7535// |<----------------| |
7536// | | |
7537// | | SubReq |
7538// | |------------->|
7539// | | |
7540// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007541// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007542// | | |
7543// | | SubReq |
7544// | |------------->|
7545// | | |
7546// | | SubFail | Duplicated action
7547// | |<-------------|
7548// | RESTNotif (fail)| |
7549// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007550// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007551// | [SUBS DELETE] |
7552// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007553//
7554//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007555
Anssi Mannila51122392021-05-25 11:51:31 +03007556func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007557
7558 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7559 Counter{cRestSubReqFromXapp, 1},
7560 Counter{cRestSubRespToXapp, 1},
7561 Counter{cSubReqToE2, 1},
7562 Counter{cSubReqTimerExpiry, 1},
7563 Counter{cSubReReqToE2, 1},
7564 Counter{cSubRespFromE2, 1},
7565 Counter{cSubFailFromE2, 1},
7566 Counter{cRestSubFailNotifToXapp, 1},
7567 Counter{cRestSubDelReqFromXapp, 1},
7568 Counter{cRestSubDelRespToXapp, 1},
7569 })
7570
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007571 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007572
7573 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007574 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007575 restSubId := xappConn1.SendRESTSubsReq(t, params)
7576
7577 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7578 // Decode of this response fails which will result resending original request
7579 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7580
7581 _, cremsg = e2termConn1.RecvSubsReq(t)
7582
Markku Virtanen55d2a282021-06-04 14:46:56 +03007583 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007584
7585 // Subscription already created in E2 Node.
7586 fparams := &teststube2ap.E2StubSubsFailParams{}
7587 fparams.Set(crereq)
7588 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7589 e2termConn1.SendSubsFail(t, fparams, cremsg)
7590
Anssi Mannila51122392021-05-25 11:51:31 +03007591 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007592 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007593
Anssi Mannilab43397e2021-11-16 12:06:16 +02007594 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7595
Anssi Mannila51122392021-05-25 11:51:31 +03007596 // Wait that subs is cleaned
7597 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7598
7599 xappConn1.TestMsgChanEmpty(t)
7600 e2termConn1.TestMsgChanEmpty(t)
7601 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007602 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007603 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007604}
7605
7606//-----------------------------------------------------------------------------
7607// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7608//
7609// stub stub
7610// +-------+ +---------+ +---------+
7611// | xapp | | submgr | | e2term |
7612// +-------+ +---------+ +---------+
7613// | | |
7614// | RestSubReq | |
7615// |---------------->| |
7616// | | |
7617// | RESTSubResp | |
7618// |<----------------| |
7619// | | |
7620// | | SubReq |
7621// | |------------->|
7622// | | |
7623// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007624// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007625// | | |
7626// | | SubReq |
7627// | |------------->|
7628// | | |
7629// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007630// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007631// | RESTNotif (fail)| |
7632// |<----------------| |
7633// | | SubDelReq |
7634// | |------------->|
7635// | | |
7636// | | SubDelResp |
7637// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007638// | | |
7639// | [SUBS DELETE] |
7640// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007641//
7642//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007643
Anssi Mannila51122392021-05-25 11:51:31 +03007644func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007645
7646 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7647 Counter{cRestSubReqFromXapp, 1},
7648 Counter{cRestSubRespToXapp, 1},
7649 Counter{cSubReqToE2, 1},
7650 Counter{cSubReqTimerExpiry, 2},
7651 Counter{cSubReReqToE2, 1},
7652 Counter{cSubRespFromE2, 1},
7653 Counter{cSubFailFromE2, 1},
7654 Counter{cRestSubFailNotifToXapp, 1},
7655 Counter{cRestSubDelReqFromXapp, 1},
7656 Counter{cRestSubDelRespToXapp, 1},
7657 Counter{cSubDelReqToE2, 1},
7658 Counter{cSubDelRespFromE2, 1},
7659 })
7660
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007661 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007662
7663 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007664 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007665 restSubId := xappConn1.SendRESTSubsReq(t, params)
7666
7667 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7668
Anssi Mannila21782182021-12-10 10:56:02 +02007669 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007670 orgInstanceId := crereq.RequestId.InstanceId
7671 crereq.RequestId.InstanceId = 0
7672 e2termConn1.SendSubsResp(t, crereq, cremsg)
7673
7674 _, cremsg = e2termConn1.RecvSubsReq(t)
7675
Markku Virtanen55d2a282021-06-04 14:46:56 +03007676 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007677
Anssi Mannila21782182021-12-10 10:56:02 +02007678 // 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 +03007679 fparams := &teststube2ap.E2StubSubsFailParams{}
7680 fparams.Set(crereq)
7681 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7682 e2termConn1.SendSubsFail(t, fparams, cremsg)
7683
7684 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7685 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7686
7687 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007688 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007689
Anssi Mannilab43397e2021-11-16 12:06:16 +02007690 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7691
Anssi Mannila51122392021-05-25 11:51:31 +03007692 // Wait that subs is cleaned
7693 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7694
7695 xappConn1.TestMsgChanEmpty(t)
7696 e2termConn1.TestMsgChanEmpty(t)
7697 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007698 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007699 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007700}
7701
7702//-----------------------------------------------------------------------------
7703// TestRESTUnpackSubscriptionResponseNoTransaction
7704//
7705// stub stub
7706// +-------+ +---------+ +---------+
7707// | xapp | | submgr | | e2term |
7708// +-------+ +---------+ +---------+
7709// | | |
7710// | RestSubReq | |
7711// |---------------->| |
7712// | | |
7713// | RESTSubResp | |
7714// |<----------------| |
7715// | | |
7716// | | SubReq |
7717// | |------------->|
7718// | | |
7719// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007720// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007721// | | |
7722// | | SubReq |
7723// | |------------->|
7724// | | |
7725// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007726// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007727// | RESTNotif (fail)| |
7728// |<----------------| |
7729// | | SubDelReq |
7730// | |------------->|
7731// | | |
7732// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007733// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007734// | | |
7735// | | SubDelReq |
7736// | |------------->|
7737// | | |
7738// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007739// | |<-------------| Ongoing transaction not found.
7740// | | |
7741// | [SUBS DELETE] |
7742// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007743//
7744//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007745
Anssi Mannila51122392021-05-25 11:51:31 +03007746func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007747
7748 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7749 Counter{cRestSubReqFromXapp, 1},
7750 Counter{cRestSubRespToXapp, 1},
7751 Counter{cSubReqToE2, 1},
7752 Counter{cSubReqTimerExpiry, 2},
7753 Counter{cSubReReqToE2, 1},
7754 Counter{cSubRespFromE2, 1},
7755 Counter{cSubFailFromE2, 1},
7756 Counter{cRestSubFailNotifToXapp, 1},
7757 Counter{cRestSubDelReqFromXapp, 1},
7758 Counter{cRestSubDelRespToXapp, 1},
7759 Counter{cSubDelReqToE2, 1},
7760 Counter{cSubDelReqTimerExpiry, 2},
7761 Counter{cSubDelReReqToE2, 1},
7762 Counter{cSubDelRespFromE2, 2},
7763 })
7764
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007765 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007766
7767 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007768 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007769 restSubId := xappConn1.SendRESTSubsReq(t, params)
7770
7771 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7772
7773 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7774 // No transaction exist for this response which will result resending original request
7775 e2termConn1.SendSubsResp(t, crereq, cremsg)
7776
7777 _, cremsg = e2termConn1.RecvSubsReq(t)
7778
Markku Virtanen55d2a282021-06-04 14:46:56 +03007779 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007780
7781 // Subscription already created in E2 Node.
7782 fparams := &teststube2ap.E2StubSubsFailParams{}
7783 fparams.Set(crereq)
7784 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7785 e2termConn1.SendSubsFail(t, fparams, cremsg)
7786
7787 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7788 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7789
7790 // Resending happens because there no transaction
7791 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7792 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7793
7794 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007795 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007796
Anssi Mannilab43397e2021-11-16 12:06:16 +02007797 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7798
Anssi Mannila51122392021-05-25 11:51:31 +03007799 // Wait that subs is cleaned
7800 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7801
7802 xappConn1.TestMsgChanEmpty(t)
7803 e2termConn1.TestMsgChanEmpty(t)
7804 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007805 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007806 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007807}
7808
7809//-----------------------------------------------------------------------------
7810// TestRESTUnpackSubscriptionFailureDecodeFail
7811//
7812// stub stub
7813// +-------+ +---------+ +---------+
7814// | xapp | | submgr | | e2term |
7815// +-------+ +---------+ +---------+
7816// | | |
7817// | RestSubReq | |
7818// |---------------->| |
7819// | | |
7820// | RESTSubResp | |
7821// |<----------------| |
7822// | | |
7823// | | SubReq |
7824// | |------------->|
7825// | | |
7826// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007827// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007828// | | |
7829// | | SubReq |
7830// | |------------->|
7831// | | |
7832// | | SubFail | Duplicated action
7833// | |<-------------|
7834// | RESTNotif (fail)| |
7835// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007836// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007837// | [SUBS DELETE] |
7838// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007839//
7840//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007841
Anssi Mannila51122392021-05-25 11:51:31 +03007842func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007843
7844 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7845 Counter{cRestSubReqFromXapp, 1},
7846 Counter{cRestSubRespToXapp, 1},
7847 Counter{cSubReqToE2, 1},
7848 Counter{cSubReqTimerExpiry, 1},
7849 Counter{cSubReReqToE2, 1},
7850 Counter{cSubFailFromE2, 2},
7851 Counter{cRestSubFailNotifToXapp, 1},
7852 Counter{cRestSubDelReqFromXapp, 1},
7853 Counter{cRestSubDelRespToXapp, 1},
7854 })
7855
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007856 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007857
7858 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007859 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007860 restSubId := xappConn1.SendRESTSubsReq(t, params)
7861
7862 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7863
7864 // Decode of this response fails which will result resending original request
7865 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7866
7867 _, cremsg = e2termConn1.RecvSubsReq(t)
7868
Markku Virtanen55d2a282021-06-04 14:46:56 +03007869 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007870
7871 // Subscription already created in E2 Node.
7872 fparams := &teststube2ap.E2StubSubsFailParams{}
7873 fparams.Set(crereq)
7874 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7875 e2termConn1.SendSubsFail(t, fparams, cremsg)
7876
Anssi Mannila51122392021-05-25 11:51:31 +03007877 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007878 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007879
Anssi Mannilab43397e2021-11-16 12:06:16 +02007880 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7881
Anssi Mannila51122392021-05-25 11:51:31 +03007882 // Wait that subs is cleaned
7883 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7884
7885 xappConn1.TestMsgChanEmpty(t)
7886 e2termConn1.TestMsgChanEmpty(t)
7887 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007888 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007889 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007890}
7891
7892//-----------------------------------------------------------------------------
7893// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7894//
7895// stub stub
7896// +-------+ +---------+ +---------+
7897// | xapp | | submgr | | e2term |
7898// +-------+ +---------+ +---------+
7899// | | |
7900// | RestSubReq | |
7901// |---------------->| |
7902// | | |
7903// | RESTSubResp | |
7904// |<----------------| |
7905// | | |
7906// | | SubReq |
7907// | |------------->|
7908// | | |
7909// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007910// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007911// | | |
7912// | | SubReq |
7913// | |------------->|
7914// | | |
7915// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007916// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007917// | RESTNotif (fail)| |
7918// |<----------------| |
7919// | | SubDelReq |
7920// | |------------->|
7921// | | |
7922// | | SubDelResp |
7923// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007924// | | |
7925// | [SUBS DELETE] |
7926// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007927//
7928//-----------------------------------------------------------------------------
7929func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007930
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007931 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007932
Anssi Mannila21782182021-12-10 10:56:02 +02007933 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7934 Counter{cRestSubReqFromXapp, 1},
7935 Counter{cRestSubRespToXapp, 1},
7936 Counter{cSubReqToE2, 1},
7937 Counter{cSubReqTimerExpiry, 2},
7938 Counter{cSubReReqToE2, 1},
7939 Counter{cSubFailFromE2, 2},
7940 Counter{cRestSubFailNotifToXapp, 1},
7941 Counter{cRestSubDelReqFromXapp, 1},
7942 Counter{cRestSubDelRespToXapp, 1},
7943 Counter{cSubDelReqToE2, 1},
7944 Counter{cSubDelRespFromE2, 1},
7945 })
7946
Anssi Mannila51122392021-05-25 11:51:31 +03007947 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007948 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007949 restSubId := xappConn1.SendRESTSubsReq(t, params)
7950
7951 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7952
Anssi Mannila21782182021-12-10 10:56:02 +02007953 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007954 fparams := &teststube2ap.E2StubSubsFailParams{}
7955 fparams.Set(crereq)
7956 fparams.Fail.RequestId.InstanceId = 0
7957 e2termConn1.SendSubsFail(t, fparams, cremsg)
7958
7959 _, cremsg = e2termConn1.RecvSubsReq(t)
7960
Markku Virtanen55d2a282021-06-04 14:46:56 +03007961 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007962
Anssi Mannila21782182021-12-10 10:56:02 +02007963 // 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 +03007964 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7965 e2termConn1.SendSubsFail(t, fparams, cremsg)
7966
7967 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7968 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7969
7970 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007971 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007972
Anssi Mannilab43397e2021-11-16 12:06:16 +02007973 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7974
Anssi Mannila51122392021-05-25 11:51:31 +03007975 // Wait that subs is cleaned
7976 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7977
7978 xappConn1.TestMsgChanEmpty(t)
7979 e2termConn1.TestMsgChanEmpty(t)
7980 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007981 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007982 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007983}
7984
7985//-----------------------------------------------------------------------------
7986// TestRESTUnpackSubscriptionFailureNoTransaction
7987//
7988// stub stub
7989// +-------+ +---------+ +---------+
7990// | xapp | | submgr | | e2term |
7991// +-------+ +---------+ +---------+
7992// | | |
7993// | RestSubReq | |
7994// |---------------->| |
7995// | | |
7996// | RESTSubResp | |
7997// |<----------------| |
7998// | | |
7999// | | SubReq |
8000// | |------------->|
8001// | | |
8002// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008003// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008004// | | |
8005// | | SubReq |
8006// | |------------->|
8007// | | |
8008// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02008009// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03008010// | RESTNotif (fail)| |
8011// |<----------------| |
8012// | | SubDelReq |
8013// | |------------->|
8014// | | |
8015// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02008016// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
8017// | | |
8018// | | SubDelReq |
8019// | |------------->|
8020// | | |
8021// | | SubDelResp |
8022// | |<-------------| Ongoing transaction not found.
8023// | | |
8024// | [SUBS DELETE] |
8025// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008026//
8027//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008028
Anssi Mannila51122392021-05-25 11:51:31 +03008029func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02008030
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008031 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03008032
Anssi Mannila21782182021-12-10 10:56:02 +02008033 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8034 Counter{cRestSubReqFromXapp, 1},
8035 Counter{cRestSubRespToXapp, 1},
8036 Counter{cSubReqToE2, 1},
8037 Counter{cSubReqTimerExpiry, 2},
8038 Counter{cSubReReqToE2, 1},
8039 Counter{cSubFailFromE2, 2},
8040 Counter{cRestSubFailNotifToXapp, 1},
8041 Counter{cRestSubDelReqFromXapp, 1},
8042 Counter{cRestSubDelRespToXapp, 1},
8043 Counter{cSubDelReqToE2, 1},
8044 Counter{cSubDelReqTimerExpiry, 2},
8045 Counter{cSubDelReReqToE2, 1},
8046 Counter{cSubDelRespFromE2, 2},
8047 })
8048
Anssi Mannila51122392021-05-25 11:51:31 +03008049 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008050 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03008051 restSubId := xappConn1.SendRESTSubsReq(t, params)
8052
8053 crereq, cremsg := e2termConn1.RecvSubsReq(t)
8054
8055 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
8056
8057 // No transaction exist for this response which will result resending original request
8058 fparams := &teststube2ap.E2StubSubsFailParams{}
8059 fparams.Set(crereq)
8060 e2termConn1.SendSubsFail(t, fparams, cremsg)
8061
8062 _, cremsg = e2termConn1.RecvSubsReq(t)
8063
Markku Virtanen55d2a282021-06-04 14:46:56 +03008064 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03008065
8066 // Subscription already created in E2 Node.
8067 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
8068 e2termConn1.SendSubsFail(t, fparams, cremsg)
8069
8070 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8071 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8072
8073 // Resending happens because there no transaction
8074 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8075 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8076
8077 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008078 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03008079
Anssi Mannilab43397e2021-11-16 12:06:16 +02008080 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8081
Anssi Mannila51122392021-05-25 11:51:31 +03008082 // Wait that subs is cleaned
8083 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
8084
8085 xappConn1.TestMsgChanEmpty(t)
8086 e2termConn1.TestMsgChanEmpty(t)
8087 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008088 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008089 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008090}
8091
8092//-----------------------------------------------------------------------------
8093// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
8094//
8095// stub stub
8096// +-------+ +---------+ +---------+
8097// | xapp | | submgr | | e2term |
8098// +-------+ +---------+ +---------+
8099// | | |
8100// | [SUBS CREATE] |
8101// | | |
8102// | | |
8103// | RESTSubDelReq | |
8104// |---------------->| |
8105// | | |
8106// | RESTSubDelResp | |
8107// |<----------------| |
8108// | | |
8109// | | SubDelReq |
8110// | |------------->|
8111// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008112// | | SubDelResp | ASN.1 decode fails.
8113// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008114// | | |
8115// | | SubDelReq |
8116// | |------------->|
8117// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008118// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008119// | |<-------------|
8120// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008121// | [SUBS DELETE] |
8122// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008123//
8124//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008125
Anssi Mannila51122392021-05-25 11:51:31 +03008126func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008127
Anssi Mannila21782182021-12-10 10:56:02 +02008128 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8129 Counter{cRestSubReqFromXapp, 1},
8130 Counter{cRestSubRespToXapp, 1},
8131 Counter{cSubReqToE2, 1},
8132 Counter{cSubRespFromE2, 1},
8133 Counter{cRestSubNotifToXapp, 1},
8134 Counter{cRestSubDelReqFromXapp, 1},
8135 Counter{cRestSubDelRespToXapp, 1},
8136 Counter{cSubDelReqToE2, 1},
8137 Counter{cSubDelReqTimerExpiry, 1},
8138 Counter{cSubDelReReqToE2, 1},
8139 Counter{cSubDelFailFromE2, 1},
8140 Counter{cSubDelRespFromE2, 1},
8141 })
8142
Anssi Mannila51122392021-05-25 11:51:31 +03008143 // Req
8144 var params *teststube2ap.RESTSubsReqParams = nil
8145 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8146
8147 // Del
8148 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8149
8150 // E2t: Receive 1st SubsDelReq
8151 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8152
8153 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02008154 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03008155
8156 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8157 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8158
8159 // Subscription does not exist in in E2 Node.
8160 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8161
8162 // Wait that subs is cleaned
8163 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8164
8165 xappConn1.TestMsgChanEmpty(t)
8166 e2termConn1.TestMsgChanEmpty(t)
8167 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008168 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008169 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008170}
8171
8172//-----------------------------------------------------------------------------
8173// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
8174//
8175// stub stub
8176// +-------+ +---------+ +---------+
8177// | xapp | | submgr | | e2term |
8178// +-------+ +---------+ +---------+
8179// | | |
8180// | [SUBS CREATE] |
8181// | | |
8182// | | |
8183// | RESTSubDelReq | |
8184// |---------------->| |
8185// | | |
8186// | RESTSubDelResp | |
8187// |<----------------| |
8188// | | |
8189// | | SubDelReq |
8190// | |------------->|
8191// | | |
8192// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008193// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008194// | | |
8195// | | SubDelReq |
8196// | |------------->|
8197// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008198// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008199// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008200// | | |
8201// | [SUBS DELETE] |
8202// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008203//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008204
Anssi Mannila51122392021-05-25 11:51:31 +03008205func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008206
Anssi Mannila21782182021-12-10 10:56:02 +02008207 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8208 Counter{cRestSubReqFromXapp, 1},
8209 Counter{cRestSubRespToXapp, 1},
8210 Counter{cSubReqToE2, 1},
8211 Counter{cSubRespFromE2, 1},
8212 Counter{cRestSubNotifToXapp, 1},
8213 Counter{cRestSubDelReqFromXapp, 1},
8214 Counter{cRestSubDelRespToXapp, 1},
8215 Counter{cSubDelReqToE2, 1},
8216 Counter{cSubDelReqTimerExpiry, 1},
8217 Counter{cSubDelReReqToE2, 1},
8218 Counter{cSubDelRespFromE2, 1},
8219 Counter{cSubDelFailFromE2, 1},
8220 })
8221
Anssi Mannila51122392021-05-25 11:51:31 +03008222 // Req
8223 var params *teststube2ap.RESTSubsReqParams = nil
8224 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8225
8226 // Del
8227 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8228
8229 // E2t: Receive 1st SubsDelReq
8230 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8231
8232 // Unknown instanceId in this response which will result resending original request
8233 delreq.RequestId.InstanceId = 0
8234 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8235
8236 // E2t: Receive 2nd SubsDelReq
8237 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8238
8239 // Subscription does not exist in in E2 Node.
8240 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8241
8242 // Wait that subs is cleaned
8243 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8244
8245 xappConn1.TestMsgChanEmpty(t)
8246 e2termConn1.TestMsgChanEmpty(t)
8247 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008248 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008249 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008250}
8251
8252//-----------------------------------------------------------------------------
8253// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
8254//
8255// stub stub
8256// +-------+ +---------+ +---------+
8257// | xapp | | submgr | | e2term |
8258// +-------+ +---------+ +---------+
8259// | | |
8260// | [SUBS CREATE] |
8261// | | |
8262// | | |
8263// | RESTSubDelReq | |
8264// |---------------->| |
8265// | | |
8266// | RESTSubDelResp | |
8267// |<----------------| |
8268// | | |
8269// | | SubDelReq |
8270// | |------------->|
8271// | | |
8272// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008273// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008274// | | |
8275// | | SubDelReq |
8276// | |------------->|
8277// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008278// | | SubDelFail | Subscription does exist any more in E2 node
8279// | |<-------------| Ongoing transaction not found. This will result timer expiry
8280// | | |
8281// | [SUBS DELETE] |
8282// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008283//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008284
Anssi Mannila51122392021-05-25 11:51:31 +03008285func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008286
Anssi Mannila21782182021-12-10 10:56:02 +02008287 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8288 Counter{cRestSubReqFromXapp, 1},
8289 Counter{cRestSubRespToXapp, 1},
8290 Counter{cSubReqToE2, 1},
8291 Counter{cSubRespFromE2, 1},
8292 Counter{cRestSubNotifToXapp, 1},
8293 Counter{cRestSubDelReqFromXapp, 1},
8294 Counter{cRestSubDelRespToXapp, 1},
8295 Counter{cSubDelReqToE2, 1},
8296 Counter{cSubDelReqTimerExpiry, 2},
8297 Counter{cSubDelReReqToE2, 1},
8298 Counter{cSubDelRespFromE2, 1},
8299 Counter{cSubDelFailFromE2, 1},
8300 })
8301
Anssi Mannila51122392021-05-25 11:51:31 +03008302 // Req
8303 var params *teststube2ap.RESTSubsReqParams = nil
8304 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8305
8306 // Del
8307 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8308
8309 // E2t: Receive 1st SubsDelReq
8310 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8311
8312 mainCtrl.MakeTransactionNil(t, e2SubsId)
8313
8314 // No transaction exist for this response which will result resending original request
8315 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8316
8317 // E2t: Receive 2nd SubsDelReq
8318 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8319
8320 // Subscription does not exist in in E2 Node.
8321 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8322
8323 // Wait that subs is cleaned
8324 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8325
8326 xappConn1.TestMsgChanEmpty(t)
8327 e2termConn1.TestMsgChanEmpty(t)
8328 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008329 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008330 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008331}
8332
8333//-----------------------------------------------------------------------------
8334// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
8335//
8336// stub stub
8337// +-------+ +---------+ +---------+
8338// | xapp | | submgr | | e2term |
8339// +-------+ +---------+ +---------+
8340// | | |
8341// | [SUBS CREATE] |
8342// | | |
8343// | | |
8344// | RESTSubDelReq | |
8345// |---------------->| |
8346// | | |
8347// | RESTSubDelResp | |
8348// |<----------------| |
8349// | | |
8350// | | SubDelReq |
8351// | |------------->|
8352// | | |
8353// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02008354// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008355// | | |
8356// | | SubDelReq |
8357// | |------------->|
8358// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008359// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008360// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008361// | | |
8362// | [SUBS DELETE] |
8363// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008364//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008365
Anssi Mannila51122392021-05-25 11:51:31 +03008366func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008367
Anssi Mannila21782182021-12-10 10:56:02 +02008368 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8369 Counter{cRestSubReqFromXapp, 1},
8370 Counter{cRestSubRespToXapp, 1},
8371 Counter{cSubReqToE2, 1},
8372 Counter{cSubRespFromE2, 1},
8373 Counter{cRestSubNotifToXapp, 1},
8374 Counter{cRestSubDelReqFromXapp, 1},
8375 Counter{cRestSubDelRespToXapp, 1},
8376 Counter{cSubDelReqToE2, 1},
8377 Counter{cSubDelReqTimerExpiry, 1},
8378 Counter{cSubDelReReqToE2, 1},
8379 Counter{cSubDelFailFromE2, 2},
8380 })
8381
Anssi Mannila51122392021-05-25 11:51:31 +03008382 // Req
8383 var params *teststube2ap.RESTSubsReqParams = nil
8384 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8385
8386 // Del
8387 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8388
8389 // E2t: Receive 1st SubsDelReq
8390 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8391
8392 // Decode of this response fails which will result resending original request
8393 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
8394
8395 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8396 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8397
8398 // Subscription does not exist in in E2 Node.
8399 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8400
8401 // Wait that subs is cleaned
8402 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8403
8404 xappConn1.TestMsgChanEmpty(t)
8405 e2termConn1.TestMsgChanEmpty(t)
8406 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008407 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008408 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008409}
8410
8411//-----------------------------------------------------------------------------
8412// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8413//
8414// stub stub
8415// +-------+ +---------+ +---------+
8416// | xapp | | submgr | | e2term |
8417// +-------+ +---------+ +---------+
8418// | | |
8419// | [SUBS CREATE] |
8420// | | |
8421// | | |
8422// | RESTSubDelReq | |
8423// |---------------->| |
8424// | | |
8425// | RESTSubDelResp | |
8426// |<----------------| |
8427// | | |
8428// | | SubDelReq |
8429// | |------------->|
8430// | | |
8431// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008432// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008433// | | |
8434// | | SubDelReq |
8435// | |------------->|
8436// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008437// | | SubDelFail | Subscription does exist any more in E2 node
8438// | |<-------------| No valid subscription found with subIds [0].
8439// | | |
8440// | [SUBS DELETE] |
8441// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008442//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008443
Anssi Mannila51122392021-05-25 11:51:31 +03008444func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008445
Anssi Mannila21782182021-12-10 10:56:02 +02008446 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8447 Counter{cRestSubReqFromXapp, 1},
8448 Counter{cRestSubRespToXapp, 1},
8449 Counter{cSubReqToE2, 1},
8450 Counter{cSubRespFromE2, 1},
8451 Counter{cRestSubNotifToXapp, 1},
8452 Counter{cRestSubDelReqFromXapp, 1},
8453 Counter{cRestSubDelRespToXapp, 1},
8454 Counter{cSubDelReqToE2, 1},
8455 Counter{cSubDelReqTimerExpiry, 1},
8456 Counter{cSubDelReReqToE2, 1},
8457 Counter{cSubDelFailFromE2, 2},
8458 })
8459
Anssi Mannila51122392021-05-25 11:51:31 +03008460 // Req
8461 var params *teststube2ap.RESTSubsReqParams = nil
8462 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8463
8464 // Del
8465 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8466
8467 // E2t: Receive 1st SubsDelReq
8468 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8469
Anssi Mannila21782182021-12-10 10:56:02 +02008470 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008471 delreq.RequestId.InstanceId = 0
8472 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8473
8474 // E2t: Receive 2nd SubsDelReq
8475 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8476
Anssi Mannila21782182021-12-10 10:56:02 +02008477 // 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 +03008478 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8479
8480 // Wait that subs is cleaned
8481 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8482
8483 xappConn1.TestMsgChanEmpty(t)
8484 e2termConn1.TestMsgChanEmpty(t)
8485 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008486 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008487 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008488}
8489
8490//-----------------------------------------------------------------------------
8491// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8492//
8493// stub stub
8494// +-------+ +---------+ +---------+
8495// | xapp | | submgr | | e2term |
8496// +-------+ +---------+ +---------+
8497// | | |
8498// | [SUBS CREATE] |
8499// | | |
8500// | | |
8501// | RESTSubDelReq | |
8502// |---------------->| |
8503// | | |
8504// | RESTSubDelResp | |
8505// |<----------------| |
8506// | | |
8507// | | SubDelReq |
8508// | |------------->|
8509// | | |
8510// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008511// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008512// | | |
8513// | | SubDelReq |
8514// | |------------->|
8515// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008516// | | SubDelFail | Subscription does exist any more in E2 node
8517// | |<-------------| Ongoing transaction not found. This will result timer expiry
8518// | | |
8519// | [SUBS DELETE] |
8520// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008521//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008522
Anssi Mannila51122392021-05-25 11:51:31 +03008523func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008524
Anssi Mannila21782182021-12-10 10:56:02 +02008525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8526 Counter{cRestSubReqFromXapp, 1},
8527 Counter{cRestSubRespToXapp, 1},
8528 Counter{cSubReqToE2, 1},
8529 Counter{cSubRespFromE2, 1},
8530 Counter{cRestSubNotifToXapp, 1},
8531 Counter{cRestSubDelReqFromXapp, 1},
8532 Counter{cRestSubDelRespToXapp, 1},
8533 Counter{cSubDelReqToE2, 1},
8534 Counter{cSubDelReqTimerExpiry, 2},
8535 Counter{cSubDelReReqToE2, 1},
8536 Counter{cSubDelFailFromE2, 2},
8537 })
8538
Anssi Mannila51122392021-05-25 11:51:31 +03008539 // Req
8540 var params *teststube2ap.RESTSubsReqParams = nil
8541 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8542
8543 // Del
8544 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8545
8546 // E2t: Receive 1st SubsDelReq
8547 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8548
8549 mainCtrl.MakeTransactionNil(t, e2SubsId)
8550
8551 // No transaction exist for this response which will result resending original request
8552 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8553
8554 // E2t: Receive 2nd SubsDelReq
8555 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8556
8557 // Subscription does not exist in in E2 Node.
8558 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8559
8560 // Wait that subs is cleaned
8561 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8562
8563 xappConn1.TestMsgChanEmpty(t)
8564 e2termConn1.TestMsgChanEmpty(t)
8565 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008566 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008567 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008568}
8569
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008570//-----------------------------------------------------------------------------
8571// TestRESTSubReqFailAsn1PackSubReqError
8572//
8573// stub stub
8574// +-------+ +---------+ +---------+
8575// | xapp | | submgr | | e2term |
8576// +-------+ +---------+ +---------+
8577// | | |
8578// | RESTSubReq | |
8579// |---------------->| |
8580// | | |
8581// | RESTSubResp | |
8582// |<----------------| |
8583// | | |
8584// | ASN.1 encode fails |
8585// | | |
8586// | | SubDelReq |
8587// | |------------->|
8588// | | |
8589// | | SubDelFail |
8590// | |<-------------|
8591// | | |
8592// | RESTNotif | |
8593// | unsuccess | |
8594// |<----------------| |
8595// | | |
8596// | [SUBS DELETE] |
8597// | | |
8598//
8599//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008600
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008601func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8602
8603 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008604 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008605 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008606 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008607 Counter{cRestSubDelReqFromXapp, 1},
8608 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008609 })
8610
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008611 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008612
8613 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008614 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008615 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8616
8617 // Req
8618 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008619 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008620
8621 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008622 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008623
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008624 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008625 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008626
8627 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008628
8629 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8630
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008631 // Wait that subs is cleaned
8632 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008633 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008634 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008635}
8636
Anssi Mannila27385172021-12-22 09:41:54 +02008637//-----------------------------------------------------------------------------
8638// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8639//
8640// stub stub
8641// +-------+ +---------+ +---------+
8642// | xapp | | submgr | | e2term |
8643// +-------+ +---------+ +---------+
8644// | | |
8645// | RESTSubReq | |
8646// |---------------->| |
8647// | | |
8648// | RESTSubResp | |
8649// |<----------------| |
8650// | | SubReq |
8651// | |------------->|
8652// | | |
8653// | | SubResp |
8654// | |<-------------|
8655// | | |
8656// | RESTNotif | |
8657// |<----------------| |
8658// | | |
8659// | RESTSubReq | | Policy modification
8660// |---------------->| |
8661// | | |
8662// | RESTSubResp | |
8663// |<----------------| |
8664// | | SubReq |
8665// | |------------->|
8666// | | |
8667// | | |
8668// | RESTNotif(Unsuccessful) | E2 timeout
8669// |<----------------| |
8670// | | |
8671// | RESTSubDelReq | |
8672// |---------------->| |
8673// | | |
8674// | | SubDelReq |
8675// | |------------->|
8676// | | |
8677// | | SubDelResp |
8678// | |<-------------|
8679// | | |
8680// | RESTSubDelResp | |
8681// |<----------------| |
8682//
8683//-----------------------------------------------------------------------------
8684
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008685func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008686
8687 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8688 Counter{cRestSubReqFromXapp, 2},
8689 Counter{cRestSubRespToXapp, 2},
8690 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008691 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008692 Counter{cSubRespFromE2, 1},
8693 Counter{cRestSubNotifToXapp, 1},
8694 Counter{cRestSubFailNotifToXapp, 1},
8695 Counter{cRestSubDelReqFromXapp, 1},
8696 Counter{cSubDelReqToE2, 1},
8697 Counter{cSubDelRespFromE2, 1},
8698 Counter{cRestSubDelRespToXapp, 1},
8699 })
8700
8701 const e2Timeout int64 = 1
8702 const e2RetryCount int64 = 0
8703 const routingNeeded bool = false
8704
8705 // Req1
8706 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8707 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8708
8709 // Subs Create
8710 restSubId := xappConn1.SendRESTSubsReq(t, params)
8711 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8712
8713 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8714 xappConn1.ExpectRESTNotification(t, restSubId)
8715 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8716 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8717 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8718
8719 // Policy change
8720 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8721 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8722 params.SetSubscriptionID(&restSubId)
8723 params.SetTimeToWait("w200ms")
8724 restSubId = xappConn1.SendRESTSubsReq(t, params)
8725 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8726
8727 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8728 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008729 // SubsResp is missing, e2SubsId will be 0
8730 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8731 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008732
8733 // Del
8734 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8735 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8736 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8737
8738 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008739 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008740 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008741}
8742
8743//-----------------------------------------------------------------------------
8744// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8745//
8746// stub stub
8747// +-------+ +---------+ +---------+
8748// | xapp | | submgr | | e2term |
8749// +-------+ +---------+ +---------+
8750// | | |
8751// | RESTSubReq | |
8752// |---------------->| |
8753// | | |
8754// | RESTSubResp | |
8755// |<----------------| |
8756// | | SubReq |
8757// | |------------->|
8758// | | |
8759// | | SubResp |
8760// | |<-------------|
8761// | | |
8762// | RESTNotif | |
8763// |<----------------| |
8764// | | |
8765// | RESTSubReq | |
8766// |---------------->| |
8767// | | |
8768// | RESTSubResp | |
8769// |<----------------| |
8770// | | SubReq |
8771// | |------------->|
8772// | |
8773// | Submgr restart |
8774// | | |
8775// | RESTSubDelReq | |
8776// |---------------->| |
8777// | | |
8778// | | SubDelReq |
8779// | |------------->|
8780// | | |
8781// | | SubDelResp |
8782// | |<-------------|
8783// | | |
8784// | RESTSubDelResp | |
8785// |<----------------| |
8786//
8787//-----------------------------------------------------------------------------
8788
8789func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008790
8791 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8792 Counter{cRestSubReqFromXapp, 2},
8793 Counter{cRestSubRespToXapp, 2},
8794 Counter{cSubReqToE2, 2},
8795 Counter{cSubRespFromE2, 1},
8796 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008797 Counter{cRestSubDelReqFromXapp, 1},
8798 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008799 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008800 Counter{cRestSubDelRespToXapp, 1},
8801 })
8802
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008803 const e2Timeout int64 = 1
8804 const e2RetryCount int64 = 0
8805 const routingNeeded bool = false
8806
8807 // Req1
8808 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8809 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8810 // Create subscription
8811 restSubId := xappConn1.SendRESTSubsReq(t, params)
8812 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8813
8814 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8815 xappConn1.ExpectRESTNotification(t, restSubId)
8816 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8817 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8818 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8819
8820 // Check subscription
8821 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8822
8823 // Policy change
8824 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8825 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8826 params.SetSubscriptionID(&restSubId)
8827 params.SetTimeToWait("w200ms")
8828 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8829 restSubId = xappConn1.SendRESTSubsReq(t, params)
8830 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8831
8832 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8833 mainCtrl.SetResetTestFlag(t, false)
8834
8835 // SubsResp is missing due to submgr restart
8836
8837 mainCtrl.SimulateRestart(t)
8838 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8839
Anssi Mannila54838ed2021-11-19 11:25:01 +02008840 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8841 // That needs to be completed before successful subscription query is possible
8842 <-time.After(time.Second * 1)
8843
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008844 // Check subscription
8845 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8846
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008847 // Delete subscription
8848 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8849 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8850 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8851
8852 //Wait that subs is cleaned
8853 waitSubsCleanup(t, e2SubsId, 10)
8854
8855 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008856 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008857}
8858
archaggeafbf95f2021-04-14 08:54:05 +03008859////////////////////////////////////////////////////////////////////////////////////
8860// Services for UT cases
8861////////////////////////////////////////////////////////////////////////////////////
8862const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008863const host string = "localhost"
8864
8865func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8866 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008867 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008868 }
8869 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008870 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008871
8872 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8873 fromXappConn.ExpectRESTNotification(t, restSubId)
8874 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8875 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008876 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008877
8878 return restSubId, e2SubsId
8879}
8880
8881func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8882
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008883 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008884 if meid != "" {
8885 params.SetMeid(meid)
8886 }
8887 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8888 restSubId := xappConn2.SendRESTSubsReq(t, params)
8889 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008890 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008891 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008892 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008893
8894 return restSubId, e2SubsId
8895}
8896
8897func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008898
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008899 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008900 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008901 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008902
8903 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8904 xappConn1.ExpectRESTNotification(t, restSubId)
8905 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8906 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008907 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008908
8909 return restSubId, e2SubsId
8910}
8911
8912func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008913 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008914 restSubId := xappConn1.SendRESTSubsReq(t, params)
8915
8916 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8917 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8918 fparams1.Set(crereq1)
8919 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8920
8921 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8922 xappConn1.ExpectRESTNotification(t, restSubId)
8923 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8924 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008925 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008926
8927 return restSubId, e2SubsId
8928}
8929
8930func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8931 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8932 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8933 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8934}
8935
8936func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8937 xappConn1.SendRESTSubsDelReq(t, restSubId)
8938 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8939 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8940}
8941
8942func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8943 xappConn2.SendRESTSubsDelReq(t, restSubId)
8944 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8945 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8946}
8947
8948func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8949 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008950 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8951 assert.Equal(t, meid, resp[0].Meid)
8952 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008953}
8954
8955func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8956 //Wait that subs is cleaned
8957 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8958
8959 xappConn1.TestMsgChanEmpty(t)
8960 xappConn2.TestMsgChanEmpty(t)
8961 e2termConn1.TestMsgChanEmpty(t)
8962 mainCtrl.wait_registry_empty(t, timeout)
8963}
8964
8965func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8966
8967 var e2SubsId []uint32
8968
8969 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008970 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008971 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8972 fromXappConn.ExpectRESTNotification(t, restSubId)
8973 toE2termConn.SendSubsResp(t, crereq, cremsg)
8974 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8975 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008976 xapp.Logger.Debug("TEST: %v", e2SubsId)
8977 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008978 <-time.After(100 * time.Millisecond)
8979 }
8980 return e2SubsId
8981}
8982
8983func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8984
8985 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008986 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008987 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8988 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8989 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008990 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008991 <-time.After(100 * time.Millisecond)
8992 }
8993
8994 // Wait that subs is cleaned
8995 for i := 0; i < len(e2SubsIds); i++ {
8996 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8997 }
8998
8999}