blob: 214cf434666af9d0aa93725983c0194d0e0ccaf3 [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//-----------------------------------------------------------------------------
885// TestSubReqRetransmission
886//
887// stub stub
888// +-------+ +---------+ +---------+
889// | xapp | | submgr | | e2term |
890// +-------+ +---------+ +---------+
891// | | |
892// | SubReq | |
893// |------------->| |
894// | | |
895// | | SubReq |
896// | |------------->|
897// | | |
898// | SubReq | |
899// | (retrans) | |
900// |------------->| |
901// | | |
902// | | SubResp |
903// | |<-------------|
904// | | |
905// | SubResp | |
906// |<-------------| |
907// | | |
908// | [SUBS DELETE] |
909// | | |
910//
911//-----------------------------------------------------------------------------
912func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200913 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200917 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200918
919 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200920 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200921 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
922
Juha Hyttinen1683f912020-04-17 10:39:57 +0300923 // hack as there is no real way to see has message be handled.
924 // Previuos counter check just tells that is has been received by submgr
925 // --> artificial delay
926 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200927 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200928 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200929
930 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200931 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200932 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
933 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200934 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200935
936 //Wait that subs is cleaned
937 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
938
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200939 xappConn1.TestMsgChanEmpty(t)
940 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200941 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200942 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200943}
944
945//-----------------------------------------------------------------------------
946// TestSubDelReqRetransmission
947//
948// stub stub
949// +-------+ +---------+ +---------+
950// | xapp | | submgr | | e2term |
951// +-------+ +---------+ +---------+
952// | | |
953// | [SUBS CREATE] |
954// | | |
955// | | |
956// | SubDelReq | |
957// |------------->| |
958// | | |
959// | | SubDelReq |
960// | |------------->|
961// | | |
962// | SubDelReq | |
963// | (same sub) | |
964// | (same xid) | |
965// |------------->| |
966// | | |
967// | | SubDelResp |
968// | |<-------------|
969// | | |
970// | SubDelResp | |
971// |<-------------| |
972//
973//-----------------------------------------------------------------------------
974func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200975 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200976
977 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200978 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200979 crereq, cremsg := e2termConn1.RecvSubsReq(t)
980 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200981 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200982
983 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200984 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200985 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200986
987 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200988 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200989 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
990
Juha Hyttinen1683f912020-04-17 10:39:57 +0300991 // hack as there is no real way to see has message be handled.
992 // Previuos counter check just tells that is has been received by submgr
993 // --> artificial delay
994 <-time.After(1 * time.Second)
995
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200996 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200997 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200998
999 //Wait that subs is cleaned
1000 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1001
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001002 xappConn1.TestMsgChanEmpty(t)
1003 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001004 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001005 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006}
1007
1008//-----------------------------------------------------------------------------
1009// TestSubDelReqCollision
1010//
1011// stub stub
1012// +-------+ +---------+ +---------+
1013// | xapp | | submgr | | e2term |
1014// +-------+ +---------+ +---------+
1015// | | |
1016// | [SUBS CREATE] |
1017// | | |
1018// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001019// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001020// |------------->| |
1021// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001022// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001023// | |------------->|
1024// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001025// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001026// | (same sub) | |
1027// | (diff xid) | |
1028// |------------->| |
1029// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001030// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001031// | |<-------------|
1032// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001033// | SubDelResp 1 | |
1034// |<-------------| |
1035// | | |
1036// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001037// |<-------------| |
1038//
1039//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001040
Juha Hyttinenfa015662020-01-24 10:05:18 +02001041func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001042 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001043
1044 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001045 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001046 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1047 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001048 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001049
1050 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001051 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001052 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001053
Juha Hyttinen3944a222020-01-24 11:51:46 +02001054 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001055 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001056 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1057 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001058 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1059
Juha Hyttinen1683f912020-04-17 10:39:57 +03001060 // hack as there is no real way to see has message be handled.
1061 // Previuos counter check just tells that is has been received by submgr
1062 // --> artificial delay
1063 <-time.After(1 * time.Second)
1064
Juha Hyttinen3944a222020-01-24 11:51:46 +02001065 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001066 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001067
1068 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001069 xappConn1.RecvSubsDelResp(t, nil)
1070 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001071
1072 //Wait that subs is cleaned
1073 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1074
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001075 xappConn1.TestMsgChanEmpty(t)
1076 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001077 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001078 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001079}
1080
1081//-----------------------------------------------------------------------------
1082// TestSubReqAndSubDelOkTwoParallel
1083//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001084// stub stub stub
1085// +-------+ +-------+ +---------+ +---------+
1086// | xapp | | xapp | | submgr | | e2term |
1087// +-------+ +-------+ +---------+ +---------+
1088// | | | |
1089// | | | |
1090// | | | |
1091// | | SubReq1 | |
1092// | |------------->| |
1093// | | | |
1094// | | | SubReq1 |
1095// | | |------------->|
1096// | | | |
1097// | SubReq2 | |
1098// |------------------------>| |
1099// | | | |
1100// | | | SubReq2 |
1101// | | |------------->|
1102// | | | |
1103// | | | SubResp1 |
1104// | | |<-------------|
1105// | | SubResp1 | |
1106// | |<-------------| |
1107// | | | |
1108// | | | SubResp2 |
1109// | | |<-------------|
1110// | SubResp2 | |
1111// |<------------------------| |
1112// | | | |
1113// | | [SUBS 1 DELETE] |
1114// | | | |
1115// | | [SUBS 2 DELETE] |
1116// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001117//
1118//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001119
Juha Hyttinenfa015662020-01-24 10:05:18 +02001120func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001121 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001122
1123 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001124 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001125 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001126 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001127 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001128
1129 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001130 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001131 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001132
1133 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1134 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1135 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1136
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001137 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001138 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001139
1140 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001141 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001142 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143
1144 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001146 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147
1148 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001149 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001150 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1151 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001152 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001153 //Wait that subs is cleaned
1154 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1155
1156 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001157 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001158 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1159 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001160 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001161 //Wait that subs is cleaned
1162 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1163
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001164 xappConn1.TestMsgChanEmpty(t)
1165 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001166 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001167 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001168}
1169
1170//-----------------------------------------------------------------------------
1171// TestSameSubsDiffRan
1172// Same subscription to different RANs
1173//
1174// stub stub
1175// +-------+ +---------+ +---------+
1176// | xapp | | submgr | | e2term |
1177// +-------+ +---------+ +---------+
1178// | | |
1179// | | |
1180// | | |
1181// | SubReq(r1) | |
1182// |------------->| |
1183// | | |
1184// | | SubReq(r1) |
1185// | |------------->|
1186// | | |
1187// | | SubResp(r1) |
1188// | |<-------------|
1189// | | |
1190// | SubResp(r1) | |
1191// |<-------------| |
1192// | | |
1193// | SubReq(r2) | |
1194// |------------->| |
1195// | | |
1196// | | SubReq(r2) |
1197// | |------------->|
1198// | | |
1199// | | SubResp(r2) |
1200// | |<-------------|
1201// | | |
1202// | SubResp(r2) | |
1203// |<-------------| |
1204// | | |
1205// | [SUBS r1 DELETE] |
1206// | | |
1207// | [SUBS r2 DELETE] |
1208// | | |
1209//
1210//-----------------------------------------------------------------------------
1211func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001212 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001213
1214 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001215 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1216 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001217 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1218 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001220
1221 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001222 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1223 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001224 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1225 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001226 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001227
1228 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001229 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1230 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001231 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1232 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001233 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001234 //Wait that subs is cleaned
1235 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1236
1237 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001238 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1239 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001240 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1241 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001242 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001243 //Wait that subs is cleaned
1244 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1245
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001246 xappConn1.TestMsgChanEmpty(t)
1247 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001248 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001249 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001250}
1251
1252//-----------------------------------------------------------------------------
1253// TestSubReqRetryInSubmgr
1254//
1255// stub stub
1256// +-------+ +---------+ +---------+
1257// | xapp | | submgr | | e2term |
1258// +-------+ +---------+ +---------+
1259// | | |
1260// | SubReq | |
1261// |------------->| |
1262// | | |
1263// | | SubReq |
1264// | |------------->|
1265// | | |
1266// | | |
1267// | | SubReq |
1268// | |------------->|
1269// | | |
1270// | | SubResp |
1271// | |<-------------|
1272// | | |
1273// | SubResp | |
1274// |<-------------| |
1275// | | |
1276// | [SUBS DELETE] |
1277// | | |
1278//
1279//-----------------------------------------------------------------------------
1280
1281func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001282 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001283
1284 // Init counter check
1285 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1286 Counter{cSubReqFromXapp, 1},
1287 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001288 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001289 Counter{cSubReReqToE2, 1},
1290 Counter{cSubRespFromE2, 1},
1291 Counter{cSubRespToXapp, 1},
1292 Counter{cSubDelReqFromXapp, 1},
1293 Counter{cSubDelReqToE2, 1},
1294 Counter{cSubDelRespFromE2, 1},
1295 Counter{cSubDelRespToXapp, 1},
1296 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001297
1298 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001299 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001300
1301 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001302 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001303
1304 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001305 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1306 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001307
1308 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001309 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001310
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001311 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001312 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1313 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001314 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001315
1316 // Wait that subs is cleaned
1317 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1318
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 xappConn1.TestMsgChanEmpty(t)
1320 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001321 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001322 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001323
1324 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001325}
1326
1327//-----------------------------------------------------------------------------
1328// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1329//
1330// stub stub
1331// +-------+ +---------+ +---------+
1332// | xapp | | submgr | | e2term |
1333// +-------+ +---------+ +---------+
1334// | | |
1335// | SubReq | |
1336// |------------->| |
1337// | | |
1338// | | SubReq |
1339// | |------------->|
1340// | | |
1341// | | |
1342// | | SubReq |
1343// | |------------->|
1344// | | |
1345// | | SubDelReq |
1346// | |------------->|
1347// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001348// | | SubDelResp |
1349// | |<-------------|
1350// | | |
1351//
1352//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001353func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001354 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001355
1356 // Init counter check
1357 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1358 Counter{cSubReqFromXapp, 1},
1359 Counter{cSubReqToE2, 1},
1360 Counter{cSubReReqToE2, 1},
1361 Counter{cSubReqTimerExpiry, 2},
1362 Counter{cSubDelReqToE2, 1},
1363 Counter{cSubDelRespFromE2, 1},
1364 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001365
1366 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001367 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001368
1369 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001370 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001371
1372 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001373 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001374
1375 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001376 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1377 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001378
1379 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001380 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001381
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001382 xappConn1.TestMsgChanEmpty(t)
1383 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001384 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001385 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001386
1387 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001388}
1389
1390//-----------------------------------------------------------------------------
1391// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1392//
1393// stub stub
1394// +-------+ +---------+ +---------+
1395// | xapp | | submgr | | e2term |
1396// +-------+ +---------+ +---------+
1397// | | |
1398// | SubReq | |
1399// |------------->| |
1400// | | |
1401// | | SubReq |
1402// | |------------->|
1403// | | |
1404// | | |
1405// | | SubReq |
1406// | |------------->|
1407// | | |
1408// | | SubDelReq |
1409// | |------------->|
1410// | | |
1411// | | |
1412// | | SubDelReq |
1413// | |------------->|
1414// | | |
1415// | | |
1416//
1417//-----------------------------------------------------------------------------
1418
1419func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001420 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001421
1422 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1423 Counter{cSubReqFromXapp, 1},
1424 Counter{cSubReqToE2, 1},
1425 Counter{cSubReReqToE2, 1},
1426 Counter{cSubReqTimerExpiry, 2},
1427 Counter{cSubDelReqToE2, 1},
1428 Counter{cSubDelReReqToE2, 1},
1429 Counter{cSubDelReqTimerExpiry, 2},
1430 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001431
1432 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001433 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001434
1435 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001436 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001437
1438 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001439 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001440
1441 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001442 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001443
1444 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001445 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001446
1447 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001448 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001449
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001450 xappConn1.TestMsgChanEmpty(t)
1451 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001452 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001453 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001454
1455 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001456}
1457
1458//-----------------------------------------------------------------------------
1459// TestSubReqSubFailRespInSubmgr
1460//
1461// stub stub
1462// +-------+ +---------+ +---------+
1463// | xapp | | submgr | | e2term |
1464// +-------+ +---------+ +---------+
1465// | | |
1466// | SubReq | |
1467// |------------->| |
1468// | | |
1469// | | SubReq |
1470// | |------------->|
1471// | | |
1472// | | SubFail |
1473// | |<-------------|
1474// | | |
1475// | SubFail | |
1476// |<-------------| |
1477// | | |
1478//
1479//-----------------------------------------------------------------------------
1480
1481func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001482 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001483
1484 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1485 Counter{cSubReqFromXapp, 1},
1486 Counter{cSubReqToE2, 1},
1487 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001488 Counter{cSubFailToXapp, 1},
1489 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001490
1491 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001492 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001493
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001494 // E2t: Receive SubsReq and send SubsFail (first)
1495 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1496 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1497 fparams1.Set(crereq1)
1498 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1499
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001500 // Xapp: Receive SubsFail
1501 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1502
1503 // Wait that subs is cleaned
1504 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1505
1506 xappConn1.TestMsgChanEmpty(t)
1507 xappConn2.TestMsgChanEmpty(t)
1508 e2termConn1.TestMsgChanEmpty(t)
1509 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001510
1511 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001512}
1513
1514//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001515// TestSubDelReqRetryInSubmgr
1516//
1517// stub stub
1518// +-------+ +---------+ +---------+
1519// | xapp | | submgr | | e2term |
1520// +-------+ +---------+ +---------+
1521// | | |
1522// | [SUBS CREATE] |
1523// | | |
1524// | | |
1525// | SubDelReq | |
1526// |------------->| |
1527// | | |
1528// | | SubDelReq |
1529// | |------------->|
1530// | | |
1531// | | SubDelReq |
1532// | |------------->|
1533// | | |
1534// | | SubDelResp |
1535// | |<-------------|
1536// | | |
1537// | SubDelResp | |
1538// |<-------------| |
1539//
1540//-----------------------------------------------------------------------------
1541
1542func TestSubDelReqRetryInSubmgr(t *testing.T) {
1543
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001544 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001545
1546 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001547 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001548 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1549 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001550 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001551
1552 // Subs Delete
1553 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001554 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001555
1556 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001557 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001558
1559 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001560 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1561 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001562
1563 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001564 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001565
1566 // Wait that subs is cleaned
1567 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1568
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001569 xappConn1.TestMsgChanEmpty(t)
1570 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001571 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001572 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001573}
1574
1575//-----------------------------------------------------------------------------
1576// TestSubDelReqTwoRetriesNoRespInSubmgr
1577//
1578// stub stub
1579// +-------+ +---------+ +---------+
1580// | xapp | | submgr | | e2term |
1581// +-------+ +---------+ +---------+
1582// | | |
1583// | [SUBS CREATE] |
1584// | | |
1585// | | |
1586// | SubDelReq | |
1587// |------------->| |
1588// | | |
1589// | | SubDelReq |
1590// | |------------->|
1591// | | |
1592// | | SubDelReq |
1593// | |------------->|
1594// | | |
1595// | | |
1596// | SubDelResp | |
1597// |<-------------| |
1598//
1599//-----------------------------------------------------------------------------
1600
1601func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1602
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001603 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001604
1605 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001606 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001607 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1608 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001609 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001610
1611 // Subs Delete
1612 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001613 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001614
1615 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001616 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001617
1618 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001619 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001620
1621 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001622 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001623
1624 // Wait that subs is cleaned
1625 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1626
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001627 xappConn1.TestMsgChanEmpty(t)
1628 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001629 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001630 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001631}
1632
1633//-----------------------------------------------------------------------------
1634// TestSubDelReqSubDelFailRespInSubmgr
1635//
1636// stub stub
1637// +-------+ +---------+ +---------+
1638// | xapp | | submgr | | e2term |
1639// +-------+ +---------+ +---------+
1640// | | |
1641// | [SUBS CREATE] |
1642// | | |
1643// | | |
1644// | SubDelReq | |
1645// |------------->| |
1646// | | |
1647// | | SubDelReq |
1648// | |------------->|
1649// | | |
1650// | | SubDelFail |
1651// | |<-------------|
1652// | | |
1653// | SubDelResp | |
1654// |<-------------| |
1655// | | |
1656//
1657//-----------------------------------------------------------------------------
1658
1659func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001660 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001661
1662 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1663 Counter{cSubReqFromXapp, 1},
1664 Counter{cSubReqToE2, 1},
1665 Counter{cSubRespFromE2, 1},
1666 Counter{cSubRespToXapp, 1},
1667 Counter{cSubDelReqFromXapp, 1},
1668 Counter{cSubDelReqToE2, 1},
1669 Counter{cSubDelFailFromE2, 1},
1670 Counter{cSubDelRespToXapp, 1},
1671 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001672
1673 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001674 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001675 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1676 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001677 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001678
1679 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001680 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001681
1682 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001683 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1684 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001685
1686 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001687 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001688
1689 // Wait that subs is cleaned
1690 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1691
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001692 xappConn1.TestMsgChanEmpty(t)
1693 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001694 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001695 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001696
1697 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001698}
1699
1700//-----------------------------------------------------------------------------
1701// TestSubReqAndSubDelOkSameAction
1702//
1703// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001704// +-------+ +-------+ +---------+ +---------+
1705// | xapp2 | | xapp1 | | submgr | | e2term |
1706// +-------+ +-------+ +---------+ +---------+
1707// | | | |
1708// | | | |
1709// | | | |
1710// | | SubReq1 | |
1711// | |------------->| |
1712// | | | |
1713// | | | SubReq1 |
1714// | | |------------->|
1715// | | | SubResp1 |
1716// | | |<-------------|
1717// | | SubResp1 | |
1718// | |<-------------| |
1719// | | | |
1720// | SubReq2 | |
1721// |--------------------------->| |
1722// | | | |
1723// | SubResp2 | |
1724// |<---------------------------| |
1725// | | | |
1726// | | SubDelReq 1 | |
1727// | |------------->| |
1728// | | | |
1729// | | SubDelResp 1 | |
1730// | |<-------------| |
1731// | | | |
1732// | SubDelReq 2 | |
1733// |--------------------------->| |
1734// | | | |
1735// | | | SubDelReq 2 |
1736// | | |------------->|
1737// | | | |
1738// | | | SubDelReq 2 |
1739// | | |------------->|
1740// | | | |
1741// | SubDelResp 2 | |
1742// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001743//
1744//-----------------------------------------------------------------------------
1745func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001746 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001747
Anssi Mannila4abf1802021-01-28 13:06:46 +02001748 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1750 Counter{cSubReqFromXapp, 2},
1751 Counter{cSubReqToE2, 1},
1752 Counter{cSubRespFromE2, 1},
1753 Counter{cSubRespToXapp, 2},
1754 Counter{cMergedSubscriptions, 1},
1755 Counter{cUnmergedSubscriptions, 1},
1756 Counter{cSubDelReqFromXapp, 2},
1757 Counter{cSubDelReqToE2, 1},
1758 Counter{cSubDelRespFromE2, 1},
1759 Counter{cSubDelRespToXapp, 2},
1760 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001761
Juha Hyttinen3944a222020-01-24 11:51:46 +02001762 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001763 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001764 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001765 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001766 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1767 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001769
1770 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001771 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001772 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001773 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001774 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001775
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001776 resp, _ := xapp.Subscription.QuerySubscriptions()
1777 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1778 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001779 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001780
Juha Hyttinen3944a222020-01-24 11:51:46 +02001781 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001782 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001783 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001784
1785 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001786 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001787 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1788 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001789 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001790 //Wait that subs is cleaned
1791 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1792
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001793 xappConn1.TestMsgChanEmpty(t)
1794 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001795 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001796 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001797
1798 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001799}
1800
1801//-----------------------------------------------------------------------------
1802// TestSubReqAndSubDelOkSameActionParallel
1803//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001804// stub stub stub
1805// +-------+ +-------+ +---------+ +---------+
1806// | xapp2 | | xapp1 | | submgr | | e2term |
1807// +-------+ +-------+ +---------+ +---------+
1808// | | | |
1809// | | | |
1810// | | | |
1811// | | SubReq1 | |
1812// | |------------->| |
1813// | | | |
1814// | | | SubReq1 |
1815// | | |------------->|
1816// | SubReq2 | |
1817// |--------------------------->| |
1818// | | | SubResp1 |
1819// | | |<-------------|
1820// | | SubResp1 | |
1821// | |<-------------| |
1822// | | | |
1823// | SubResp2 | |
1824// |<---------------------------| |
1825// | | | |
1826// | | SubDelReq 1 | |
1827// | |------------->| |
1828// | | | |
1829// | | SubDelResp 1 | |
1830// | |<-------------| |
1831// | | | |
1832// | SubDelReq 2 | |
1833// |--------------------------->| |
1834// | | | |
1835// | | | SubDelReq 2 |
1836// | | |------------->|
1837// | | | |
1838// | | | SubDelReq 2 |
1839// | | |------------->|
1840// | | | |
1841// | SubDelResp 2 | |
1842// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001843//
1844//-----------------------------------------------------------------------------
1845func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001846 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001847
1848 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001849 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001850 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001851 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001852 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001853
1854 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001855 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001856 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001857 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001858
1859 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001860 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001861 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001862
1863 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001864 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001865
1866 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001867 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1868 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001869
1870 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001871 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001872 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1873 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001874 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001875
1876 //Wait that subs is cleaned
1877 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1878
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001879 xappConn1.TestMsgChanEmpty(t)
1880 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001881 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001882 mainCtrl.wait_registry_empty(t, 10)
1883}
1884
1885//-----------------------------------------------------------------------------
1886// TestSubReqAndSubDelNokSameActionParallel
1887//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001888// stub stub stub
1889// +-------+ +-------+ +---------+ +---------+
1890// | xapp2 | | xapp1 | | submgr | | e2term |
1891// +-------+ +-------+ +---------+ +---------+
1892// | | | |
1893// | | | |
1894// | | | |
1895// | | SubReq1 | |
1896// | |------------->| |
1897// | | | |
1898// | | | SubReq1 |
1899// | | |------------->|
1900// | SubReq2 | |
1901// |--------------------------->| |
1902// | | | SubFail1 |
1903// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001904// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001905// | | SubFail1 | |
1906// | |<-------------| |
1907// | | | |
1908// | SubFail2 | |
1909// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001910//
1911//-----------------------------------------------------------------------------
1912func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001913 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001914
1915 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001916 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001917 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001918 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001919
1920 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001921 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001922
1923 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001924 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001925 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001926 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001927 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001928 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001929
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001930 // E2t: send SubsFail (first)
1931 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1932 fparams1.Set(crereq1)
1933 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1934
Juha Hyttinen3944a222020-01-24 11:51:46 +02001935 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001936 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001937 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001938 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001939
1940 //Wait that subs is cleaned
1941 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1942
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001943 xappConn1.TestMsgChanEmpty(t)
1944 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001945 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001946 mainCtrl.wait_registry_empty(t, 10)
1947}
1948
1949//-----------------------------------------------------------------------------
1950// TestSubReqAndSubDelNoAnswerSameActionParallel
1951//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001952// stub stub stub
1953// +-------+ +-------+ +---------+ +---------+
1954// | xapp2 | | xapp1 | | submgr | | e2term |
1955// +-------+ +-------+ +---------+ +---------+
1956// | | | |
1957// | | | |
1958// | | | |
1959// | | SubReq1 | |
1960// | |------------->| |
1961// | | | |
1962// | | | SubReq1 |
1963// | | |------------->|
1964// | | SubReq2 | |
1965// |--------------------------->| |
1966// | | | |
1967// | | | SubReq1 |
1968// | | |------------->|
1969// | | | |
1970// | | | |
1971// | | | SubDelReq |
1972// | | |------------->|
1973// | | | |
1974// | | | SubDelResp |
1975// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001976//
1977//-----------------------------------------------------------------------------
1978func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001979 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001980
1981 //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 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001985
Juha Hyttinen1683f912020-04-17 10:39:57 +03001986 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001987
1988 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001989 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001990 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001991 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001992 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001993 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001994
1995 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001996 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001997
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001998 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1999 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002000
2001 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002002 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002003
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002004 xappConn1.TestMsgChanEmpty(t)
2005 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002006 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002007 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002008}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002009
2010//----------------------------- Policy cases ---------------------------------
2011//-----------------------------------------------------------------------------
2012// TestSubReqPolicyAndSubDelOk
2013//
2014// stub stub
2015// +-------+ +---------+ +---------+
2016// | xapp | | submgr | | e2term |
2017// +-------+ +---------+ +---------+
2018// | | |
2019// | SubReq | |
2020// |------------->| |
2021// | | |
2022// | | SubReq |
2023// | |------------->|
2024// | | |
2025// | | SubResp |
2026// | |<-------------|
2027// | | |
2028// | SubResp | |
2029// |<-------------| |
2030// | | |
2031// | | |
2032// | SubDelReq | |
2033// |------------->| |
2034// | | |
2035// | | SubDelReq |
2036// | |------------->|
2037// | | |
2038// | | SubDelResp |
2039// | |<-------------|
2040// | | |
2041// | SubDelResp | |
2042// |<-------------| |
2043//
2044//-----------------------------------------------------------------------------
2045func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2046 CaseBegin("TestSubReqAndSubDelOk")
2047
2048 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2049 rparams1.Init()
2050 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2051 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2052
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002053 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2054 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002055 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2056 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002057 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002058
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002059 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002060 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002061
2062 //Wait that subs is cleaned
2063 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2064
2065 xappConn1.TestMsgChanEmpty(t)
2066 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002067 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002068 mainCtrl.wait_registry_empty(t, 10)
2069}
2070
2071//-----------------------------------------------------------------------------
2072// TestSubReqPolicyChangeAndSubDelOk
2073//
2074// stub stub
2075// +-------+ +---------+ +---------+
2076// | xapp | | submgr | | e2term |
2077// +-------+ +---------+ +---------+
2078// | | |
2079// | SubReq | |
2080// |------------->| |
2081// | | |
2082// | | SubReq |
2083// | |------------->|
2084// | | |
2085// | | SubResp |
2086// | |<-------------|
2087// | | |
2088// | SubResp | |
2089// |<-------------| |
2090// | | |
2091// | SubReq | |
2092// |------------->| |
2093// | | |
2094// | | SubReq |
2095// | |------------->|
2096// | | |
2097// | | SubResp |
2098// | |<-------------|
2099// | | |
2100// | SubResp | |
2101// |<-------------| |
2102// | | |
2103// | SubDelReq | |
2104// |------------->| |
2105// | | |
2106// | | SubDelReq |
2107// | |------------->|
2108// | | |
2109// | | SubDelResp |
2110// | |<-------------|
2111// | | |
2112// | SubDelResp | |
2113// |<-------------| |
2114//
2115//-----------------------------------------------------------------------------
2116
2117func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2118 CaseBegin("TestSubReqAndSubDelOk")
2119
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002120 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2121 rparams1.Init()
2122 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2123 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002124
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002125 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2126 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002127 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2128
2129 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002130 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002131 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2132 xappConn1.SendSubsReq(t, rparams1, cretrans)
2133
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002134 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2135 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002136 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2137 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002138 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002139
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002140 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002141 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002142
2143 //Wait that subs is cleaned
2144 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2145
2146 xappConn1.TestMsgChanEmpty(t)
2147 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002148 e2termConn1.TestMsgChanEmpty(t)
2149 mainCtrl.wait_registry_empty(t, 10)
2150}
2151
2152//-----------------------------------------------------------------------------
2153// TestSubReqAndSubDelOkTwoE2termParallel
2154//
2155// stub stub stub
2156// +-------+ +---------+ +---------+ +---------+
2157// | xapp | | submgr | | e2term1 | | e2term2 |
2158// +-------+ +---------+ +---------+ +---------+
2159// | | | |
2160// | | | |
2161// | | | |
2162// | SubReq1 | | |
2163// |------------->| | |
2164// | | | |
2165// | | SubReq1 | |
2166// | |------------->| |
2167// | | | |
2168// | SubReq2 | | |
2169// |------------->| | |
2170// | | | |
2171// | | SubReq2 | |
2172// | |---------------------------->|
2173// | | | |
2174// | | SubResp1 | |
2175// | |<-------------| |
2176// | SubResp1 | | |
2177// |<-------------| | |
2178// | | SubResp2 | |
2179// | |<----------------------------|
2180// | SubResp2 | | |
2181// |<-------------| | |
2182// | | | |
2183// | [SUBS 1 DELETE] | |
2184// | | | |
2185// | [SUBS 2 DELETE] | |
2186// | | | |
2187//
2188//-----------------------------------------------------------------------------
2189func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2190 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2191
2192 //Req1
2193 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2194 xappConn1.SendSubsReq(t, nil, cretrans1)
2195 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2196
2197 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2198 xappConn1.SendSubsReq(t, nil, cretrans2)
2199 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2200
2201 //Resp1
2202 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2203 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2204
2205 //Resp2
2206 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2207 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2208
2209 //Del1
2210 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2211 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2212 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2213 xappConn1.RecvSubsDelResp(t, deltrans1)
2214 //Wait that subs is cleaned
2215 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2216
2217 //Del2
2218 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2219 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2220 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2221 xappConn1.RecvSubsDelResp(t, deltrans2)
2222 //Wait that subs is cleaned
2223 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2224
2225 xappConn1.TestMsgChanEmpty(t)
2226 xappConn2.TestMsgChanEmpty(t)
2227 e2termConn1.TestMsgChanEmpty(t)
2228 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002229 mainCtrl.wait_registry_empty(t, 10)
2230}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002231
2232//-----------------------------------------------------------------------------
2233// TestSubReqInsertAndSubDelOk
2234//
2235// stub stub
2236// +-------+ +---------+ +---------+
2237// | xapp | | submgr | | e2term |
2238// +-------+ +---------+ +---------+
2239// | | |
2240// | SubReq | |
2241// |------------->| |
2242// | | |
2243// | | SubReq |
2244// | |------------->|
2245// | | |
2246// | | SubResp |
2247// | |<-------------|
2248// | | |
2249// | SubResp | |
2250// |<-------------| |
2251// | | |
2252// | | |
2253// | SubDelReq | |
2254// |------------->| |
2255// | | |
2256// | | SubDelReq |
2257// | |------------->|
2258// | | |
2259// | | SubDelResp |
2260// | |<-------------|
2261// | | |
2262// | SubDelResp | |
2263// |<-------------| |
2264//
2265//-----------------------------------------------------------------------------
2266func TestSubReqInsertAndSubDelOk(t *testing.T) {
2267 CaseBegin("TestInsertSubReqAndSubDelOk")
2268
2269 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2270 rparams1.Init()
2271 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2272 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2273
2274 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2275 e2termConn1.SendSubsResp(t, crereq, cremsg)
2276 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2277 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2278 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2279
2280 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2281 xappConn1.RecvSubsDelResp(t, deltrans)
2282
2283 //Wait that subs is cleaned
2284 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2285
2286 xappConn1.TestMsgChanEmpty(t)
2287 xappConn2.TestMsgChanEmpty(t)
2288 e2termConn1.TestMsgChanEmpty(t)
2289 mainCtrl.wait_registry_empty(t, 10)
2290}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002291
2292//-----------------------------------------------------------------------------
2293// TestSubReqRetransmissionWithSameSubIdDiffXid
2294//
2295// This case simulates case where xApp restarts and starts sending same
2296// subscription requests which have already subscribed successfully
2297
2298// stub stub
2299// +-------+ +---------+ +---------+
2300// | xapp | | submgr | | e2term |
2301// +-------+ +---------+ +---------+
2302// | | |
2303// | SubReq | |
2304// |------------->| |
2305// | | |
2306// | | SubReq |
2307// | |------------->|
2308// | | |
2309// | | SubResp |
2310// | |<-------------|
2311// | | |
2312// | SubResp | |
2313// |<-------------| |
2314// | | |
2315// | xApp restart | |
2316// | | |
2317// | SubReq | |
2318// | (retrans with same xApp generated subid but diff xid)
2319// |------------->| |
2320// | | |
2321// | SubResp | |
2322// |<-------------| |
2323// | | |
2324// | [SUBS DELETE] |
2325// | | |
2326//
2327//-----------------------------------------------------------------------------
2328func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2329 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2330
2331 //Subs Create
2332 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2333 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2334 e2termConn1.SendSubsResp(t, crereq, cremsg)
2335 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2336
2337 // xApp restart here
2338 // --> artificial delay
2339 <-time.After(1 * time.Second)
2340
2341 //Subs Create
2342 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2343 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2344
2345 //Subs Delete
2346 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2347 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2348 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2349 xappConn1.RecvSubsDelResp(t, deltrans)
2350
2351 //Wait that subs is cleaned
2352 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2353
2354 xappConn1.TestMsgChanEmpty(t)
2355 xappConn2.TestMsgChanEmpty(t)
2356 e2termConn1.TestMsgChanEmpty(t)
2357 mainCtrl.wait_registry_empty(t, 10)
2358}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002359
2360//-----------------------------------------------------------------------------
2361// TestSubReqNokAndSubDelOkWithRestartInMiddle
2362//
2363// stub stub
2364// +-------+ +---------+ +---------+
2365// | xapp | | submgr | | e2term |
2366// +-------+ +---------+ +---------+
2367// | | |
2368// | SubReq | |
2369// |------------->| |
2370// | | |
2371// | | SubReq |
2372// | |------------->|
2373// | | |
2374// | | SubResp |
2375// | <----|
2376// | |
2377// | Submgr restart |
2378// | |
2379// | | |
2380// | | SubDelReq |
2381// | |------------->|
2382// | | |
2383// | | SubDelResp |
2384// | |<-------------|
2385// | | |
2386//
2387//-----------------------------------------------------------------------------
2388
2389func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2390 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2391
Anssi Mannilac92b4212020-12-07 14:59:34 +02002392 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2393 xappConn1.SendSubsReq(t, nil, nil)
2394 e2termConn1.RecvSubsReq(t)
2395 mainCtrl.SetResetTestFlag(t, false)
2396
2397 resp, _ := xapp.Subscription.QuerySubscriptions()
2398 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002399 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002400 e2SubsId := uint32(resp[0].SubscriptionID)
2401 t.Logf("e2SubsId = %v", e2SubsId)
2402
archaggeafbf95f2021-04-14 08:54:05 +03002403 mainCtrl.SimulateRestart(t)
2404 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002405
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002406 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002407 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2408 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2409
2410 // Wait that subs is cleaned
2411 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2412
2413 xappConn1.TestMsgChanEmpty(t)
2414 xappConn2.TestMsgChanEmpty(t)
2415 e2termConn1.TestMsgChanEmpty(t)
2416 mainCtrl.wait_registry_empty(t, 10)
2417}
2418
2419//-----------------------------------------------------------------------------
2420// TestSubReqAndSubDelOkWithRestartInMiddle
2421//
2422// stub stub
2423// +-------+ +---------+ +---------+
2424// | xapp | | submgr | | e2term |
2425// +-------+ +---------+ +---------+
2426// | | |
2427// | SubReq | |
2428// |------------->| |
2429// | | |
2430// | | SubReq |
2431// | |------------->|
2432// | | |
2433// | | SubResp |
2434// | |<-------------|
2435// | | |
2436// | SubResp | |
2437// |<-------------| |
2438// | | |
2439// | |
2440// | Submgr restart |
2441// | |
2442// | SubDelReq | |
2443// |------------->| |
2444// | | |
2445// | | SubDelReq |
2446// | |------------->|
2447// | | |
2448// | | SubDelResp |
2449// | |<-------------|
2450// | | |
2451// | SubDelResp | |
2452// |<-------------| |
2453//
2454//-----------------------------------------------------------------------------
2455
2456func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2457 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2458
2459 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2460 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2461 e2termConn1.SendSubsResp(t, crereq, cremsg)
2462 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2463
2464 // Check subscription
2465 resp, _ := xapp.Subscription.QuerySubscriptions()
2466 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2467 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002468 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002469
2470 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002471 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002472
Anssi Mannila54838ed2021-11-19 11:25:01 +02002473 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2474 // That needs to be completed before successful subscription query is possible
2475 <-time.After(time.Second * 1)
2476
Anssi Mannilac92b4212020-12-07 14:59:34 +02002477 // Check that subscription is restored correctly after restart
2478 resp, _ = xapp.Subscription.QuerySubscriptions()
2479 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2480 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002481 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002482
2483 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2484 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2485 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2486 xappConn1.RecvSubsDelResp(t, deltrans)
2487
2488 //Wait that subs is cleaned
2489 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2490
2491 xappConn1.TestMsgChanEmpty(t)
2492 xappConn2.TestMsgChanEmpty(t)
2493 e2termConn1.TestMsgChanEmpty(t)
2494 mainCtrl.wait_registry_empty(t, 10)
2495}
2496
2497//-----------------------------------------------------------------------------
2498// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2499//
2500// stub stub
2501// +-------+ +-------+ +---------+ +---------+
2502// | xapp2 | | xapp1 | | submgr | | e2term |
2503// +-------+ +-------+ +---------+ +---------+
2504// | | | |
2505// | | | |
2506// | | | |
2507// | | SubReq1 | |
2508// | |------------->| |
2509// | | | |
2510// | | | SubReq1 |
2511// | | |------------->|
2512// | | | SubResp1 |
2513// | | |<-------------|
2514// | | SubResp1 | |
2515// | |<-------------| |
2516// | | | |
2517// | |
2518// | submgr restart |
2519// | |
2520// | | | |
2521// | | | |
2522// | SubReq2 | |
2523// |--------------------------->| |
2524// | | | |
2525// | SubResp2 | |
2526// |<---------------------------| |
2527// | | | |
2528// | | SubDelReq 1 | |
2529// | |------------->| |
2530// | | | |
2531// | | SubDelResp 1 | |
2532// | |<-------------| |
2533// | | | |
2534// | | | |
2535// | |
2536// | submgr restart |
2537// | |
2538// | | | |
2539// | SubDelReq 2 | |
2540// |--------------------------->| |
2541// | | | |
2542// | | | SubDelReq 2 |
2543// | | |------------->|
2544// | | | |
2545// | | | SubDelReq 2 |
2546// | | |------------->|
2547// | | | |
2548// | SubDelResp 2 | |
2549// |<---------------------------| |
2550//
2551//-----------------------------------------------------------------------------
2552
2553func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2554 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2555
2556 //Req1
2557 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2558 rparams1.Init()
2559 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2560 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2561 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2562 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2563
2564 //Req2
2565 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2566 rparams2.Init()
2567 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2568 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2569
2570 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002571 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002572 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2573 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002574 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002575
2576 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002577 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002578
Anssi Mannila54838ed2021-11-19 11:25:01 +02002579 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2580 // That needs to be completed before successful subscription query is possible
2581 <-time.After(time.Second * 1)
2582
Anssi Mannilac92b4212020-12-07 14:59:34 +02002583 // Check that subscription is restored correctly after restart
2584 resp, _ = xapp.Subscription.QuerySubscriptions()
2585 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2586 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002587 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002588
2589 //Del1
2590 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2591 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2592 xappConn1.RecvSubsDelResp(t, deltrans1)
2593 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2594
2595 mainCtrl.SimulateRestart(t)
2596 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2597
Anssi Mannila54838ed2021-11-19 11:25:01 +02002598 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2599 // Submgr need be ready before successful subscription deletion is possible
2600 <-time.After(time.Second * 1)
2601
Anssi Mannilac92b4212020-12-07 14:59:34 +02002602 //Del2
2603 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2604 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2605
2606 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2607 xappConn2.RecvSubsDelResp(t, deltrans2)
2608
2609 //Wait that subs is cleaned
2610 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2611
2612 xappConn1.TestMsgChanEmpty(t)
2613 xappConn2.TestMsgChanEmpty(t)
2614 e2termConn1.TestMsgChanEmpty(t)
2615 mainCtrl.wait_registry_empty(t, 10)
2616}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002617
archaggeafbf95f2021-04-14 08:54:05 +03002618//*****************************************************************************
2619// REST interface test cases
2620//*****************************************************************************
2621
Anssi Mannila47518ae2021-04-16 09:27:07 +03002622//-----------------------------------------------------------------------------
2623// Test debug GET and POST requests
2624//
2625// curl
2626// +-------+ +---------+
2627// | user | | submgr |
2628// +-------+ +---------+
2629// | |
2630// | GET/POST Req |
2631// |------------->|
2632// | Resp |
2633// |<-------------|
2634// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002635func TestGetSubscriptions(t *testing.T) {
2636
Anssi Mannila92c38552021-12-29 09:59:24 +02002637 mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002638}
2639
2640func TestGetSymptomData(t *testing.T) {
2641
Anssi Mannila92c38552021-12-29 09:59:24 +02002642 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002643}
2644
2645func TestPostdeleteSubId(t *testing.T) {
2646
Anssi Mannila92c38552021-12-29 09:59:24 +02002647 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002648}
2649
2650func TestPostEmptyDb(t *testing.T) {
2651
Anssi Mannila92c38552021-12-29 09:59:24 +02002652 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002653}
archaggeafbf95f2021-04-14 08:54:05 +03002654
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002655func TestGetRestSubscriptions(t *testing.T) {
2656
Anssi Mannila92c38552021-12-29 09:59:24 +02002657 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2658}
2659
2660//-----------------------------------------------------------------------------
2661// TestDelAllE2nodeSubsViaDebugIf
2662//
2663// stub stub stub
2664// +-------+ +---------+ +---------+ +---------+
2665// | xapp | | submgr | | e2term | | rtmgr |
2666// +-------+ +---------+ +---------+ +---------+
2667// | | | |
2668// | RESTSubReq | | |
2669// |---------------->| | |
2670// | RESTSubResp | | |
2671// |<----------------| | |
2672// | | RouteCreate | |
2673// | |--------------------------->|
2674// | | RouteResponse| |
2675// | |<---------------------------|
2676// | | SubReq | |
2677// | |------------->| |
2678// | | SubResp | |
2679// | |<-------------| |
2680// | RESTNotif1 | | |
2681// |<----------------| | |
2682// | | | |
2683// | REST get_all_e2nodes | |
2684// |---------------->| | |
2685// | OK 200 | | |
2686// |<----------------| | |
2687// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1
2688// |---------------->| | |
2689// | OK 200 | | |
2690// |<----------------| | |
2691// | | SubDelReq | |
2692// | |------------->| |
2693// | | SubDelResp | |
2694// | |<-------------| |
2695// | | | |
2696// | | RouteDelete | |
2697// | |--------------------------->|
2698// | | RouteResponse| |
2699// | |<---------------------------|
2700//
2701//-----------------------------------------------------------------------------
2702
2703func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
2704
2705 // Init counter check
2706 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2707 Counter{cRestSubReqFromXapp, 1},
2708 Counter{cRestSubRespToXapp, 1},
2709 Counter{cSubReqToE2, 1},
2710 Counter{cSubRespFromE2, 1},
2711 Counter{cRestSubNotifToXapp, 1},
2712 Counter{cRestSubDelReqFromXapp, 1},
2713 Counter{cSubDelReqToE2, 1},
2714 Counter{cSubDelRespFromE2, 1},
2715 Counter{cRestSubDelRespToXapp, 1},
2716 })
2717
2718 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2719 restSubId := xappConn1.SendRESTSubsReq(t, params)
2720 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2721
2722 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2723 xappConn1.ExpectRESTNotification(t, restSubId)
2724 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2725 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2726 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2727
2728 e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes")
2729
2730 var e2nodesList []string
2731 err := json.Unmarshal(e2nodesJson, &e2nodesList)
2732 if err != nil {
2733 t.Errorf("Unmarshal error: %s", err)
2734 }
2735 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList))
2736
2737 e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2738 var e2RestSubsMap map[string]RESTSubscription
2739 err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap)
2740 if err != nil {
2741 t.Errorf("Unmarshal error: %s", err)
2742 }
2743
2744 if len(e2RestSubsMap) != 1 {
2745 t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap))
2746 }
2747
2748 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002749 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 +02002750 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2751 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2752
2753 // Wait that subs is cleaned
2754 waitSubsCleanup(t, e2SubsId, 10)
2755 mainCtrl.VerifyCounterValues(t)
2756 mainCtrl.VerifyAllClean(t)
2757}
2758
2759//-----------------------------------------------------------------------------
2760// TestDelAllxAppSubsViaDebugIf
2761//
2762// stub stub stub
2763// +-------+ +---------+ +---------+ +---------+
2764// | xapp | | submgr | | e2term | | rtmgr |
2765// +-------+ +---------+ +---------+ +---------+
2766// | | | |
2767// | RESTSubReq | | |
2768// |---------------->| | |
2769// | RESTSubResp | | |
2770// |<----------------| | |
2771// | | RouteCreate | |
2772// | |--------------------------->|
2773// | | RouteResponse| |
2774// | |<---------------------------|
2775// | | SubReq | |
2776// | |------------->| |
2777// | | SubResp | |
2778// | |<-------------| |
2779// | RESTNotif1 | | |
2780// |<----------------| | |
2781// | | | |
2782// | REST get_all_xapps | |
2783// |---------------->| | |
2784// | OK 200 | | |
2785// |<----------------| | |
2786// | REST delete_all_xapp_subscriptions | xappServiceName = localhost
2787// |---------------->| | |
2788// | OK 200 | | |
2789// |<----------------| | |
2790// | | SubDelReq | |
2791// | |------------->| |
2792// | | SubDelResp | |
2793// | |<-------------| |
2794// | | | |
2795// | | RouteDelete | |
2796// | |--------------------------->|
2797// | | RouteResponse| |
2798// | |<---------------------------|
2799//
2800//-----------------------------------------------------------------------------
2801
2802func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
2803
2804 // Init counter check
2805 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2806 Counter{cRestSubReqFromXapp, 1},
2807 Counter{cRestSubRespToXapp, 1},
2808 Counter{cSubReqToE2, 1},
2809 Counter{cSubRespFromE2, 1},
2810 Counter{cRestSubNotifToXapp, 1},
2811 Counter{cRestSubDelReqFromXapp, 1},
2812 Counter{cSubDelReqToE2, 1},
2813 Counter{cSubDelRespFromE2, 1},
2814 Counter{cRestSubDelRespToXapp, 1},
2815 })
2816
2817 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2818 restSubId := xappConn1.SendRESTSubsReq(t, params)
2819 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2820
2821 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2822 xappConn1.ExpectRESTNotification(t, restSubId)
2823 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2824 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2825 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2826
2827 xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps")
2828
2829 var xappList []string
2830 err := json.Unmarshal(xappsJson, &xappList)
2831 if err != nil {
2832 t.Errorf("Unmarshal error: %s", err)
2833 }
2834 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
2835
2836 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002837 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
Anssi Mannila92c38552021-12-29 09:59:24 +02002838 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2839 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2840
2841 // Wait that subs is cleaned
2842 waitSubsCleanup(t, e2SubsId, 10)
2843 mainCtrl.VerifyCounterValues(t)
2844 mainCtrl.VerifyAllClean(t)
2845}
2846
2847//-----------------------------------------------------------------------------
2848// TestDelViaxAppSubsIf
2849//
2850// stub stub stub
2851// +-------+ +---------+ +---------+ +---------+
2852// | xapp | | submgr | | e2term | | rtmgr |
2853// +-------+ +---------+ +---------+ +---------+
2854// | | | |
2855// | RESTSubReq | | |
2856// |---------------->| | |
2857// | RESTSubResp | | |
2858// |<----------------| | |
2859// | | RouteCreate | |
2860// | |--------------------------->|
2861// | | RouteResponse| |
2862// | |<---------------------------|
2863// | | SubReq | |
2864// | |------------->| |
2865// | | SubResp | |
2866// | |<-------------| |
2867// | RESTNotif1 | | |
2868// |<----------------| | |
2869// | | | |
2870// | REST get_xapp_rest_restsubscriptions |
2871// |---------------->| | |
2872// | OK 200 | | |
2873// |<----------------| | |
2874// | RESTSudDel | | |
2875// |---------------->| | | Via user curl command (port 8088)
2876// | RESTSudDel | | |
2877// |<----------------| | |
2878// | | SubDelReq | |
2879// | |------------->| |
2880// | | SubDelResp | |
2881// | |<-------------| |
2882// | | | |
2883// | | RouteDelete | |
2884// | |--------------------------->|
2885// | | RouteResponse| |
2886// | |<---------------------------|
2887//
2888//-----------------------------------------------------------------------------
2889
2890func TestDelViaxAppSubsIf(t *testing.T) {
2891
2892 // Init counter check
2893 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2894 Counter{cRestSubReqFromXapp, 1},
2895 Counter{cRestSubRespToXapp, 1},
2896 Counter{cSubReqToE2, 1},
2897 Counter{cSubRespFromE2, 1},
2898 Counter{cRestSubNotifToXapp, 1},
2899 Counter{cRestSubDelReqFromXapp, 1},
2900 Counter{cSubDelReqToE2, 1},
2901 Counter{cSubDelRespFromE2, 1},
2902 Counter{cRestSubDelRespToXapp, 1},
2903 })
2904
2905 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2906 restSubId := xappConn1.SendRESTSubsReq(t, params)
2907 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2908
2909 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2910 xappConn1.ExpectRESTNotification(t, restSubId)
2911 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2912 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2913 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2914
2915 restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName
2916
2917 var restSubsMap map[string]RESTSubscription
2918 err := json.Unmarshal(restSubsListJson, &restSubsMap)
2919 if err != nil {
2920 t.Errorf("Unmarshal error: %s", err)
2921 }
2922 _, ok := restSubsMap[restSubId]
2923 if !ok {
2924 t.Errorf("REST subscription not found. restSubId=%s", restSubId)
2925 }
2926
2927 var e2Subscriptions []Subscription
2928 e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId)
2929 err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions)
2930 if err != nil {
2931 t.Errorf("Unmarshal error: %s", err)
2932 }
2933 if len(e2Subscriptions) != 1 {
2934 t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions))
2935 }
2936
2937 // Simulate deletion through xapp REST test interface
2938 mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId)
2939 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2940 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2941
2942 // Wait that subs is cleaned
2943 waitSubsCleanup(t, e2SubsId, 10)
2944 mainCtrl.VerifyCounterValues(t)
2945 mainCtrl.VerifyAllClean(t)
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002946}
2947
archaggeafbf95f2021-04-14 08:54:05 +03002948//-----------------------------------------------------------------------------
2949// TestRESTSubReqAndRouteNok
2950//
2951// stub stub
2952// +-------+ +---------+ +---------+
2953// | xapp | | submgr | | rtmgr |
2954// +-------+ +---------+ +---------+
2955// | | |
2956// | RESTSubReq | |
2957// |---------------->| |
2958// | | |
2959// | RESTSubResp | |
2960// |<----------------| |
2961// | | RouteCreate |
2962// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03002963// | | RouteCreate |
2964// | | status:400 |
2965// | |(Bad request) |
2966// | |<-------------|
2967// | RESTNotif | |
2968// |<----------------| |
2969// | | |
2970// | [SUBS INT DELETE] |
2971// | | |
2972// | RESTSubDelReq | |
2973// |---------------->| |
2974// | RESTSubDelResp | |
2975// |<----------------| |
2976//
2977//-----------------------------------------------------------------------------
2978func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002979
2980 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002981 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002982 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002983 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002984 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002985 Counter{cRestSubDelReqFromXapp, 1},
2986 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002987 })
2988
2989 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002990
Markku Virtanenda34eec2021-05-20 08:22:04 +00002991 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2992 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002993 newSubsId := mainCtrl.get_registry_next_subid(t)
2994
2995 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002996 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002997 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002998 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002999 waiter.WaitResult(t)
3000
archaggeafbf95f2021-04-14 08:54:05 +03003001 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003002 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003003
3004 // Del
3005 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3006
3007 // Wait that subs is cleaned
3008 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3009 waitSubsCleanup(t, e2SubsId, 10)
3010 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003011 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003012}
3013
Anssi Mannila27385172021-12-22 09:41:54 +02003014//-----------------------------------------------------------------------------
3015// TestRESTSubReqAndRouteUpdateNok
3016//
3017// stub stub stub stub
3018// +-------+ +-------+ +---------+ +---------+ +---------+
3019// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3020// +-------+ +-------+ +---------+ +---------+ +---------+
3021// | | | | |
3022// | RESTSubReq1 | | |
3023// |------------------------>| | |
3024// | RESTSubResp2 | | |
3025// |<------------------------| | |
3026// | | | | |
3027// | | | RouteCreate | |
3028// | | |------------->| |
3029// | | | CreateResp | |
3030// | | |<-------------| |
3031// | | | SubReq | |
3032// | | |---------------------------->|
3033// | | | SubResp | |
3034// | | |<----------------------------|
3035// | RESTNotif1 | | |
3036// |<------------------------| | |
3037// | | | | |
3038// | | RESTSubReq2 | | |
3039// | |------------>| | |
3040// | | RESTSubResp2| | |
3041// | |<------------| | |
3042// | | | RouteUpdate | |
3043// | | |------------->| |
3044// | | | RouteUpdate | |
3045// | | | status:400 | |
3046// | | |(Bad request) | |
3047// | | |<-------------| |
3048// | | RESTNotif2(unsuccessful) | |
3049// | |<------------| | |
3050// | | | | |
3051// | [SUBS INT DELETE] | |
3052// | | | | |
3053// | RESTSubDelReq1 | | |
3054// |------------------------>| | |
3055// | RESTSubDelResp1 | | |
3056// |<------------------------| | |
3057// | | | | |
3058// | | | [SUBS DELETE] |
3059//
3060//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003061func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003062
3063 //Init counter check
3064 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003065 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003066 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003067 Counter{cSubReqToE2, 1},
3068 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003069 Counter{cRestSubNotifToXapp, 1},
3070 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003071 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003072 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003073 Counter{cSubDelReqToE2, 1},
3074 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003075 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003076 })
3077
3078 var params *teststube2ap.RESTSubsReqParams = nil
3079
Anssi Mannila27385172021-12-22 09:41:54 +02003080 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03003081 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3082
3083 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3084
3085 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
3086 waiter := rtmgrHttp.AllocNextEvent(false)
3087 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003088 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003089 params.SetMeid("RAN_NAME_1")
3090 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003091 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003092 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003093 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003094 xappConn2.WaitRESTNotification(t, restSubId2)
3095
3096 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3097
3098 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003099 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003100
3101 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3102 //Wait that subs is cleaned
3103 waitSubsCleanup(t, e2SubsId, 10)
3104
3105 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003106 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003107}
3108
Anssi Mannila27385172021-12-22 09:41:54 +02003109//-----------------------------------------------------------------------------
3110// TestRESTSubDelReqAndRouteDeleteNok
3111//
3112// stub stub stub
3113// +-------+ +---------+ +---------+ +---------+
3114// | xapp | | submgr | | rtmgr | | e2term |
3115// +-------+ +---------+ +---------+ +---------+
3116// | | | |
3117// | RESTSubReq | | |
3118// |---------------->| | |
3119// | | | |
3120// | RESTSubResp | | |
3121// |<----------------| | |
3122// | | SubReq | |
3123// | |---------------------------->|
3124// | | SubResp | |
3125// | |<----------------------------|
3126// | RESTNotif | | |
3127// |<----------------| | |
3128// | | | |
3129// | | | |
3130// | RESTSubDelReq | | |
3131// |---------------->| | |
3132// | RESTSubDelResp | | |
3133// |<----------------| | |
3134// | | SubSelReq | |
3135// | |---------------------------->|
3136// | | SubSelResp | |
3137// | |<----------------------------|
3138// | | RouteDelete | |
3139// | |------------->| |
3140// | | Routedelete | |
3141// | | status:400 | |
3142// | |(Bad request) | |
3143// | |<-------------| |
3144//
3145//-----------------------------------------------------------------------------
3146
archaggeafbf95f2021-04-14 08:54:05 +03003147func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003148
3149 // Init counter check
3150 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003151 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003152 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003153 Counter{cSubReqToE2, 1},
3154 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003155 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003156 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003157 Counter{cRouteDeleteFail, 1},
3158 Counter{cSubDelReqToE2, 1},
3159 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003160 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003161 })
3162
3163 var params *teststube2ap.RESTSubsReqParams = nil
3164
3165 //Subs Create
3166 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3167
3168 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3169
3170 waiter := rtmgrHttp.AllocNextEvent(false)
3171 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3172 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3173 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3174 waiter.WaitResult(t)
3175
3176 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003177 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003178 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003179}
3180
Anssi Mannila27385172021-12-22 09:41:54 +02003181//-----------------------------------------------------------------------------
3182// TestRESTSubMergeDelAndRouteUpdateNok
3183//
3184// stub stub stub stub
3185// +-------+ +-------+ +---------+ +---------+ +---------+
3186// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3187// +-------+ +-------+ +---------+ +---------+ +---------+
3188// | | | | |
3189// | RESTSubReq1 | | |
3190// |------------------------>| | |
3191// | RESTSubResp2 | | |
3192// |<------------------------| | |
3193// | | | | |
3194// | | | RouteCreate | |
3195// | | |------------->| |
3196// | | | CreateResp | |
3197// | | |<-------------| |
3198// | | | SubReq | |
3199// | | |---------------------------->|
3200// | | | SubResp | |
3201// | | |<----------------------------|
3202// | RESTNotif1 | | |
3203// |<------------------------| | |
3204// | | | | |
3205// | | RESTSubReq2 | | |
3206// | |------------>| | |
3207// | | RESTSubResp2| | |
3208// | |<------------| | |
3209// | | | RouteCreate | |
3210// | | |------------->| |
3211// | | | CreateResp | |
3212// | | |<-------------| |
3213// | | | SubReq | |
3214// | | |---------------------------->|
3215// | | | SubResp | |
3216// | | |<----------------------------|
3217// | | RESTNotif2 | | |
3218// | |<------------| | |
3219// | | | | |
3220// | [SUBS INT DELETE] | |
3221// | | | | |
3222// | RESTSubDelReq1 | | |
3223// |------------------------>| | |
3224// | RESTSubDelResp1 | | |
3225// |<------------------------| | |
3226// | | | SubDelReq | |
3227// | | |---------------------------->|
3228// | | | SubDelResp | |
3229// | | |<----------------------------|
3230// | | | RouteUpdate | |
3231// | | |------------->| |
3232// | | | RouteUpdate | |
3233// | | | status:400 | |
3234// | | |(Bad request) | |
3235// | | |<-------------| |
3236// | | | | |
3237// | | RESTSubDelReq2 | |
3238// | |------------>| | |
3239// | | RESTSubDelResp2 | |
3240// | |<------------| | |
3241// | | | SubDelReq | |
3242// | | |---------------------------->|
3243// | | | SubdelResp | |
3244// | | |<----------------------------|
3245// | | | RouteDelete | |
3246// | | |------------->| |
3247// | | | Deleteresp | |
3248// | | |<-------------| |
3249
3250//-----------------------------------------------------------------------------
3251
archaggeafbf95f2021-04-14 08:54:05 +03003252func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003253
3254 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003255 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003256 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003257 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003258 Counter{cSubReqToE2, 1},
3259 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003260 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003261 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003262 Counter{cRouteDeleteUpdateFail, 1},
3263 Counter{cSubDelReqToE2, 1},
3264 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003265 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003266 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003267 })
3268
3269 var params *teststube2ap.RESTSubsReqParams = nil
3270
3271 //Subs Create
3272 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3273
3274 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3275 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
3276
3277 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3278
3279 //Del1, this shall fail on rtmgr side
3280 waiter := rtmgrHttp.AllocNextEvent(false)
3281 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3282 waiter.WaitResult(t)
3283
3284 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
3285
3286 //Del2
3287 deleteXapp2Subscription(t, &restSubId2)
3288
3289 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003290 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003291 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003292}
3293
3294//-----------------------------------------------------------------------------
3295// TestRESTSubReqRetransmission
3296//
3297// stub stub
3298// +-------+ +---------+ +---------+
3299// | xapp | | submgr | | e2term |
3300// +-------+ +---------+ +---------+
3301// | | |
3302// | RESTSubReq1 | |
3303// |---------------->| |
3304// | | |
3305// | RESTSubResp | |
3306// |<----------------| |
3307// | | SubReq1 |
3308// | |------------->|
3309// | | |
3310// | RESTSubReq2 | |
3311// | (retrans) | |
3312// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003313// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003314// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003315// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003316// | | SubResp1 |
3317// | |<-------------|
3318// | RESTNotif1 | |
3319// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003320// | | |
3321// | [SUBS DELETE] |
3322// | | |
3323//
3324//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003325
archaggeafbf95f2021-04-14 08:54:05 +03003326func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003327
3328 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003329 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003330 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003331 Counter{cSubReqToE2, 1},
3332 Counter{cSubRespFromE2, 1},
3333 Counter{cRestSubNotifToXapp, 1},
3334 Counter{cRestSubDelReqFromXapp, 1},
3335 Counter{cSubDelReqToE2, 1},
3336 Counter{cSubDelRespFromE2, 1},
3337 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003338 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003339 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003340 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3341 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3342
3343 // Subs Create
3344 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003345
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003346 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003347 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003348
Anssi Mannilab43397e2021-11-16 12:06:16 +02003349 xappConn1.SendRESTSubsReq(t, params)
3350 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003351
Anssi Mannilab43397e2021-11-16 12:06:16 +02003352 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003353
3354 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003355 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003356 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3357 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003358
Anssi Mannilab43397e2021-11-16 12:06:16 +02003359 e2SubsId := <-xappConn1.ListedRESTNotifications
3360
3361 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003362
3363 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003364 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003365 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3366 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3367
Anssi Mannilab43397e2021-11-16 12:06:16 +02003368 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003369
3370 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003371 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003372}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003373
Markku Virtanen42723e22021-06-15 10:09:23 +03003374//-----------------------------------------------------------------------------
3375// stub stub stub
3376// +-------+ +---------+ +---------+ +---------+
3377// | xapp | | submgr | | e2term | | rtmgr |
3378// +-------+ +---------+ +---------+ +---------+
3379// | | | |
3380// | RESTSubReq | | |
3381// |---------------->| | |
3382// | RESTSubResp | | |
3383// |<----------------| | |
3384// | | RouteCreate | |
3385// | |--------------------------->|
3386// | | RouteResponse| |
3387// | |<---------------------------| // The order of these events may vary
3388// | | SubReq | |
3389// | |------------->| | // The order of these events may vary
3390// | | SubResp | |
3391// | |<-------------| |
3392// | RESTNotif1 | | |
3393// |<----------------| | |
3394// | RESTSubReq | | |
3395// | [RETRANS1] | | |
3396// |---------------->| | |
3397// | RESTNotif1 | | |
3398// |<----------------| | |
3399// | RESTSubReq | | |
3400// | [RETRANS2] | | |
3401// |---------------->| | |
3402// | RESTNotif1 | | |
3403// |<----------------| | |
3404// | RESTSubDelReq | | |
3405// |---------------->| | |
3406// | | SubDelReq | |
3407// | |------------->| |
3408// | RESTSubDelResp| | |
3409// |<----------------| | |
3410// | | SubDelResp | |
3411// | |<-------------| |
3412// | | | |
3413//
3414//-----------------------------------------------------------------------------
3415
3416func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003417
3418 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3419 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003420 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003421 Counter{cRestSubRespToXapp, 3},
3422 Counter{cSubReqToE2, 1},
3423 Counter{cSubRespFromE2, 1},
3424 Counter{cRestSubNotifToXapp, 3},
3425 Counter{cRestSubDelReqFromXapp, 1},
3426 Counter{cSubDelReqToE2, 1},
3427 Counter{cSubDelRespFromE2, 1},
3428 Counter{cRestSubDelRespToXapp, 1},
3429 })
3430
3431 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3432
3433 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3434
3435 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3436
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003437 mainCtrl.WaitOngoingRequestMapEmpty()
3438
Markku Virtanen42723e22021-06-15 10:09:23 +03003439 //1.st resend
3440 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3441
3442 assert.Equal(t, restSubId_resend, restSubId)
3443
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003444 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003445
3446 //2.nd resend
3447 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3448
3449 assert.Equal(t, restSubId_resend2, restSubId)
3450
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003451 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003452
3453 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3454
3455 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003456 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003457 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003458}
3459
3460//-----------------------------------------------------------------------------
3461// stub stub stub
3462// +-------+ +---------+ +---------+ +---------+
3463// | xapp | | submgr | | e2term | | rtmgr |
3464// +-------+ +---------+ +---------+ +---------+
3465// | | | |
3466// | RESTSubReq | | |
3467// |---------------->| | |
3468// | RESTSubResp | | |
3469// |<----------------| | |
3470// | | RouteCreate | |
3471// | |--------------------------->|
3472// | | RouteResponse| |
3473// | |<---------------------------| // The order of these events may vary
3474// | | SubReq | |
3475// | |------------->| | // The order of these events may vary
3476// | | SubResp | |
3477// | |<-------------| |
3478// | RESTNotif1 | | |
3479// |<----------------| | |
3480// | RESTSubReq | | |
3481// | [RETRANS, with RESTsubsId] | |
3482// |---------------->| | |
3483// | RESTNotif1 | | |
3484// |<----------------| | |
3485// | RESTSubReq | | |
3486// | [RETRANS, without RESTsubsId] | |
3487// |---------------->| | |
3488// | RESTNotif1 | | |
3489// |<----------------| | |
3490// | RESTSubDelReq | | |
3491// |---------------->| | |
3492// | | SubDelReq | |
3493// | |------------->| |
3494// | RESTSubDelResp| | |
3495// |<----------------| | |
3496// | | SubDelResp | |
3497// | |<-------------| |
3498// | | | |
3499//
3500//-----------------------------------------------------------------------------
3501func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003502
3503 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3504 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003505 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003506 Counter{cRestSubRespToXapp, 3},
3507 Counter{cSubReqToE2, 1},
3508 Counter{cSubRespFromE2, 1},
3509 Counter{cRestSubNotifToXapp, 3},
3510 Counter{cRestSubDelReqFromXapp, 1},
3511 Counter{cSubDelReqToE2, 1},
3512 Counter{cSubDelRespFromE2, 1},
3513 Counter{cRestSubDelRespToXapp, 1},
3514 })
3515
3516 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3517
3518 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3519
3520 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3521
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003522 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003523
3524 //1.st resend with subscription ID
3525 params.SetSubscriptionID(&restSubId)
3526 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3527
3528 assert.Equal(t, restSubId_resend, restSubId)
3529
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003530 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003531
3532 //2.nd resend without subscription ID (faking app restart)
3533 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3534 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3535
3536 assert.Equal(t, restSubId_resend2, restSubId)
3537
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003538 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003539
3540 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3541
3542 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003543 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003544 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003545}
3546
3547//-----------------------------------------------------------------------------
3548// stub stub stub
3549// +-------+ +---------+ +---------+ +---------+
3550// | xapp | | submgr | | e2term | | rtmgr |
3551// +-------+ +---------+ +---------+ +---------+
3552// | | | |
3553// | RESTSubReq | | |
3554// |---------------->| | |
3555// | RESTSubResp | | |
3556// |<----------------| | |
3557// | | RouteCreate | |
3558// | |--------------------------->|
3559// | | RouteResponse| |
3560// | |<---------------------------|
3561// | | SubReq | |
3562// | |------------->| |
3563// | | SubResp | |
3564// | |<-------------| |
3565// | RESTNotif1 | | |
3566// |<----------------| | |
3567// | RESTSubReq | | |
3568// | [with RestSUbsId + one additional e2 subDetail]
3569// |---------------->| | |
3570// | RESTNotif1 | | |
3571// | [for initial e2 subDetail] | |
3572// |<----------------| | |
3573// | | RouteCreate | |
3574// | |--------------------------->|
3575// | | RouteResponse| |
3576// | |<---------------------------|
3577// | | SubReq | |
3578// | |------------->| |
3579// | | SubResp | |
3580// | |<-------------| |
3581// | RESTNotif1 | | |
3582// |<----------------| | |
3583// | RESTSubReq | | |
3584// | [with RESTsubsId initial request] |
3585// |---------------->| | |
3586// | RESTNotif1 | | |
3587// |<----------------| | |
3588// | RESTSubDelReq | | |
3589// |---------------->| | |
3590// | RESTSubDelResp| | |
3591// |<----------------| | |
3592// | | SubDelReq | |
3593// | |------------->| |
3594// | | SubDelResp | |
3595// | |<-------------| |
3596// | | SubDelReq | |
3597// | |------------->| |
3598// | | SubDelResp | |
3599// | |<-------------| |
3600// | | | |
3601//
3602//-----------------------------------------------------------------------------
3603
3604func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003605
3606 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3607 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003608 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003609 Counter{cRestSubRespToXapp, 3},
3610 Counter{cSubReqToE2, 2},
3611 Counter{cSubRespFromE2, 2},
3612 Counter{cRestSubNotifToXapp, 4},
3613 Counter{cRestSubDelReqFromXapp, 1},
3614 Counter{cSubDelReqToE2, 2},
3615 Counter{cSubDelRespFromE2, 2},
3616 Counter{cRestSubDelRespToXapp, 1},
3617 })
3618
3619 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3620
3621 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3622
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003623 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003624
3625 // Send modified requst, this time with e2 subscriptions.
3626 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3627 params2.SetSubscriptionID(&restSubId)
3628
3629 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003630 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003631 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3632 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003633 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3634 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003635
3636 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3637
Markku Virtanen2b512b62021-07-30 12:04:00 +00003638 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003639 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3640 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3641 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3642 assert.NotEqual(t, e2SubsId2, 0)
3643
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003644 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003645
3646 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3647 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3648 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003649 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003650 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3651 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3652 assert.Equal(t, restSubId_resend, restSubId_resend2)
3653
Markku Virtanen2b512b62021-07-30 12:04:00 +00003654 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3655 assert.Equal(t, e2SubsId, e2SubsId1)
3656
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003657 mainCtrl.WaitOngoingRequestMapEmpty()
3658
Markku Virtanen42723e22021-06-15 10:09:23 +03003659 // Delete both e2 subscriptions
3660 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3661 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3662 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3663
3664 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003665 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003666 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003667}
3668
3669//-----------------------------------------------------------------------------
3670// stub stub stub
3671// +-------+ +---------+ +---------+ +---------+
3672// | xapp | | submgr | | e2term | | rtmgr |
3673// +-------+ +---------+ +---------+ +---------+
3674// | | | |
3675// | RESTSubReq | | |
3676// |---------------->| | |
3677// | RESTSubResp | | |
3678// |<----------------| | |
3679// | | RouteCreate | |
3680// | |--------------------------->|
3681// | | RouteResponse| |
3682// | |<---------------------------|
3683// | | SubReq | |
3684// | |------------->| |
3685// | | SubResp | |
3686// | |<-------------| |
3687// | RESTNotif1 | | |
3688// |<----------------| | |
3689// | RESTSubReq | | |
3690// | [with RestSUbsId + one additional e2 subDetail]
3691// |---------------->| | |
3692// | RESTNotif1 | | |
3693// | [for initial e2 subDetail] | |
3694// |<----------------| | |
3695// | | RouteCreate | |
3696// | |--------------------------->|
3697// | | RouteResponse| |
3698// | |<---------------------------|
3699// | | SubReq | |
3700// | |------------->| |
3701// | | SubResp | |
3702// | |<-------------| |
3703// | RESTNotif1 | | |
3704// |<----------------| | |
3705// | RESTSubReq | | |
3706// | [without RESTsubsId initial request] |
3707// |---------------->| | |
3708// | RESTNotif1 | | |
3709// |<----------------| | |
3710// | RESTSubDelReq | | |
3711// |---------------->| | |
3712// | RESTSubDelResp| | |
3713// |<----------------| | |
3714// | | SubDelReq | |
3715// | |------------->| |
3716// | | SubDelResp | |
3717// | |<-------------| |
3718// | | SubDelReq | |
3719// | |------------->| |
3720// | | SubDelResp | |
3721// | |<-------------| |
3722// | | | |
3723//
3724//-----------------------------------------------------------------------------
3725
3726func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003727
3728 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3729 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003730 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003731 Counter{cRestSubRespToXapp, 3},
3732 Counter{cSubReqToE2, 2},
3733 Counter{cSubRespFromE2, 2},
3734 Counter{cRestSubNotifToXapp, 4},
3735 Counter{cRestSubDelReqFromXapp, 1},
3736 Counter{cSubDelReqToE2, 2},
3737 Counter{cSubDelRespFromE2, 2},
3738 Counter{cRestSubDelRespToXapp, 1},
3739 })
3740
3741 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3742
3743 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3744
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003745 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003746
Anssi Mannila21782182021-12-10 10:56:02 +02003747 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003748 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3749 params2.SetSubscriptionID(&restSubId)
3750
3751 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003752 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003753 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3754 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3755
Markku Virtanen2b512b62021-07-30 12:04:00 +00003756 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3757 assert.Equal(t, e2SubsId, e2SubsId1)
3758 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3759 xappConn1.DecrementRequestCount()
3760
Markku Virtanen42723e22021-06-15 10:09:23 +03003761 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3762
3763 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3764 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3765 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3766 assert.NotEqual(t, e2SubsId2, 0)
3767
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003768 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003769
3770 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3771 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003772 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003773 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3774 // md5sum shall find the original request
3775 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3776 assert.Equal(t, restSubId_resend, restSubId_resend2)
3777
Markku Virtanen2b512b62021-07-30 12:04:00 +00003778 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3779 assert.Equal(t, e2SubsId, e2SubsId1)
3780
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003781 mainCtrl.WaitOngoingRequestMapEmpty()
3782
Markku Virtanen42723e22021-06-15 10:09:23 +03003783 // Delete both e2 subscriptions
3784 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3785 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3786 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3787
3788 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003789 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003790 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003791}
3792
3793//-----------------------------------------------------------------------------
3794// stub stub stub
3795// +-------+ +---------+ +---------+ +---------+
3796// | xapp | | submgr | | e2term | | rtmgr |
3797// +-------+ +---------+ +---------+ +---------+
3798// | | | |
3799// | RESTSubReq | | |
3800// |---------------->| | |
3801// | RESTSubResp | | |
3802// |<----------------| | |
3803// | | RouteCreate | |
3804// | |--------------------------->|
3805// | | RouteResponse| |
3806// | |<---------------------------|
3807// | | SubReq | |
3808// | |------------->| |
3809// | | SubResp | |
3810// | |<-------------| |
3811// | RESTNotif1 | | |
3812// |<----------------| | |
3813// | RESTSubReq | | |
3814// | [with RestSUbsId + one additional e2 subDetail]
3815// |---------------->| | |
3816// | RESTNotif1 | | |
3817// | [for initial e2 subDetail] | |
3818// |<----------------| | |
3819// | | RouteCreate | |
3820// | |--------------------------->|
3821// | | RouteResponse| |
3822// | |<---------------------------|
3823// | | SubReq | |
3824// | |------------->| |
3825// | | SubResp | |
3826// | |<-------------| |
3827// | RESTNotif1 | | |
3828// |<----------------| | |
3829// | RESTSubDelReq | | |
3830// |---------------->| | |
3831// | RESTSubDelResp| | |
3832// |<----------------| | |
3833// | | SubDelReq | |
3834// | |------------->| |
3835// | | SubDelResp | |
3836// | |<-------------| |
3837// | | SubDelReq | |
3838// | |------------->| |
3839// | | SubDelResp | |
3840// | |<-------------| |
3841// | RESTSubReq | | |
3842// | [with RESTsubsId initial request] |
3843// |---------------->| | |
3844// | RESTSubResp | | |
3845// |<----------------| | |
3846// | | RouteCreate | |
3847// | |--------------------------->|
3848// | | RouteResponse| |
3849// | |<---------------------------|
3850// | | SubReq | |
3851// | |------------->| |
3852// | | SubResp | |
3853// | |<-------------| |
3854// | RESTNotif1 | | |
3855// |<----------------| | |
3856// | | | |
3857//
3858//-----------------------------------------------------------------------------
3859func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003860
3861 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3862 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003863 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003864 Counter{cRestSubRespToXapp, 3},
3865 Counter{cSubReqToE2, 3},
3866 Counter{cSubRespFromE2, 3},
3867 Counter{cRestSubNotifToXapp, 4},
3868 Counter{cRestSubDelReqFromXapp, 2},
3869 Counter{cSubDelReqToE2, 3},
3870 Counter{cSubDelRespFromE2, 3},
3871 Counter{cRestSubDelRespToXapp, 2},
3872 })
3873
3874 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3875
3876 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3877
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003878 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003879
3880 // Send modified requst, this time with e2 subscriptions.
3881 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3882 params2.SetSubscriptionID(&restSubId)
3883
3884 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003885 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003886 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3887 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3888
Markku Virtanen2b512b62021-07-30 12:04:00 +00003889 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3890 assert.Equal(t, e2SubsId, e2SubsId1)
3891
Markku Virtanen42723e22021-06-15 10:09:23 +03003892 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3893
3894 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3895 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3896 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3897 assert.NotEqual(t, e2SubsId2, 0)
3898
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003899 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003900
3901 // Delete both e2 subscriptions
3902 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3903 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3904 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3905
3906 waitSubsCleanup(t, e2SubsId, 10)
3907
3908 // Resend the original request, we shall find it's previous md5sum/restsubs
3909 // but the restsubscription has been already removed. This shall trigger a
3910 // fresh create.
3911 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3912
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003913 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003914
3915 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3916
3917 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003918 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003919 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003920}
3921
Anssi Mannila27385172021-12-22 09:41:54 +02003922//-----------------------------------------------------------------------------
3923// TestRESTSubDelReqRetransmission
3924//
3925// stub stub
3926// +-------+ +---------+ +---------+
3927// | xapp | | submgr | | e2term |
3928// +-------+ +---------+ +---------+
3929// | | |
3930// | RESTSubReq | |
3931// |---------------->| |
3932// | | |
3933// | RESTSubResp | |
3934// |<----------------| |
3935// | | SubReq |
3936// | |------------->|
3937// | | SubResp |
3938// | |<-------------|
3939// | RESTNotif1 | |
3940// |<----------------| |
3941// | | |
3942// | RESTSubDelReq | |
3943// |---------------->| |
3944// | RESTSubDelResp | |
3945// |<----------------| |
3946// | | SubDelReq |
3947// | |------------->|
3948// | RESTSubDelReq | |
3949// |---------------->| |
3950// | RESTSubDelResp | |
3951// |<----------------| |
3952// | | SubDelResp |
3953// | |<-------------|
3954// | | |
3955//
3956//-----------------------------------------------------------------------------
3957
archaggeafbf95f2021-04-14 08:54:05 +03003958func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003959
3960 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003961 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003962 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003963 Counter{cSubReqToE2, 1},
3964 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003965 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003966 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003967 Counter{cSubDelReqToE2, 1},
3968 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003969 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003970 })
3971
3972 var params *teststube2ap.RESTSubsReqParams = nil
3973
3974 //Subs Create
3975 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3976
3977 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3978
3979 //Subs Delete
3980 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3981 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3982
Anssi Mannila27385172021-12-22 09:41:54 +02003983 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03003984 seqBef := mainCtrl.get_msgcounter(t)
3985 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3986 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3987
Anssi Mannila27385172021-12-22 09:41:54 +02003988 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03003989 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3990
3991 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003992 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003993 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003994}
3995
3996//-----------------------------------------------------------------------------
3997// TestRESTSubReqDelReq
3998//
3999// stub stub
4000// +-------+ +---------+ +---------+
4001// | xapp | | submgr | | e2term |
4002// +-------+ +---------+ +---------+
4003// | | |
4004// | RESTSubReq | |
4005// |---------------->| |
4006// | | |
4007// | RESTSubResp | |
4008// |<----------------| |
4009// | | SubReq |
4010// | |------------->|
4011// | RESTSubDelReq | |
4012// |---------------->| |
4013// | RESTSubDelResp | |
4014// | unsuccess | |
4015// |<----------------| |
4016// | | SubResp |
4017// | |<-------------|
4018// | RESTNotif1 | |
4019// |<----------------| |
4020// | | |
4021// | [SUBS DELETE] |
4022// | | |
4023//
4024//-----------------------------------------------------------------------------
4025func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004026
4027 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004028 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004029 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004030 Counter{cSubReqToE2, 1},
4031 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004032 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004033 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004034 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004035 Counter{cSubDelReqToE2, 1},
4036 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004037 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004038 })
4039
4040 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004041
4042 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004043 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004044 restSubId := xappConn1.SendRESTSubsReq(t, params)
4045
4046 // Del. This will fail as processing of the subscription
4047 // is still ongoing in submgr. Deletion is not allowed before
4048 // subscription creation has been completed.
4049 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4050 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4051 xappConn1.ExpectRESTNotification(t, restSubId)
4052 e2termConn1.SendSubsResp(t, crereq, cremsg)
4053 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4054
4055 // Retry del
4056 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4057
4058 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4059 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4060
4061 // Wait that subs is cleaned
4062 waitSubsCleanup(t, e2SubsId, 10)
4063 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004064 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004065}
4066
Anssi Mannila27385172021-12-22 09:41:54 +02004067//-----------------------------------------------------------------------------
4068// TestRESTSubReqAndSubDelOkTwoParallel
4069//
4070// stub stub stub
4071// +-------+ +-------+ +---------+ +---------+
4072// | xapp2 | | xapp1 | | submgr | | e2term |
4073// +-------+ +-------+ +---------+ +---------+
4074// | | | |
4075// | | RESTSubReq1 | |
4076// | |------------->| |
4077// | | RESTSubResp1 | |
4078// | |<-------------| |
4079// | | | |
4080// | | | SubReq1 |
4081// | | |------------->|
4082// | | | |
4083// | RESTSubReq2 | |
4084// |------------------------>| |
4085// | RESTSubResp2 | |
4086// |<------------------------| |
4087// | | | |
4088// | | | SubReq2 |
4089// | | |------------->|
4090// | | | |
4091// | | | SubResp1 |
4092// | | |<-------------|
4093// | | RESTNotif1 | |
4094// | |<-------------| |
4095// | | | |
4096// | | | SubResp2 |
4097// | | |<-------------|
4098// | RESTNotif2 | |
4099// |<------------------------| |
4100// | | | |
4101// | | [SUBS 1 DELETE] |
4102// | | | |
4103// | | [SUBS 2 DELETE] |
4104// | | | |
4105//
4106//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004107
4108func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004109
4110 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004111 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004112 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004113 Counter{cSubReqToE2, 2},
4114 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004115 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004116 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004117 Counter{cSubDelReqToE2, 2},
4118 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004119 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004120 })
4121
4122 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004123 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004124 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004125 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004126
4127 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004128 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004129 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004130 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004131
4132 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4133 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4134
4135 //XappConn1 receives both of the responses
4136 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4137
4138 //Resp1
4139 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4140 //Resp2
4141 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4142
4143 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004144 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004145 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004146 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004147
4148 //Del1
4149 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4150 //Del2
4151 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
4152
4153 //Wait that subs is cleaned
4154 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
4155 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4156
4157 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004158 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004159}
4160
Anssi Mannila27385172021-12-22 09:41:54 +02004161//-----------------------------------------------------------------------------
4162// TestRESTSameSubsDiffRan
4163// Same subscription to different RANs
4164//
4165// stub stub
4166// +-------+ +---------+ +---------+
4167// | xapp | | submgr | | e2term |
4168// +-------+ +---------+ +---------+
4169// | | |
4170// | RESTSubReq(r1) | |
4171// |---------------->| |
4172// | RESTSubResp(r1) | |
4173// |<----------------| |
4174// | | |
4175// | | SubReq(r1) |
4176// | |------------->|
4177// | | |
4178// | | SubResp(r1) |
4179// | |<-------------|
4180// | | |
4181// | RESTNotif(r1) | |
4182// |<----------------| |
4183// | | |
4184// | RESTSubReq(r2) | |
4185// |---------------->| |
4186// | | |
4187// | RESTSubResp(r2) | |
4188// |<----------------| |
4189// | | SubReq(r2) |
4190// | |------------->|
4191// | | |
4192// | | SubResp(r2) |
4193// | |<-------------|
4194// | | |
4195// | RESTNotif(r2) | |
4196// |<----------------| |
4197// | | |
4198// | [SUBS r1 DELETE] |
4199// | | |
4200// | [SUBS r2 DELETE] |
4201// | | |
4202//
4203//-----------------------------------------------------------------------------
4204
archaggeafbf95f2021-04-14 08:54:05 +03004205func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004206
4207 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004208 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004209 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004210 Counter{cSubReqToE2, 2},
4211 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004212 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004213 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004214 Counter{cSubDelReqToE2, 2},
4215 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004216 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004217 })
4218
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004219 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004220 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004221 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004222
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004223 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004224 params.SetMeid("RAN_NAME_2")
4225 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004226 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004227
4228 //Del1
4229 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4230 //Del2
4231 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
4232
4233 //Wait that subs is cleaned
4234 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4235 waitSubsCleanup(t, e2SubsId2, 10)
4236
4237 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004238 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004239}
4240
Anssi Mannila27385172021-12-22 09:41:54 +02004241//-----------------------------------------------------------------------------
4242// TestRESTSubReqRetryInSubmgr
4243//
4244// stub stub
4245// +-------+ +---------+ +---------+
4246// | xapp | | submgr | | e2term |
4247// +-------+ +---------+ +---------+
4248// | | |
4249// | RESTSubReq | |
4250// |---------------->| |
4251// | RESTSubResp | |
4252// |<----------------| |
4253// | | SubReq |
Anssi Mannila92c38552021-12-29 09:59:24 +02004254// | |------------->|
Anssi Mannila27385172021-12-22 09:41:54 +02004255// | | |
4256// | | |
4257// | | SubReq |
4258// | |------------->|
4259// | | SubResp |
4260// | |<-------------|
4261// | | |
4262// | RESTNotif | |
4263// |<----------------| |
4264// | | |
4265// | [SUBS DELETE] |
4266// | | |
4267//
4268//-----------------------------------------------------------------------------
4269
archaggeafbf95f2021-04-14 08:54:05 +03004270func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004271
4272 // Init counter check
4273 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004274 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004275 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004276 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004277 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004278 Counter{cSubReReqToE2, 1},
4279 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004280 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004281 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004282 Counter{cSubDelReqToE2, 1},
4283 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004284 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004285 })
4286
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004287 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004288 restSubId := xappConn1.SendRESTSubsReq(t, params)
4289
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004290 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004291
4292 // Catch the first message and ignore it
4293 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004294 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004295
4296 // The second request is being handled normally
4297 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4298 xappConn1.ExpectRESTNotification(t, restSubId)
4299 e2termConn1.SendSubsResp(t, crereq, cremsg)
4300 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4301
4302 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4303
Anssi Mannila27385172021-12-22 09:41:54 +02004304 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004305 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4306
4307 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4308 //Wait that subs is cleaned
4309 waitSubsCleanup(t, e2SubsId, 10)
4310
4311 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004312 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004313}
4314
4315//-----------------------------------------------------------------------------
4316// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4317//
4318// stub stub
4319// +-------+ +---------+ +---------+
4320// | xapp | | submgr | | e2term |
4321// +-------+ +---------+ +---------+
4322// | | |
4323// | RESTSubReq | |
4324// |---------------->| |
4325// | | |
4326// | RESTSubResp | |
4327// |<----------------| |
4328// | | SubReq |
4329// | |------------->|
4330// | | |
4331// | | |
4332// | | SubReq |
4333// | |------------->|
4334// | | |
4335// | | SubDelReq |
4336// | |------------->|
4337// | | |
4338// | | |
4339// | | SubDelReq |
4340// | |------------->|
4341// | | |
4342// | | |
4343// | | SubDelResp |
4344// | |<-------------|
4345// | RESTNotif | |
4346// | unsuccess | |
4347// |<----------------| |
4348// | | |
4349// | [SUBS DELETE] |
4350// | | |
4351//
4352//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004353
archaggeafbf95f2021-04-14 08:54:05 +03004354func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004355
4356 // Init counter check
4357 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004358 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004359 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004360 Counter{cSubReqToE2, 1},
4361 Counter{cSubReReqToE2, 1},
4362 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004363 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004364 Counter{cSubDelReqToE2, 1},
4365 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004366 Counter{cRestSubDelReqFromXapp, 1},
4367 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004368 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004369
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004370 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004371 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004372 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004373
4374 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004375 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004376
4377 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004378 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004379
4380 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004381 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004382 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004383 xappConn1.WaitRESTNotification(t, restSubId)
4384
Anssi Mannilab43397e2021-11-16 12:06:16 +02004385 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4386
archaggeafbf95f2021-04-14 08:54:05 +03004387 // Wait that subs is cleaned
4388 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004389 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004390 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004391}
4392
Anssi Mannila27385172021-12-22 09:41:54 +02004393//-----------------------------------------------------------------------------
4394// TestREST2eTermNotRespondingToSubReq
4395//
4396// stub stub
4397// +-------+ +---------+ +---------+
4398// | xapp | | submgr | | e2term |
4399// +-------+ +---------+ +---------+
4400// | | |
4401// | RESTSubReq | |
4402// |---------------->| |
4403// | RESTSubResp | |
4404// |<----------------| |
4405// | | SubReq |
4406// | |------------->|
4407// | | |
4408// | | SubReq |
4409// | |------------->|
4410// | | |
4411// | | SubDelReq |
4412// | |------------->|
4413// | | |
4414// | | SubDelReq |
4415// | |------------->|
4416// | RESTNotif(Unsuccessful) |
4417// |<----------------| |
4418// | | |
4419// | RESTSubDelReq | |
4420// |---------------->| |
4421// | RESTSubDelResp | |
4422// |<----------------| |
4423// | | |
4424//
4425//-----------------------------------------------------------------------------
4426
archaggeafbf95f2021-04-14 08:54:05 +03004427func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004428
4429 // Init counter check
4430 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004431 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004432 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004433 Counter{cSubReqToE2, 1},
4434 Counter{cSubReReqToE2, 1},
4435 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004436 Counter{cSubDelReReqToE2, 1},
4437 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004438 Counter{cSubDelReqToE2, 1},
4439 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004440 Counter{cRestSubDelReqFromXapp, 1},
4441 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004442 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004443
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004444 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004445 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004446 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004447
4448 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004449 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004450
4451 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004452 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004453
4454 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004455 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004456
Markku Virtanen55d2a282021-06-04 14:46:56 +03004457 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004458 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004459 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004460
4461 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4462
Anssi Mannilab43397e2021-11-16 12:06:16 +02004463 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004464
Anssi Mannilab43397e2021-11-16 12:06:16 +02004465 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004466 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004467 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004468}
4469
4470//-----------------------------------------------------------------------------
4471// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4472//
4473// stub stub
4474// +-------+ +---------+ +---------+
4475// | xapp | | submgr | | e2term |
4476// +-------+ +---------+ +---------+
4477// | | |
4478// | RESTSubReq | |
4479// |---------------->| |
4480// | | |
4481// | RESTSubResp | |
4482// |<----------------| |
4483// | | SubReq |
4484// | |------------->|
4485// | | |
4486// | | |
4487// | | SubReq |
4488// | |------------->|
4489// | | |
4490// | | SubDelReq |
4491// | |------------->|
4492// | | |
4493// | | |
4494// | | SubDelReq |
4495// | |------------->|
4496// | | |
4497// | | |
4498// | | SubDelResp |
4499// | |<-------------|
4500// | RESTNotif | |
4501// | unsuccess | |
4502// |<----------------| |
4503// | | |
4504// | [SUBS DELETE] |
4505// | | |
4506//
4507//-----------------------------------------------------------------------------
4508func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004509
4510 // Init counter check
4511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004512 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004513 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004514 Counter{cSubReqToE2, 1},
4515 Counter{cSubReReqToE2, 1},
4516 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004517 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004518 Counter{cSubDelReqToE2, 1},
4519 Counter{cSubDelReReqToE2, 1},
4520 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004521 Counter{cRestSubDelReqFromXapp, 1},
4522 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004523 })
4524
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004525 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004526 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004527 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004528
4529 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004530 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004531
4532 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004533 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004534
4535 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004536 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004537
Markku Virtanen55d2a282021-06-04 14:46:56 +03004538 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004539 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004540 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004541
4542 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4543
Anssi Mannilab43397e2021-11-16 12:06:16 +02004544 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004545
Anssi Mannilab43397e2021-11-16 12:06:16 +02004546 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004547 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004548 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004549}
4550
4551//-----------------------------------------------------------------------------
4552// TestRESTSubReqSubFailRespInSubmgr
4553//
4554// stub stub
4555// +-------+ +---------+ +---------+
4556// | xapp | | submgr | | e2term |
4557// +-------+ +---------+ +---------+
4558// | | |
4559// | RESTSubReq | |
4560// |---------------->| |
4561// | | |
4562// | RESTSubResp | |
4563// |<----------------| |
4564// | | SubReq |
4565// | |------------->|
4566// | | |
4567// | | SubFail |
4568// | |<-------------|
4569// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004570// | RESTNotif | |
4571// | unsuccess | |
4572// |<----------------| |
4573// | | |
4574// | [SUBS DELETE] |
4575// | | |
4576//
4577//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004578
archaggeafbf95f2021-04-14 08:54:05 +03004579func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004580
4581 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004582 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004583 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004584 Counter{cSubReqToE2, 1},
4585 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004586 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004587 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004588 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004589 })
4590
4591 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004592 const e2Timeout int64 = 2
4593 const e2RetryCount int64 = 1
4594 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004595
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004596 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004597 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004598 restSubId := xappConn1.SendRESTSubsReq(t, params)
4599
4600 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4601 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4602 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004603 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004604 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4605
archaggeafbf95f2021-04-14 08:54:05 +03004606 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004607 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004608
4609 // REST subscription sill there to be deleted
4610 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4611
4612 // Wait that subs is cleaned
4613 waitSubsCleanup(t, e2SubsId, 10)
4614
4615 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004616 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004617}
4618
4619//-----------------------------------------------------------------------------
Anssi Mannila56233b02022-01-24 13:26:42 +02004620// TestRESTSubReqPartialResp
4621//
4622// stub stub
4623// +-------+ +---------+ +---------+
4624// | xapp | | submgr | | e2term |
4625// +-------+ +---------+ +---------+
4626// | | |
4627// | RESTSubReq | |
4628// |---------------->| |
4629// | RESTSubResp | |
4630// |<----------------| |
4631// | | SubReq |
4632// | |------------->|
4633// | | SubResp | Partially accepted
4634// | |<-------------|
4635// | | |
4636// | RESTNotif | |
4637// |<----------------| |
4638// | | |
4639// | [SUBS DELETE] |
4640// | | |
4641//
4642//-----------------------------------------------------------------------------
4643
4644func TestRESTSubReqPartialResp(t *testing.T) {
4645
4646 // Init counter check
4647 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4648 Counter{cRestSubReqFromXapp, 1},
4649 Counter{cRestSubRespToXapp, 1},
4650 Counter{cSubReqToE2, 1},
4651 Counter{cSubRespFromE2, 1},
4652 Counter{cPartialSubRespFromE2, 1},
4653 Counter{cRestSubNotifToXapp, 1},
4654 Counter{cRestSubDelReqFromXapp, 1},
4655 Counter{cSubDelReqToE2, 1},
4656 Counter{cSubDelRespFromE2, 1},
4657 Counter{cRestSubDelRespToXapp, 1},
4658 })
4659
4660 // Req
4661 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4662
4663 actionId := int64(2)
4664 actionType := "report"
4665 actionDefinition := []int64{5678, 1}
4666 subsequestActionType := "continue"
4667 timeToWait := "w10ms"
4668 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4669
4670 restSubId := xappConn1.SendRESTSubsReq(t, params)
4671 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4672 xappConn1.ExpectRESTNotification(t, restSubId)
4673
4674 actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{}
4675 actionNotAdmittedItem.ActionId = 1
4676 actionNotAdmittedItem.Cause.Content = 1
4677 actionNotAdmittedItem.Cause.Value = 8
4678 actionNotAdmittedList := e2ap.ActionNotAdmittedList{}
4679 actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem)
4680 e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList)
4681 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4682
4683 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4684
4685 // Del
4686 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4687
4688 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4689 //Wait that subs is cleaned
4690 waitSubsCleanup(t, e2SubsId, 10)
4691
4692 mainCtrl.VerifyCounterValues(t)
4693 mainCtrl.VerifyAllClean(t)
4694}
4695
4696//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004697// TestRESTSubDelReqRetryInSubmgr
4698//
4699// stub stub
4700// +-------+ +---------+ +---------+
4701// | xapp | | submgr | | e2term |
4702// +-------+ +---------+ +---------+
4703// | | |
4704// | [SUBS CREATE] |
4705// | | |
4706// | | |
4707// | RESTSubDelReq | |
4708// |---------------->| |
4709// | | |
4710// | RESTSubDelResp | |
4711// |<----------------| |
4712// | | SubDelReq |
4713// | |------------->|
4714// | | |
4715// | | SubDelReq |
4716// | |------------->|
4717// | | |
4718// | | SubDelResp |
4719// | |<-------------|
4720// | | |
4721//
4722//-----------------------------------------------------------------------------
4723func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004724
4725 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004726 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004727 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004728 Counter{cSubReqToE2, 1},
4729 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004730 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004731 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004732 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004733 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004734 Counter{cSubDelReReqToE2, 1},
4735 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004736 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004737 })
4738 // Req
4739 var params *teststube2ap.RESTSubsReqParams = nil
4740 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4741
4742 // Del
4743 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4744
4745 // E2t: Receive 1st SubsDelReq
4746 e2termConn1.RecvSubsDelReq(t)
4747
4748 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4749 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4750 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4751
4752 //Wait that subs is cleaned
4753 waitSubsCleanup(t, e2SubsId, 10)
4754
4755 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004756 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004757}
4758
4759//-----------------------------------------------------------------------------
4760// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4761//
4762// stub stub
4763// +-------+ +---------+ +---------+
4764// | xapp | | submgr | | e2term |
4765// +-------+ +---------+ +---------+
4766// | | |
4767// | [SUBS CREATE] |
4768// | | |
4769// | | |
4770// | RESTSubDelReq | |
4771// |---------------->| |
4772// | | |
4773// | RESTSubDelResp | |
4774// |<----------------| |
4775// | | SubDelReq |
4776// | |------------->|
4777// | | |
4778// | | SubDelReq |
4779// | |------------->|
4780// | | |
4781// | | |
4782//
4783//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004784
archaggeafbf95f2021-04-14 08:54:05 +03004785func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004786
4787 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004788 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004789 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004790 Counter{cSubReqToE2, 1},
4791 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004792 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004793 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004794 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004795 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004796 Counter{cSubDelReReqToE2, 1},
4797 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004798 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004799 })
4800
4801 // Req
4802 var params *teststube2ap.RESTSubsReqParams = nil
4803 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4804
4805 // Del
4806 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4807
4808 // E2t: Receive 1st SubsDelReq
4809 e2termConn1.RecvSubsDelReq(t)
4810
4811 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4812 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4813 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4814
4815 //Wait that subs is cleaned
4816 waitSubsCleanup(t, e2SubsId, 10)
4817
4818 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004819 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004820}
4821
4822//-----------------------------------------------------------------------------
4823// TestRESTSubDelReqSubDelFailRespInSubmgr
4824//
4825// stub stub
4826// +-------+ +---------+ +---------+
4827// | xapp | | submgr | | e2term |
4828// +-------+ +---------+ +---------+
4829// | | |
4830// | [SUBS CREATE] |
4831// | | |
4832// | | |
4833// | RESTSubDelReq | |
4834// |---------------->| |
4835// | | |
4836// | RESTSubDelResp | |
4837// |<----------------| |
4838// | | SubDelReq |
4839// | |------------->|
4840// | | |
4841// | | SubDelFail |
4842// | |<-------------|
4843// | | |
4844//
4845//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004846
archaggeafbf95f2021-04-14 08:54:05 +03004847func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004848
4849 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004850 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004851 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004852 Counter{cSubReqToE2, 1},
4853 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004854 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004855 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004856 Counter{cSubDelReqToE2, 1},
4857 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004858 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004859 })
4860
4861 // Req
4862 var params *teststube2ap.RESTSubsReqParams = nil
4863 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4864
4865 // Del
4866 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4867
4868 // E2t: Send receive SubsDelReq and send SubsDelFail
4869 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4870 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4871
4872 //Wait that subs is cleaned
4873 waitSubsCleanup(t, e2SubsId, 10)
4874
4875 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004876 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004877}
4878
4879//-----------------------------------------------------------------------------
4880// TestRESTSubReqAndSubDelOkSameAction
4881//
4882// stub stub
4883// +-------+ +-------+ +---------+ +---------+
4884// | xapp2 | | xapp1 | | submgr | | e2term |
4885// +-------+ +-------+ +---------+ +---------+
4886// | | | |
4887// | | RESTSubReq1 | |
4888// | |---------------->| |
4889// | | | |
4890// | | RESTSubResp1 | |
4891// | |<----------------| |
4892// | | | |
4893// | | | SubReq1 |
4894// | | |------------->|
4895// | | | SubResp1 |
4896// | | |<-------------|
4897// | | RESTNotif1 | |
4898// | |<----------------| |
4899// | | | |
4900// | RESTSubReq2 | |
4901// |------------------------------>| |
4902// | | | |
4903// | RESTSubResp2 | |
4904// |<------------------------------| |
4905// | | | |
4906// | | RESTNotif2 | |
4907// |<------------------------------| |
4908// | | | |
4909// | | RESTSubDelReq1 | |
4910// | |---------------->| |
4911// | | | |
4912// | | RESTSubDelResp1 | |
4913// | |<----------------| |
4914// | | | |
4915// | RESTSubDelReq2 | |
4916// |------------------------------>| |
4917// | | | |
4918// | RESTSubDelResp2 | |
4919// |<------------------------------| |
4920// | | | |
4921// | | | SubDelReq2 |
4922// | | |------------->|
4923// | | | |
4924// | | | SubDelResp2 |
4925// | | |<-------------|
4926// | | | |
4927//
4928//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004929
archaggeafbf95f2021-04-14 08:54:05 +03004930func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004931
4932 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004933 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004934 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004935 Counter{cSubReqToE2, 1},
4936 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004937 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004938 Counter{cMergedSubscriptions, 1},
4939 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004940 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004941 Counter{cSubDelReqToE2, 1},
4942 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004943 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004944 })
4945
4946 // Req1
4947 var params *teststube2ap.RESTSubsReqParams = nil
4948
4949 //Subs Create
4950 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4951 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4952
4953 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004954 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004955 params.SetMeid("RAN_NAME_1")
4956
4957 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004958 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004959 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004960 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004961 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004962 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004963 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004964 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004965
4966 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4967
4968 // Del1
4969 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4970
4971 // Del2
4972 deleteXapp2Subscription(t, &restSubId2)
4973
4974 //Wait that subs is cleaned
4975 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004976 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004977 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004978}
4979
4980//-----------------------------------------------------------------------------
4981// TestSubReqAndSubDelOkSameActionParallel
4982//
4983// stub stub stub
4984// +-------+ +-------+ +---------+ +---------+
4985// | xapp2 | | xapp1 | | submgr | | e2term |
4986// +-------+ +-------+ +---------+ +---------+
4987// | | | |
4988// | | | |
4989// | | | |
4990// | | SubReq1 | |
4991// | |------------->| |
4992// | | | |
4993// | | | SubReq1 |
4994// | | |------------->|
4995// | SubReq2 | |
4996// |--------------------------->| |
4997// | | | SubResp1 |
4998// | | |<-------------|
4999// | | SubResp1 | |
5000// | |<-------------| |
5001// | | | SubReq2 |
5002// | | |------------->|
5003// | | | |
5004// | | | SubResp2 |
5005// | | |<-------------|
5006// | SubResp2 | |
5007// |<---------------------------| |
5008// | | | |
5009// | | SubDelReq 1 | |
5010// | |------------->| |
5011// | | | |
5012// | | SubDelResp 1 | |
5013// | |<-------------| |
5014// | | | |
5015// | SubDelReq 2 | |
5016// |--------------------------->| |
5017// | | | |
5018// | | | SubDelReq 2 |
5019// | | |------------->|
5020// | | | |
5021// | | | SubDelReq 2 |
5022// | | |------------->|
5023// | | | |
5024// | SubDelResp 2 | |
5025// |<---------------------------| |
5026//
5027func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005028
5029 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005030 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005031 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005032 Counter{cSubReqToE2, 2},
5033 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005034 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005035 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005036 Counter{cSubDelReqToE2, 2},
5037 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005038 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005039 })
5040
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005041 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005042 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5043 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5044
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005045 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005046 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5047
5048 xappConn1.ExpectRESTNotification(t, restSubId1)
5049 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5050 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
5051
5052 xappConn2.ExpectRESTNotification(t, restSubId2)
5053 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
5054 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
5055 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5056
5057 // Del1
5058 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5059 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5060 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5061 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5062
5063 // Del2
5064 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5065 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
5066 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
5067
5068 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005069 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005070 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005071}
5072
5073//-----------------------------------------------------------------------------
5074// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
5075//
5076// stub stub stub
5077// +-------+ +-------+ +---------+ +---------+
5078// | xapp2 | | xapp1 | | submgr | | e2term |
5079// +-------+ +-------+ +---------+ +---------+
5080// | | | |
5081// | | | |
5082// | | | |
5083// | | RESTSubReq1 | |
5084// | |---------------->| |
5085// | | | |
5086// | | RESTSubResp1 | |
5087// | |<----------------| |
5088// | | | SubReq1 |
5089// | | |------------->|
5090// | RESTSubReq2 | |
5091// |------------------------------>| |
5092// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005093// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005094// |<------------------------------| |
5095// | | | SubReq1 |
5096// | | |------------->|
5097// | | | |
5098// | | | |
5099// | | | SubDelReq |
5100// | | |------------->|
5101// | | | |
5102// | | | SubDelResp |
5103// | | |<-------------|
5104// | | RESTNotif1 | |
5105// | | unsuccess | |
5106// | |<----------------| |
5107// | RESTNotif2 | |
5108// | | unsuccess | |
5109// |<------------------------------| |
5110// | | | |
5111// | | RESTSubDelReq1 | |
5112// | |---------------->| |
5113// | | | |
5114// | | RESTSubDelResp1 | |
5115// | |<----------------| |
5116// | | | |
5117// | RESTSubDelReq2 | |
5118// |------------------------------>| |
5119// | | | |
5120// | RESTSubDelResp2 | |
5121// |<------------------------------| |
5122//
5123//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005124
archaggeafbf95f2021-04-14 08:54:05 +03005125func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005126
5127 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005128 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005129 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005130 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005131 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005132 Counter{cSubReqTimerExpiry, 2},
5133 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005134 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005135 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005136 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005137 Counter{cSubDelReqToE2, 1},
5138 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005139 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005140 })
archaggeafbf95f2021-04-14 08:54:05 +03005141 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005142
5143 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005144 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005145 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5146 crereq1, _ := e2termConn1.RecvSubsReq(t)
5147
5148 // Req2
5149 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005150 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005151 params2.SetMeid("RAN_NAME_1")
5152 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5153 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5154
5155 //Req1 (retransmitted)
5156 e2termConn1.RecvSubsReq(t)
5157
5158 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005159
5160 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005161 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5162
Markku Virtanenda34eec2021-05-20 08:22:04 +00005163 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005164 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005165 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005166 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005167
5168 // Del1
5169 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5170
5171 // Del2
5172 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5173
Markku Virtanenda34eec2021-05-20 08:22:04 +00005174 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5175
archaggeafbf95f2021-04-14 08:54:05 +03005176 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005177 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005178 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005179 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005180}
5181
5182//-----------------------------------------------------------------------------
5183// TestRESTSubReqAndSubDelNokSameActionParallel
5184//
5185// stub stub stub
5186// +-------+ +-------+ +---------+ +---------+
5187// | xapp2 | | xapp1 | | submgr | | e2term |
5188// +-------+ +-------+ +---------+ +---------+
5189// | | | |
5190// | | | |
5191// | | | |
5192// | | RESTSubReq1 | |
5193// | |---------------->| |
5194// | | | |
5195// | | RESTSubResp1 | |
5196// | |<----------------| |
5197// | | | SubReq1 |
5198// | | |------------->|
5199// | RESTSubReq2 | |
5200// |------------------------------>| |
5201// | | | |
5202// | RESTSubDelResp2 | |
5203// |<------------------------------| |
5204// | | | SubFail1 |
5205// | | |<-------------|
5206// | | | |
5207// | | RESTNotif1 | |
5208// | | unsuccess | |
5209// | |<----------------| |
5210// | RESTNotif2 | |
5211// | | unsuccess | |
5212// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005213// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005214// | | 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 +03005215// | |---------------->| |
5216// | | | |
5217// | | RESTSubDelResp1 | |
5218// | |<----------------| |
5219// | | | |
5220// | RESTSubDelReq2 | |
5221// |------------------------------>| |
5222// | | | |
5223// | RESTSubDelResp2 | |
5224// |<------------------------------| |
5225//
5226//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005227
archaggeafbf95f2021-04-14 08:54:05 +03005228func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005229
5230 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005231 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005232 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005233 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005234 Counter{cSubReqToE2, 1},
5235 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005236 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005237 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005238 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005239 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005240 })
5241
5242 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005243
5244 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005245 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005246 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5247 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5248
5249 // Req2
5250 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005251 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005252 params2.SetMeid("RAN_NAME_1")
5253 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5254 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5255
5256 // E2t: send SubsFail (first)
5257 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5258 fparams1.Set(crereq1)
5259 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5260
archaggeafbf95f2021-04-14 08:54:05 +03005261 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005262 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005263 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005264 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005265 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005266
5267 // Del1
5268 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5269
5270 // Del2
5271 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5272
5273 //Wait that subs is cleaned
5274 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5275 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005276 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005277 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005278}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005279
Anssi Mannila27385172021-12-22 09:41:54 +02005280//-----------------------------------------------------------------------------
5281// TestRESTSubReqPolicyAndSubDelOk
5282//
5283// stub stub
5284// +-------+ +---------+ +---------+
5285// | xapp | | submgr | | e2term |
5286// +-------+ +---------+ +---------+
5287// | | |
5288// | RESTSubReq | |
5289// |--------------->| |
5290// | RESTSubResp | |
5291// |<---------------| |
5292// | | |
5293// | | SubReq |
5294// | |------------->|
5295// | | |
5296// | | SubResp |
5297// | |<-------------|
5298// | | |
5299// | RESTNotif | |
5300// |<---------------| |
5301// | | |
5302// | | |
5303// | RESTSubDelReq | |
5304// |--------------->| |
5305// | RESTSubDelResp | |
5306// |<---------------| |
5307// | | |
5308// | | SubDelReq |
5309// | |------------->|
5310// | | |
5311// | | SubDelResp |
5312// | |<-------------|
5313// | | |
5314//
5315//-----------------------------------------------------------------------------
5316
archaggeafbf95f2021-04-14 08:54:05 +03005317func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005318
5319 // Init counter check
5320 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005321 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005322 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005323 Counter{cSubReqToE2, 1},
5324 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005325 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005326 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005327 Counter{cSubDelReqToE2, 1},
5328 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005329 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005330 })
5331
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005332 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005333 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005334 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005335
5336 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5337 xappConn1.ExpectRESTNotification(t, restSubId)
5338 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5339 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005340 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005341
5342 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5343 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5344 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5345
5346 // Wait that subs is cleaned
5347 waitSubsCleanup(t, e2SubsId, 10)
5348 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005349 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005350}
5351
5352//-----------------------------------------------------------------------------
5353// TestRESTSubReqPolicyChangeAndSubDelOk
5354//
5355// stub stub
5356// +-------+ +---------+ +---------+
5357// | xapp | | submgr | | e2term |
5358// +-------+ +---------+ +---------+
5359// | | |
5360// | RESTSubReq | |
5361// |---------------->| |
5362// | | |
5363// | RESTSubResp | |
5364// |<----------------| |
5365// | | SubReq |
5366// | |------------->|
5367// | | |
5368// | | SubResp |
5369// | |<-------------|
5370// | | |
5371// | RESTNotif | |
5372// |<----------------| |
5373// | | |
5374// | RESTSubReq | |
5375// |---------------->| |
5376// | | |
5377// | RESTSubResp | |
5378// |<----------------| |
5379// | | SubReq |
5380// | |------------->|
5381// | | |
5382// | | SubResp |
5383// | |<-------------|
5384// | | |
5385// | RESTNotif | |
5386// |<----------------| |
5387// | | |
5388// | RESTSubDelReq | |
5389// |---------------->| |
5390// | | |
5391// | | SubDelReq |
5392// | |------------->|
5393// | | |
5394// | | SubDelResp |
5395// | |<-------------|
5396// | | |
5397// | RESTSubDelResp | |
5398// |<----------------| |
5399//
5400//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005401
archaggeafbf95f2021-04-14 08:54:05 +03005402func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005403
5404 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005405 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005406 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005407 Counter{cSubReqToE2, 2},
5408 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005409 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005410 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005411 Counter{cSubDelReqToE2, 1},
5412 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005413 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005414 })
5415
5416 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005417 const e2Timeout int64 = 1
5418 const e2RetryCount int64 = 0
5419 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005420
5421 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005422 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005423 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005424 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5425
5426 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005427 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005428
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005429 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005430 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005431 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005432 params.SetTimeToWait("w200ms")
5433 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5434
5435 // Del
5436 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5437
5438 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5439 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5440
5441 // Wait that subs is cleaned
5442 waitSubsCleanup(t, e2SubsId, 10)
5443 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005444 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005445}
5446
5447//-----------------------------------------------------------------------------
aditverm323c77e2023-09-20 09:50:47 +05305448// TestRESTSubReqPolicyChangeNokAndSubDelOk
5449//
5450// stub stub
5451// +-------+ +---------+ +---------+
5452// | xapp | | submgr | | e2term |
5453// +-------+ +---------+ +---------+
5454// | | |
5455// | RESTSubReq | |
5456// |---------------->| |
5457// | | |
5458// | RESTSubResp | |
5459// |<----------------| |
5460// | | SubReq |
5461// | |------------->|
5462// | | |
5463// | | SubResp |
5464// | |<-------------|
5465// | | |
5466// | RESTNotif | |
5467// |<----------------| |
5468// | | |
5469// | RESTSubReq | |
5470// |---------------->| |
5471// | | |
5472// | RESTSubResp | |
5473// |<----------------| |
5474// | | SubReq |
5475// | |------------->|
5476// | | |
5477// | | SubFail |
5478// | |<-------------|
5479// | | |
5480// | RESTNotif | |
5481// |<----------------| |
5482// | | |
5483// | RESTSubDelReq | |
5484// |---------------->| |
5485// | | |
5486// | | SubDelReq |
5487// | |------------->|
5488// | | |
5489// | | SubDelResp |
5490// | |<-------------|
5491// | | |
5492// | RESTSubDelResp | |
5493// |<----------------| |
5494//
5495//-----------------------------------------------------------------------------
5496
5497func TestRESTSubReqPolicyChangeNokAndSubDelOk(t *testing.T) {
5498
5499 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5500 Counter{cRestSubReqFromXapp, 2},
5501 Counter{cRestSubRespToXapp, 2},
5502 Counter{cSubReqToE2, 2},
5503 Counter{cSubRespFromE2, 1},
5504 Counter{cSubFailFromE2, 1},
5505 Counter{cRestSubNotifToXapp, 1},
5506 Counter{cRestSubFailNotifToXapp, 1},
5507 Counter{cRestSubDelReqFromXapp, 1},
5508 Counter{cSubDelReqToE2, 1},
5509 Counter{cSubDelRespFromE2, 1},
5510 Counter{cRestSubDelRespToXapp, 1},
5511 })
5512
5513 const subReqCount int = 1
5514 const e2Timeout int64 = 1
5515 const e2RetryCount int64 = 0
5516 const routingNeeded bool = false
5517
5518 // Req
5519 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5520 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5521 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5522 fmt.Printf("restSubId: %v", restSubId)
5523
5524 // Policy change
5525 // GetRESTSubsReqPolicyParams sets some counters on tc side.
5526 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5527 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5528 params.SetSubscriptionID(&restSubId)
5529 params.SetTimeToWait("w200ms")
5530
5531 restSubId = xappConn1.SendRESTSubsReq(t, params)
5532 fmt.Printf("restSubId: %v", restSubId)
5533
5534 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5535 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
5536
5537 // Gnb sends RICSubscriptionFailure
5538 fparams := &teststube2ap.E2StubSubsFailParams{}
5539 fparams.Set(crereq)
5540 fparams.SetCauseVal(0, 1, 5) // CauseRIC / function-resource-limit
5541 e2termConn1.SendSubsFail(t, fparams, cremsg)
5542
5543 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5544 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
5545
5546 // Del
5547 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5548
5549 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5550 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5551
5552 // Wait that subs is cleaned
5553 waitSubsCleanup(t, e2SubsId, 10)
5554 mainCtrl.VerifyCounterValues(t)
5555 mainCtrl.VerifyAllClean(t)
5556}
5557
5558//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005559// TestRESTSubReqPolicyChangeNOk
5560//
5561// stub stub
5562// +-------+ +---------+ +---------+
5563// | xapp | | submgr | | e2term |
5564// +-------+ +---------+ +---------+
5565// | | |
5566// | RESTSubReq | |
5567// |---------------->| |
5568// | | |
5569// | RESTSubResp | |
5570// |<----------------| |
5571// | | SubReq |
5572// | |------------->|
5573// | | |
5574// | | SubResp |
5575// | |<-------------|
5576// | | |
5577// | RESTNotif | |
5578// |<----------------| |
5579// | | |
5580// | RESTSubReq | |
5581// |---------------->| |
5582// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005583// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005584// | | |
5585// | RESTSubDelReq | |
5586// |---------------->| |
5587// | | |
5588// | | SubDelReq |
5589// | |------------->|
5590// | | |
5591// | | SubDelResp |
5592// | |<-------------|
5593// | | |
5594// | RESTSubDelResp | |
5595// |<----------------| |
5596//
5597//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005598
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005599func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005600
5601 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5602 Counter{cRestSubReqFromXapp, 2},
5603 Counter{cRestSubRespToXapp, 1},
5604 Counter{cSubReqToE2, 1},
5605 Counter{cSubRespFromE2, 1},
5606 Counter{cRestSubNotifToXapp, 1},
5607 Counter{cRestSubFailToXapp, 1},
5608 Counter{cRestSubDelReqFromXapp, 1},
5609 Counter{cSubDelReqToE2, 1},
5610 Counter{cSubDelRespFromE2, 1},
5611 Counter{cRestSubDelRespToXapp, 1},
5612 })
5613
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005614 // Req
5615 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5616 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5617
5618 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005619 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5620
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005621 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005622 params.SetSubscriptionID(&restSubIdUpd)
5623 params.SetTimeToWait("w200ms")
5624
5625 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5626 assert.Equal(t, restSubId2, "")
5627
5628 // Del
5629 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5630
5631 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5632 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5633
5634 // Wait that subs is cleaned
5635 waitSubsCleanup(t, e2SubsId, 10)
5636 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005637 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005638}
5639
5640//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005641// TestRESTSubReqAndSubDelOkTwoE2termParallel
5642//
5643// stub stub stub
5644// +-------+ +---------+ +---------+ +---------+
5645// | xapp | | submgr | | e2term1 | | e2term2 |
5646// +-------+ +---------+ +---------+ +---------+
5647// | | | |
5648// | | | |
5649// | | | |
5650// | RESTSubReq1 | | |
5651// |---------------->| | |
5652// | | | |
5653// | RESTSubResp1 | | |
5654// |<----------------| | |
5655// | | SubReq1 | |
5656// | |------------->| |
5657// | | | |
5658// | RESTSubReq2 | | |
5659// |---------------->| | |
5660// | | | |
5661// | RESTSubResp2 | | |
5662// |<----------------| | |
5663// | | SubReq2 | |
5664// | |---------------------------->|
5665// | | | |
5666// | | SubResp1 | |
5667// | |<-------------| |
5668// | RESTNotif1 | | |
5669// |<----------------| | |
5670// | | SubResp2 | |
5671// | |<----------------------------|
5672// | RESTNotif2 | | |
5673// |<----------------| | |
5674// | | | |
5675// | [SUBS 1 DELETE] | |
5676// | | | |
5677// | [SUBS 2 DELETE] | |
5678// | | | |
5679//
5680//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005681
archaggeafbf95f2021-04-14 08:54:05 +03005682func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005683
5684 // Init counter check
5685 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005686 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005687 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005688 Counter{cSubReqToE2, 2},
5689 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005690 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005691 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005692 Counter{cSubDelReqToE2, 2},
5693 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005694 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005695 })
5696
5697 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005698
5699 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005700 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005701 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5702 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5703
5704 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005705 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005706 params.SetMeid("RAN_NAME_11")
5707 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5708 // would not work as notification would not be received
5709 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5710 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5711
5712 // Resp1
5713 xappConn1.ExpectRESTNotification(t, restSubId1)
5714 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5715 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005716 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005717
5718 // Resp2
5719 xappConn2.ExpectRESTNotification(t, restSubId2)
5720 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5721 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005722 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005723
5724 // Delete1
5725 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5726 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5727 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5728
5729 // Wait that subs is cleaned
5730 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5731
5732 // Delete2
5733 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5734 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5735 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5736
5737 // Wait that subs is cleaned
5738 waitSubsCleanup(t, e2SubsId2, 10)
5739
5740 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005741 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005742}
5743
5744//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005745// TestRESTSubReqInsertAndSubDelOk
5746//
5747// stub stub
5748// +-------+ +---------+ +---------+
5749// | xapp | | submgr | | e2term |
5750// +-------+ +---------+ +---------+
5751// | | |
5752// | RestSubReq | |
5753// |---------------->| |
5754// | | |
5755// | RESTSubResp | |
5756// |<----------------| |
5757// | | |
5758// | | SubReq |
5759// | |------------->|
5760// | | |
5761// | | SubResp |
5762// | |<-------------|
5763// | RESTNotif | |
5764// |<----------------| |
5765// | ... | ... |
5766// | | |
5767// | RESTSubDelReq | |
5768// |---------------->| |
5769// | | |
5770// | | SubDelReq |
5771// | |------------->|
5772// | | |
5773// | | SubDelResp |
5774// | |<-------------|
5775// | | |
5776// | RESTSubDelResp| |
5777// |<----------------| |
5778//
5779//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005780
archaggeafbf95f2021-04-14 08:54:05 +03005781func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005782
5783 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005784 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005785 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005786 Counter{cSubReqToE2, 1},
5787 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005788 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005789 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005790 Counter{cSubDelReqToE2, 1},
5791 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005792 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005793 })
5794
5795 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005796
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005797 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005798 params.SetSubActionTypes("insert")
5799
5800 // Req
5801 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5802
5803 // Del
5804 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5805
5806 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5807 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5808
5809 // Wait that subs is cleaned
5810 waitSubsCleanup(t, e2SubsId, 10)
5811 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005812 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005813}
5814
5815//-----------------------------------------------------------------------------
5816// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5817//
5818// stub stub
5819// +-------+ +---------+ +---------+
5820// | xapp | | submgr | | e2term |
5821// +-------+ +---------+ +---------+
5822// | | |
5823// | RESTSubReq | |
5824// |------------->| |
5825// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005826// | RESTSubResp | |
5827// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005828// | | SubReq |
5829// | |------------->|
5830// | | |
5831// | | SubResp |
5832// | <----|
5833// | |
5834// | Submgr restart |
5835// | |
5836// | | |
5837// | | SubDelReq |
5838// | |------------->|
5839// | | |
5840// | | SubDelResp |
5841// | |<-------------|
5842// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005843// | RESTNotif | |
5844// | unsuccess | |
5845// |<-------------| |
5846// | | |
5847// | RESTSubDelReq| |
5848// |------------->| |
5849// | | |
5850// |RESTSubDelResp| |
5851// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005852//
5853//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005854
archaggeafbf95f2021-04-14 08:54:05 +03005855func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005856
5857 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005859 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005860 Counter{cSubReqToE2, 1},
5861 Counter{cSubDelReqFromXapp, 1},
5862 Counter{cSubDelReqToE2, 1},
5863 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005864 Counter{cRestSubDelReqFromXapp, 1},
5865 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005866 })
5867
5868 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005869
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005870 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005871
5872 //Req
5873 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5874 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005875 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005876
5877 e2termConn1.RecvSubsReq(t)
5878
5879 mainCtrl.SetResetTestFlag(t, false)
5880
5881 mainCtrl.SimulateRestart(t)
5882 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5883
Anssi Mannilab43397e2021-11-16 12:06:16 +02005884 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005885 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5886 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5887
Anssi Mannilab43397e2021-11-16 12:06:16 +02005888 //Del
5889 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5890
archaggeafbf95f2021-04-14 08:54:05 +03005891 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005892 e2termConn1.TestMsgChanEmpty(t)
5893 mainCtrl.wait_registry_empty(t, 10)
5894
5895 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005896 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005897}
5898
5899//-----------------------------------------------------------------------------
5900// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5901//
5902// stub stub
5903// +-------+ +---------+ +---------+
5904// | xapp | | submgr | | e2term |
5905// +-------+ +---------+ +---------+
5906// | | |
5907// | RESTSubReq | |
5908// |---------------->| |
5909// | | |
5910// | RESTSubResp | |
5911// |<----------------| |
5912// | | SubReq |
5913// | |------------->|
5914// | | |
5915// | | SubResp |
5916// | |<-------------|
5917// | | |
5918// | RESTNotif | |
5919// |<----------------| |
5920// | | |
5921// | |
5922// | Submgr restart |
5923// | | |
5924// | RESTSubDelReq | |
5925// |---------------->| |
5926// | | |
5927// | | SubDelReq |
5928// | |------------->|
5929// | | |
5930// | | SubDelResp |
5931// | |<-------------|
5932// | | |
5933// | RESTSubDelResp | |
5934// |<----------------| |
5935//
5936//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005937
archaggeafbf95f2021-04-14 08:54:05 +03005938func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005939
5940 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005941 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005942 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005943 Counter{cSubReqToE2, 1},
5944 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005945 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005946 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005947 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005948 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005949 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005950 })
archaggeafbf95f2021-04-14 08:54:05 +03005951
5952 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005953 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005954 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005955 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005956
5957 // Check subscription
5958 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5959
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005960 mainCtrl.SimulateRestart(t)
5961 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005962
Anssi Mannila54838ed2021-11-19 11:25:01 +02005963 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5964 // That needs to be completed before successful subscription query is possible
5965 <-time.After(time.Second * 1)
5966
archaggeafbf95f2021-04-14 08:54:05 +03005967 // Check subscription
5968 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5969
5970 // Delete subscription
5971 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5972
5973 //Wait that subs is cleaned
5974 waitSubsCleanup(t, e2SubsId, 10)
5975
5976 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005977 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005978}
5979
5980//-----------------------------------------------------------------------------
5981// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5982//
5983// stub stub
5984// +-------+ +-------+ +---------+ +---------+
5985// | xapp2 | | xapp1 | | submgr | | e2term |
5986// +-------+ +-------+ +---------+ +---------+
5987// | | | |
5988// | | RESTSubReq1 | |
5989// | |---------------->| |
5990// | | | |
5991// | | RESTSubResp1 | |
5992// | |<----------------| |
5993// | | | |
5994// | | | SubReq1 |
5995// | | |------------->|
5996// | | | SubResp1 |
5997// | | |<-------------|
5998// | | RESTNotif1 | |
5999// | |<----------------| |
6000// | | | |
6001// | RESTSubReq2 | |
6002// |------------------------------>| |
6003// | | | |
6004// | RESTSubResp2 | |
6005// |<------------------------------| |
6006// | | | |
6007// | | RESTNotif2 | |
6008// |<------------------------------| |
6009// | | | |
6010// | | Submgr restart |
6011// | | | |
6012// | | RESTSubDelReq1 | |
6013// | |---------------->| |
6014// | | | |
6015// | | RESTSubDelResp1 | |
6016// | |<----------------| |
6017// | | | |
6018// | | Submgr restart |
6019// | | | |
6020// | RESTSubDelReq2 | |
6021// |------------------------------>| |
6022// | | | |
6023// | RESTSubDelResp2 | |
6024// |<------------------------------| |
6025// | | | |
6026// | | | SubDelReq2 |
6027// | | |------------->|
6028// | | | |
6029// | | | SubDelResp2 |
6030// | | |<-------------|
6031// | | | |
6032//
6033//-----------------------------------------------------------------------------
6034func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006035
6036 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006037 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006038 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006039 Counter{cSubReqToE2, 1},
6040 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006041 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006042 Counter{cMergedSubscriptions, 1},
6043 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006044 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006045 Counter{cSubDelReqToE2, 1},
6046 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006047 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006048 })
6049
archaggeafbf95f2021-04-14 08:54:05 +03006050 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02006051 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006052 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006053 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03006054
6055 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006056 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006057 params.SetMeid("RAN_NAME_1")
6058 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006059 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03006060 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006061 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006062 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006063 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03006064
6065 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
6066
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006067 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006068 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
6069
6070 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6071 // That needs to be completed before successful subscription delete is possible
6072 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03006073
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006074 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03006075 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02006076 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006077 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02006078
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006079 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006080 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
6081
6082 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6083 // That needs to be completed before successful subscription query is possible
6084 <-time.After(time.Second * 1)
6085
archaggeafbf95f2021-04-14 08:54:05 +03006086 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
6087
6088 // Delete subscription 2
6089 deleteXapp2Subscription(t, &restSubId2)
6090
6091 //Wait that subs is cleaned
6092 waitSubsCleanup(t, e2SubsId2, 10)
6093
6094 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006095 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006096}
6097
6098//-----------------------------------------------------------------------------
6099// TestRESTReportSubReqAndSubDelOk
6100//
6101// stub stub
6102// +-------+ +---------+ +---------+
6103// | xapp | | submgr | | e2term |
6104// +-------+ +---------+ +---------+
6105// | | |
6106// | RestSubReq | |
6107// |---------------->| |
6108// | | |
6109// | RESTSubResp | |
6110// |<----------------| |
6111// | | |
6112// | | SubReq |
6113// | |------------->|
6114// | | |
6115// | | SubResp |
6116// | |<-------------|
6117// | RESTNotif | |
6118// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02006119// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03006120// | |------------->|
6121// | | |
6122// | | SubResp |
6123// | |<-------------|
6124// | RESTNotif | |
6125// |<----------------| |
6126// | ... | ... |
6127// | | |
6128// | | |
6129// | RESTSubDelReq | |
6130// |---------------->| |
6131// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006132// | RESTSubDelResp| |
6133// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006134// | | SubDelReq |
6135// | |------------->|
6136// | | |
6137// | | SubDelResp |
6138// | |<-------------|
6139// | | |
archaggeafbf95f2021-04-14 08:54:05 +03006140//
6141//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006142
archaggeafbf95f2021-04-14 08:54:05 +03006143func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006144 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006145 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006146 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006147}
6148
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006149func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006150 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006151
Anssi Mannila21782182021-12-10 10:56:02 +02006152 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6153 Counter{cRestSubReqFromXapp, 1},
6154 Counter{cRestSubRespToXapp, 1},
6155 Counter{cSubReqToE2, uint64(subReqCount)},
6156 Counter{cSubRespFromE2, uint64(subReqCount)},
6157 Counter{cRestSubNotifToXapp, 1},
6158 Counter{cRestSubDelReqFromXapp, 1},
6159 Counter{cRestSubDelRespToXapp, 1},
6160 Counter{cSubDelReqToE2, uint64(subReqCount)},
6161 Counter{cSubDelRespFromE2, uint64(subReqCount)},
6162 })
6163
archaggeafbf95f2021-04-14 08:54:05 +03006164 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006165 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006166 restSubId := xappConn1.SendRESTSubsReq(t, params)
6167
6168 var e2SubsId []uint32
6169 for i := 0; i < subReqCount; i++ {
6170 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6171 xappConn1.ExpectRESTNotification(t, restSubId)
6172
6173 e2termConn1.SendSubsResp(t, crereq, cremsg)
6174 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006175 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03006176 e2SubsId = append(e2SubsId, instanceId)
6177 resp, _ := xapp.Subscription.QuerySubscriptions()
6178 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
6179 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
6180 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
6181
6182 }
6183
6184 // Del
6185 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6186
6187 for i := 0; i < subReqCount; i++ {
6188 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6189 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6190 }
6191
6192 // Wait that subs is cleaned
6193 for i := 0; i < subReqCount; i++ {
6194 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6195 }
6196
6197 xappConn1.TestMsgChanEmpty(t)
6198 e2termConn1.TestMsgChanEmpty(t)
6199 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006200 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006201 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006202}
6203
Anssi Mannila27385172021-12-22 09:41:54 +02006204//-----------------------------------------------------------------------------
6205// TestRESTTwoPolicySubReqAndSubDelOk
6206//
6207// stub stub
6208// +-------+ +---------+ +---------+
6209// | xapp | | submgr | | e2term |
6210// +-------+ +---------+ +---------+
6211// | | |
6212// | RestSubReq | |
6213// |---------------->| |
6214// | | |
6215// | RESTSubResp | |
6216// |<----------------| |
6217// | | |
6218// | | SubReq |
6219// | |------------->|
6220// | | |
6221// | | SubResp |
6222// | |<-------------|
6223// | RESTNotif | |
6224// |<----------------| |
6225// | | SubReq |
6226// | |------------->|
6227// | | |
6228// | | SubResp |
6229// | |<-------------|
6230// | RESTNotif | |
6231// |<----------------| |
6232// | | |
6233// | RESTSubDelReq | |
6234// |---------------->| |
6235// | | |
6236// | RESTSubDelResp| |
6237// |<----------------| |
6238// | | SubDelReq |
6239// | |------------->|
6240// | | |
6241// | | SubDelResp |
6242// | |<-------------|
6243// | | |
6244// | | SubDelReq |
6245// | |------------->|
6246// | | |
6247// | | SubDelResp |
6248// | |<-------------|
6249// | | |
6250//
6251//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006252
archaggeafbf95f2021-04-14 08:54:05 +03006253func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6254
archaggeafbf95f2021-04-14 08:54:05 +03006255 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006256 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006257 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006258 Counter{cSubReqToE2, 2},
6259 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006260 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006261 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006262 Counter{cSubDelReqToE2, 2},
6263 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006264 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006265 })
6266
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006267 const subReqCount int = 2
6268
archaggeafbf95f2021-04-14 08:54:05 +03006269 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006270 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006271 restSubId := xappConn1.SendRESTSubsReq(t, params)
6272 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6273
6274 assert.Equal(t, len(e2SubsIds), 2)
6275
6276 // Del
6277 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6278 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6279
6280 xappConn1.TestMsgChanEmpty(t)
6281 e2termConn1.TestMsgChanEmpty(t)
6282 mainCtrl.wait_registry_empty(t, 10)
6283
6284 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006285 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006286}
Anssi Mannila27385172021-12-22 09:41:54 +02006287
6288//-----------------------------------------------------------------------------
6289// TestRESTPolicySubReqAndSubDelOk19E2Subs
6290//
6291// stub stub
6292// +-------+ +---------+ +---------+
6293// | xapp | | submgr | | e2term |
6294// +-------+ +---------+ +---------+
6295// | | |
6296// | RestSubReq | |
6297// |---------------->| |
6298// | | |
6299// | RESTSubResp | |
6300// |<----------------| |
6301// | | | ------
6302// | | SubReq |
6303// | |------------->|
6304// | | | E2 subscription x 19
6305// | | SubResp |
6306// | |<-------------|
6307// | RESTNotif | |
6308// |<----------------| |
6309// | | | ------
6310// | RESTSubDelReq | |
6311// |---------------->| |
6312// | | |
6313// | RESTSubDelResp| |
6314// |<----------------| |
6315// | | SubDelReq | ------
6316// | |------------->|
6317// | | | E2 subscription delete x 19
6318// | | SubDelResp |
6319// | |<-------------|
6320// | | | ------
6321// | | |
6322//
6323//-----------------------------------------------------------------------------
6324
6325func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006326
archaggeafbf95f2021-04-14 08:54:05 +03006327 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006328 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006329 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006330 Counter{cSubReqToE2, 19},
6331 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006332 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006333 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006334 Counter{cSubDelReqToE2, 19},
6335 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006336 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006337 })
6338
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006339 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006340 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006341 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006342 restSubId := xappConn1.SendRESTSubsReq(t, params)
6343 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6344
6345 assert.Equal(t, len(e2SubsIds), 19)
6346
6347 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6348 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6349
6350 xappConn1.TestMsgChanEmpty(t)
6351 e2termConn1.TestMsgChanEmpty(t)
6352 mainCtrl.wait_registry_empty(t, 10)
6353
6354 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006355 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006356}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006357
Anssi Mannila27385172021-12-22 09:41:54 +02006358//-----------------------------------------------------------------------------
6359// TestRESTTwoPolicySubReqAndSubDelOk
6360//
6361// stub stub
6362// +-------+ +---------+ +---------+
6363// | xapp | | submgr | | e2term |
6364// +-------+ +---------+ +---------+
6365// | | |
6366// | RestSubReq | |
6367// |---------------->| |
6368// | | |
6369// | RESTSubResp | |
6370// |<----------------| |
6371// | | |
6372// | | SubReq |
6373// | |------------->|
6374// | | |
6375// | | SubResp |
6376// | |<-------------|
6377// | RESTNotif | |
6378// |<----------------| |
6379// | | SubReq |
6380// | |------------->|
6381// | | |
6382// | | SubResp |
6383// | |<-------------|
6384// | RESTNotif | |
6385// |<----------------| |
6386// | | |
6387// | RESTSubDelReq | |
6388// |---------------->| |
6389// | | |
6390// | RESTSubDelResp| |
6391// |<----------------| |
6392// | | SubDelReq |
6393// | |------------->|
6394// | | |
6395// | | SubDelResp |
6396// | |<-------------|
6397// | | |
6398// | | SubDelReq |
6399// | |------------->|
6400// | | |
6401// | | SubDelResp |
6402// | |<-------------|
6403// | | |
6404//
6405//-----------------------------------------------------------------------------
6406
archaggeafbf95f2021-04-14 08:54:05 +03006407func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6408
6409 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006410
6411 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006412 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006413 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006414 Counter{cSubReqToE2, uint64(subReqCount)},
6415 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006416 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006417 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006418 Counter{cSubDelReqToE2, uint64(subReqCount)},
6419 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006420 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006421 })
6422
6423 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006424 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006425 restSubId := xappConn1.SendRESTSubsReq(t, params)
6426 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6427
6428 assert.Equal(t, len(e2SubsIds), subReqCount)
6429
6430 // Del
6431 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6432 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6433
6434 xappConn1.TestMsgChanEmpty(t)
6435 e2termConn1.TestMsgChanEmpty(t)
6436 mainCtrl.wait_registry_empty(t, 10)
6437
6438 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006439 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006440}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006441
Anssi Mannila27385172021-12-22 09:41:54 +02006442//-----------------------------------------------------------------------------
6443// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6444//
6445// stub stub
6446// +-------+ +---------+ +---------+
6447// | xapp | | submgr | | e2term |
6448// +-------+ +---------+ +---------+
6449// | | |
6450// | RestSubReq | |
6451// |---------------->| |
6452// | | |
6453// | RESTSubResp | |
6454// |<----------------| |
6455// | | |
6456// | | SubReq |
6457// | |------------->|
6458// | | |
6459// | | SubResp |
6460// | |<-------------|
6461// | RESTNotif | |
6462// |<----------------| |
6463// | | SubReq |
6464// | |------------->|
6465// | | |
6466// | | SubResp |
6467// | |<-------------|
6468// | RESTNotif | |
6469// |<----------------| |
6470// | | |
6471// | RESTSubDelReq | |
6472// |---------------->| |
6473// | | |
6474// | RESTSubDelResp| |
6475// |<----------------| |
6476// | | SubDelReq |
6477// | |------------->|
6478// | | |
6479// | | SubDelResp |
6480// | |<-------------|
6481// | | |
6482// | | SubDelReq |
6483// | |------------->|
6484// | | |
6485// | | SubDelResp |
6486// | |<-------------|
6487// | | |
6488//
6489//-----------------------------------------------------------------------------
6490
archaggeafbf95f2021-04-14 08:54:05 +03006491func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6492
6493 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006494
6495 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006496 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006497 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006498 Counter{cSubReqToE2, uint64(subReqCount)},
6499 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006500 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006501 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006502 Counter{cSubDelReqToE2, uint64(subReqCount)},
6503 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006504 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006505 })
6506
6507 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006508 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006509 restSubId := xappConn1.SendRESTSubsReq(t, params)
6510 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6511
6512 assert.Equal(t, len(e2SubsIds), subReqCount)
6513
6514 // Del
6515 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6516 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6517
6518 xappConn1.TestMsgChanEmpty(t)
6519 e2termConn1.TestMsgChanEmpty(t)
6520 mainCtrl.wait_registry_empty(t, 10)
6521
6522 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006523 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006524}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006525
Anssi Mannila27385172021-12-22 09:41:54 +02006526//-----------------------------------------------------------------------------
6527// TestRESTReportSubReqAndSubDelOk19E2Subs
6528//
6529// stub stub
6530// +-------+ +---------+ +---------+
6531// | xapp | | submgr | | e2term |
6532// +-------+ +---------+ +---------+
6533// | | |
6534// | RestSubReq | |
6535// |---------------->| |
6536// | | |
6537// | RESTSubResp | |
6538// |<----------------| |
6539// | | | ------
6540// | | SubReq |
6541// | |------------->|
6542// | | | E2 subscription x 19
6543// | | SubResp |
6544// | |<-------------|
6545// | RESTNotif | |
6546// |<----------------| |
6547// | | | ------
6548// | RESTSubDelReq | |
6549// |---------------->| |
6550// | | |
6551// | RESTSubDelResp| |
6552// |<----------------| |
6553// | | SubDelReq | ------
6554// | |------------->|
6555// | | | E2 subscription delete x 19
6556// | | SubDelResp |
6557// | |<-------------|
6558// | | | ------
6559// | | |
6560//
6561//-----------------------------------------------------------------------------
6562
6563func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006564
6565 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006566
6567 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006568 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006569 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006570 Counter{cSubReqToE2, uint64(subReqCount)},
6571 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006572 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006573 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006574 Counter{cSubDelReqToE2, uint64(subReqCount)},
6575 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006576 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006577 })
6578
6579 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006580 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006581 restSubId := xappConn1.SendRESTSubsReq(t, params)
6582 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6583
6584 assert.Equal(t, len(e2SubsIds), subReqCount)
6585
6586 // Del
6587 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6588 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6589
6590 xappConn1.TestMsgChanEmpty(t)
6591 e2termConn1.TestMsgChanEmpty(t)
6592 mainCtrl.wait_registry_empty(t, 10)
6593
6594 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006595 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006596}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006597
Anssi Mannila27385172021-12-22 09:41:54 +02006598//-----------------------------------------------------------------------------
6599// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6600//
6601// stub stub stub
6602// +-------+ +-------+ +---------+ +---------+
6603// | xapp2 | | xapp1 | | submgr | | e2term |
6604// +-------+ +-------+ +---------+ +---------+
6605// | | | |
6606// | | RESTSubReq1 | |
6607// | |------------->| |
6608// | | RESTSubResp1 | |
6609// | |<-------------| |
6610// | | | |
6611// | | | SubReq1 |
6612// | | |------------->|
6613// | | | |
6614// | RESTSubReq2 | |
6615// |------------------------>| |
6616// | RESTSubResp2 | |
6617// |<------------------------| |
6618// | | | |
6619// | | | SubReq2 |
6620// | | |------------->|
6621// | | | |
6622// | | | SubResp1 |
6623// | | |<-------------|
6624// | | RESTNotif1 | |
6625// | |<-------------| |
6626// | | | |
6627// | | | SubResp2 |
6628// | | |<-------------|
6629// | RESTNotif2 | |
6630// |<------------------------| |
6631// | | | |
6632// | | [SUBS 1 DELETE] |
6633// | | | |
6634// | | [SUBS 2 DELETE] |
6635// | | | |
6636//
6637//-----------------------------------------------------------------------------
6638
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006639func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006640
6641 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006642 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006643 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006644 Counter{cSubReqToE2, 2},
6645 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006646 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006647 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006648 Counter{cSubDelReqToE2, 2},
6649 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006650 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006651 })
6652
6653 // Req1
6654 var params *teststube2ap.RESTSubsReqParams = nil
6655
6656 //Subs Create
6657 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006658 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006659
6660 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6661
6662 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006663 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006664 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006665 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006666 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6667
6668 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006669 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006670 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6671 xappConn2.ExpectRESTNotification(t, restSubId2)
6672 e2termConn1.SendSubsResp(t, crereq, cremsg)
6673 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6674
6675 deleteXapp1Subscription(t, &restSubId1)
6676 deleteXapp2Subscription(t, &restSubId2)
6677
6678 waitSubsCleanup(t, e2SubsId1, 10)
6679 waitSubsCleanup(t, e2SubsId2, 10)
6680
6681 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006682 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006683}
6684
Anssi Mannila27385172021-12-22 09:41:54 +02006685//-----------------------------------------------------------------------------
6686// TestRESTSubReqReportSameActionDiffActionListLen
6687//
6688// stub stub stub
6689// +-------+ +-------+ +---------+ +---------+
6690// | xapp2 | | xapp1 | | submgr | | e2term |
6691// +-------+ +-------+ +---------+ +---------+
6692// | | | |
6693// | | RESTSubReq1 | |
6694// | |------------->| |
6695// | | RESTSubResp1 | |
6696// | |<-------------| |
6697// | | | |
6698// | | | SubReq1 |
6699// | | |------------->|
6700// | | | |
6701// | RESTSubReq2 | |
6702// |------------------------>| |
6703// | RESTSubResp2 | |
6704// |<------------------------| |
6705// | | | |
6706// | | | SubReq2 |
6707// | | |------------->|
6708// | | | |
6709// | | | SubResp1 |
6710// | | |<-------------|
6711// | | RESTNotif1 | |
6712// | |<-------------| |
6713// | | | |
6714// | | | SubResp2 |
6715// | | |<-------------|
6716// | RESTNotif2 | |
6717// |<------------------------| |
6718// | | | |
6719// | | [SUBS 1 DELETE] |
6720// | | | |
6721// | | [SUBS 2 DELETE] |
6722// | | | |
6723//
6724//-----------------------------------------------------------------------------
6725
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006726func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006727
6728 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006729 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006730 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006731 Counter{cSubReqToE2, 2},
6732 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006733 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006734 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006735 Counter{cSubDelReqToE2, 2},
6736 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006737 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006738 })
6739
6740 // Req1
6741 var params *teststube2ap.RESTSubsReqParams = nil
6742
6743 //Subs Create
6744 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006745 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006746
6747 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6748
6749 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006750 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006751 params.SetMeid("RAN_NAME_1")
6752
6753 actionId := int64(1)
6754 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006755 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006756 subsequestActionType := "continue"
6757 timeToWait := "w10ms"
6758 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6759
6760 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006761 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006762 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6763 xappConn2.ExpectRESTNotification(t, restSubId2)
6764 e2termConn1.SendSubsResp(t, crereq, cremsg)
6765 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6766
6767 deleteXapp1Subscription(t, &restSubId1)
6768 deleteXapp2Subscription(t, &restSubId2)
6769
6770 waitSubsCleanup(t, e2SubsId1, 10)
6771 waitSubsCleanup(t, e2SubsId2, 10)
6772
6773 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006774 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006775}
6776
Anssi Mannila27385172021-12-22 09:41:54 +02006777//-----------------------------------------------------------------------------
6778// TestRESTSubReqReportSameActionDiffActionID
6779//
6780// stub stub stub
6781// +-------+ +-------+ +---------+ +---------+
6782// | xapp2 | | xapp1 | | submgr | | e2term |
6783// +-------+ +-------+ +---------+ +---------+
6784// | | | |
6785// | | RESTSubReq1 | |
6786// | |------------->| |
6787// | | RESTSubResp1 | |
6788// | |<-------------| |
6789// | | | |
6790// | | | SubReq1 |
6791// | | |------------->|
6792// | | | |
6793// | RESTSubReq2 | |
6794// |------------------------>| |
6795// | RESTSubResp2 | |
6796// |<------------------------| |
6797// | | | |
6798// | | | SubReq2 |
6799// | | |------------->|
6800// | | | |
6801// | | | SubResp1 |
6802// | | |<-------------|
6803// | | RESTNotif1 | |
6804// | |<-------------| |
6805// | | | |
6806// | | | SubResp2 |
6807// | | |<-------------|
6808// | RESTNotif2 | |
6809// |<------------------------| |
6810// | | | |
6811// | | [SUBS 1 DELETE] |
6812// | | | |
6813// | | [SUBS 2 DELETE] |
6814// | | | |
6815//
6816//-----------------------------------------------------------------------------
6817
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006818func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006819
6820 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006821 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006822 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006823 Counter{cSubReqToE2, 2},
6824 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006825 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006826 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006827 Counter{cSubDelReqToE2, 2},
6828 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006829 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006830 })
6831
6832 // Req1
6833 var params *teststube2ap.RESTSubsReqParams = nil
6834
6835 //Subs Create
6836 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006837 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006838
6839 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6840
6841 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006842 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006843 params.SetMeid("RAN_NAME_1")
6844 params.SetSubActionIDs(int64(2))
6845
6846 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006847 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006848 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6849 xappConn2.ExpectRESTNotification(t, restSubId2)
6850 e2termConn1.SendSubsResp(t, crereq, cremsg)
6851 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6852
6853 deleteXapp1Subscription(t, &restSubId1)
6854 deleteXapp2Subscription(t, &restSubId2)
6855
6856 waitSubsCleanup(t, e2SubsId1, 10)
6857 waitSubsCleanup(t, e2SubsId2, 10)
6858
6859 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006860 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006861}
6862
Anssi Mannila27385172021-12-22 09:41:54 +02006863//-----------------------------------------------------------------------------
6864// TestRESTSubReqDiffActionType
6865//
6866// stub stub stub
6867// +-------+ +-------+ +---------+ +---------+
6868// | xapp2 | | xapp1 | | submgr | | e2term |
6869// +-------+ +-------+ +---------+ +---------+
6870// | | | |
6871// | | RESTSubReq1 | |
6872// | |------------->| |
6873// | | RESTSubResp1 | |
6874// | |<-------------| |
6875// | | | |
6876// | | | SubReq1 |
6877// | | |------------->|
6878// | | | |
6879// | RESTSubReq2 | |
6880// |------------------------>| |
6881// | RESTSubResp2 | |
6882// |<------------------------| |
6883// | | | |
6884// | | | SubReq2 |
6885// | | |------------->|
6886// | | | |
6887// | | | SubResp1 |
6888// | | |<-------------|
6889// | | RESTNotif1 | |
6890// | |<-------------| |
6891// | | | |
6892// | | | SubResp2 |
6893// | | |<-------------|
6894// | RESTNotif2 | |
6895// |<------------------------| |
6896// | | | |
6897// | | [SUBS 1 DELETE] |
6898// | | | |
6899// | | [SUBS 2 DELETE] |
6900// | | | |
6901//
6902//-----------------------------------------------------------------------------
6903
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006904func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006905
6906 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006907 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006908 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006909 Counter{cSubReqToE2, 2},
6910 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006911 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006912 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006913 Counter{cSubDelReqToE2, 2},
6914 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006915 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006916 })
6917
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006918 const e2Timeout int64 = 2
6919 const e2RetryCount int64 = 2
6920 const routingNeeded bool = true
6921
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006922 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006923 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006924 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006925
6926 //Subs Create
6927 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006928 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006929
6930 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6931
6932 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006933 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006934 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006935 params.SetMeid("RAN_NAME_1")
6936
6937 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006938 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006939 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6940 xappConn2.ExpectRESTNotification(t, restSubId2)
6941 e2termConn1.SendSubsResp(t, crereq, cremsg)
6942 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6943
6944 deleteXapp1Subscription(t, &restSubId1)
6945 deleteXapp2Subscription(t, &restSubId2)
6946
6947 waitSubsCleanup(t, e2SubsId1, 10)
6948 waitSubsCleanup(t, e2SubsId2, 10)
6949
6950 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006951 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006952}
6953
Anssi Mannila27385172021-12-22 09:41:54 +02006954//-----------------------------------------------------------------------------
6955// TestRESTSubReqPolicyAndSubDelOkSameAction
6956//
6957// stub stub stub
6958// +-------+ +-------+ +---------+ +---------+
6959// | xapp2 | | xapp1 | | submgr | | e2term |
6960// +-------+ +-------+ +---------+ +---------+
6961// | | | |
6962// | | RESTSubReq1 | |
6963// | |------------->| |
6964// | | RESTSubResp1 | |
6965// | |<-------------| |
6966// | | | |
6967// | | | SubReq1 |
6968// | | |------------->|
6969// | | | |
6970// | RESTSubReq2 | |
6971// |------------------------>| |
6972// | RESTSubResp2 | |
6973// |<------------------------| |
6974// | | | |
6975// | | | SubReq2 |
6976// | | |------------->|
6977// | | | |
6978// | | | SubResp1 |
6979// | | |<-------------|
6980// | | RESTNotif1 | |
6981// | |<-------------| |
6982// | | | |
6983// | | | SubResp2 |
6984// | | |<-------------|
6985// | RESTNotif2 | |
6986// |<------------------------| |
6987// | | | |
6988// | | [SUBS 1 DELETE] |
6989// | | | |
6990// | | [SUBS 2 DELETE] |
6991// | | | |
6992//
6993//-----------------------------------------------------------------------------
6994
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006995func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006996
6997 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006998 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006999 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007000 Counter{cSubReqToE2, 2},
7001 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007002 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007003 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007004 Counter{cSubDelReqToE2, 2},
7005 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007006 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007007 })
7008
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007009 const e2Timeout int64 = 2
7010 const e2RetryCount int64 = 2
7011 const routingNeeded bool = true
7012
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007013 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007014 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007015 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007016
7017 //Subs Create
7018 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007019 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007020
7021 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7022
7023 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007024 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007025 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007026 params.SetMeid("RAN_NAME_1")
7027
7028 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007029 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007030 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7031 xappConn2.ExpectRESTNotification(t, restSubId2)
7032 e2termConn1.SendSubsResp(t, crereq, cremsg)
7033 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7034
7035 deleteXapp1Subscription(t, &restSubId1)
7036 deleteXapp2Subscription(t, &restSubId2)
7037
7038 waitSubsCleanup(t, e2SubsId1, 10)
7039 waitSubsCleanup(t, e2SubsId2, 10)
7040
7041 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007042 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007043}
7044
Anssi Mannila27385172021-12-22 09:41:54 +02007045//-----------------------------------------------------------------------------
7046// TestRESTSubReqReportSameActionDiffActionDefinitionLen
7047//
7048// stub stub stub
7049// +-------+ +-------+ +---------+ +---------+
7050// | xapp2 | | xapp1 | | submgr | | e2term |
7051// +-------+ +-------+ +---------+ +---------+
7052// | | | |
7053// | | RESTSubReq1 | |
7054// | |------------->| |
7055// | | RESTSubResp1 | |
7056// | |<-------------| |
7057// | | | |
7058// | | | SubReq1 |
7059// | | |------------->|
7060// | | | |
7061// | RESTSubReq2 | |
7062// |------------------------>| |
7063// | RESTSubResp2 | |
7064// |<------------------------| |
7065// | | | |
7066// | | | SubReq2 |
7067// | | |------------->|
7068// | | | |
7069// | | | SubResp1 |
7070// | | |<-------------|
7071// | | RESTNotif1 | |
7072// | |<-------------| |
7073// | | | |
7074// | | | SubResp2 |
7075// | | |<-------------|
7076// | RESTNotif2 | |
7077// |<------------------------| |
7078// | | | |
7079// | | [SUBS 1 DELETE] |
7080// | | | |
7081// | | [SUBS 2 DELETE] |
7082// | | | |
7083//
7084//-----------------------------------------------------------------------------
7085
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007086func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007087
7088 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007089 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007090 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007091 Counter{cSubReqToE2, 2},
7092 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007093 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007094 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007095 Counter{cSubDelReqToE2, 2},
7096 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007097 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007098 })
7099
7100 // Req1
7101 var params *teststube2ap.RESTSubsReqParams = nil
7102
7103 //Subs Create
7104 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007105 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007106
7107 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7108
7109 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007110 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007111 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007112 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007113 params.SetSubActionDefinition(actionDefinition)
7114
7115 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007116 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007117 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7118 xappConn2.ExpectRESTNotification(t, restSubId2)
7119 e2termConn1.SendSubsResp(t, crereq, cremsg)
7120 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7121
7122 deleteXapp1Subscription(t, &restSubId1)
7123 deleteXapp2Subscription(t, &restSubId2)
7124
7125 waitSubsCleanup(t, e2SubsId1, 10)
7126 waitSubsCleanup(t, e2SubsId2, 10)
7127
7128 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007129 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007130}
7131
Anssi Mannila27385172021-12-22 09:41:54 +02007132//-----------------------------------------------------------------------------
7133// TestRESTSubReqReportSameActionDiffActionDefinitionContents
7134//
7135// stub stub stub
7136// +-------+ +-------+ +---------+ +---------+
7137// | xapp2 | | xapp1 | | submgr | | e2term |
7138// +-------+ +-------+ +---------+ +---------+
7139// | | | |
7140// | | RESTSubReq1 | |
7141// | |------------->| |
7142// | | RESTSubResp1 | |
7143// | |<-------------| |
7144// | | | |
7145// | | | SubReq1 |
7146// | | |------------->|
7147// | | | |
7148// | RESTSubReq2 | |
7149// |------------------------>| |
7150// | RESTSubResp2 | |
7151// |<------------------------| |
7152// | | | |
7153// | | | SubReq2 |
7154// | | |------------->|
7155// | | | |
7156// | | | SubResp1 |
7157// | | |<-------------|
7158// | | RESTNotif1 | |
7159// | |<-------------| |
7160// | | | |
7161// | | | SubResp2 |
7162// | | |<-------------|
7163// | RESTNotif2 | |
7164// |<------------------------| |
7165// | | | |
7166// | | [SUBS 1 DELETE] |
7167// | | | |
7168// | | [SUBS 2 DELETE] |
7169// | | | |
7170//
7171//-----------------------------------------------------------------------------
7172
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007173func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007174
7175 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007176 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007177 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007178 Counter{cSubReqToE2, 2},
7179 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007180 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007181 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007182 Counter{cSubDelReqToE2, 2},
7183 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007184 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007185 })
7186
7187 // Req1
7188 var params *teststube2ap.RESTSubsReqParams = nil
7189
7190 //Subs Create
7191 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007192 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007193
7194 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7195
7196 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007197 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007198 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007199 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007200 params.SetSubActionDefinition(actionDefinition)
7201
7202 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007203 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007204 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7205 xappConn2.ExpectRESTNotification(t, restSubId2)
7206 e2termConn1.SendSubsResp(t, crereq, cremsg)
7207 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7208
7209 deleteXapp1Subscription(t, &restSubId1)
7210 deleteXapp2Subscription(t, &restSubId2)
7211
7212 waitSubsCleanup(t, e2SubsId1, 10)
7213 waitSubsCleanup(t, e2SubsId2, 10)
7214
7215 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007216 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007217}
7218
Anssi Mannila27385172021-12-22 09:41:54 +02007219//-----------------------------------------------------------------------------
7220// TestRESTSubReqReportSameActionDiffSubsAction
7221//
7222// stub stub stub
7223// +-------+ +-------+ +---------+ +---------+
7224// | xapp2 | | xapp1 | | submgr | | e2term |
7225// +-------+ +-------+ +---------+ +---------+
7226// | | | |
7227// | | RESTSubReq1 | |
7228// | |------------->| |
7229// | | RESTSubResp1 | |
7230// | |<-------------| |
7231// | | | |
7232// | | | SubReq1 |
7233// | | |------------->|
7234// | | | |
7235// | RESTSubReq2 | |
7236// |------------------------>| |
7237// | RESTSubResp2 | |
7238// |<------------------------| |
7239// | | | |
7240// | | | SubReq2 |
7241// | | |------------->|
7242// | | | |
7243// | | | SubResp1 |
7244// | | |<-------------|
7245// | | RESTNotif1 | |
7246// | |<-------------| |
7247// | | | |
7248// | | | SubResp2 |
7249// | | |<-------------|
7250// | RESTNotif2 | |
7251// |<------------------------| |
7252// | | | |
7253// | | [SUBS 1 DELETE] |
7254// | | | |
7255// | | [SUBS 2 DELETE] |
7256// | | | |
7257//
7258//-----------------------------------------------------------------------------
7259
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007260func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007261
7262 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007263 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007264 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007265 Counter{cSubReqToE2, 2},
7266 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007267 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007268 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007269 Counter{cSubDelReqToE2, 2},
7270 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007271 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007272 })
7273
7274 // Req1
7275 var params *teststube2ap.RESTSubsReqParams = nil
7276
7277 //Subs Create
7278 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007279 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007280
7281 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7282
7283 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007284 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007285 params.SetMeid("RAN_NAME_1")
7286 params.SetTimeToWait("w200ms")
7287 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007288 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007289 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7290 xappConn2.ExpectRESTNotification(t, restSubId2)
7291 e2termConn1.SendSubsResp(t, crereq, cremsg)
7292 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7293
7294 deleteXapp1Subscription(t, &restSubId1)
7295 deleteXapp2Subscription(t, &restSubId2)
7296
7297 waitSubsCleanup(t, e2SubsId1, 10)
7298 waitSubsCleanup(t, e2SubsId2, 10)
7299
7300 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007301 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007302}
7303
Anssi Mannila51122392021-05-25 11:51:31 +03007304//-----------------------------------------------------------------------------
7305// TestRESTUnpackSubscriptionResponseDecodeFail
7306//
7307// stub stub
7308// +-------+ +---------+ +---------+
7309// | xapp | | submgr | | e2term |
7310// +-------+ +---------+ +---------+
7311// | | |
7312// | RestSubReq | |
7313// |---------------->| |
7314// | | |
7315// | RESTSubResp | |
7316// |<----------------| |
7317// | | |
7318// | | SubReq |
7319// | |------------->|
7320// | | |
7321// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007322// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007323// | | |
7324// | | SubReq |
7325// | |------------->|
7326// | | |
7327// | | SubFail | Duplicated action
7328// | |<-------------|
7329// | RESTNotif (fail)| |
7330// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007331// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007332// | [SUBS DELETE] |
7333// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007334//
7335//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007336
Anssi Mannila51122392021-05-25 11:51:31 +03007337func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007338
7339 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7340 Counter{cRestSubReqFromXapp, 1},
7341 Counter{cRestSubRespToXapp, 1},
7342 Counter{cSubReqToE2, 1},
7343 Counter{cSubReqTimerExpiry, 1},
7344 Counter{cSubReReqToE2, 1},
7345 Counter{cSubRespFromE2, 1},
7346 Counter{cSubFailFromE2, 1},
7347 Counter{cRestSubFailNotifToXapp, 1},
7348 Counter{cRestSubDelReqFromXapp, 1},
7349 Counter{cRestSubDelRespToXapp, 1},
7350 })
7351
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007352 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007353
7354 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007355 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007356 restSubId := xappConn1.SendRESTSubsReq(t, params)
7357
7358 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7359 // Decode of this response fails which will result resending original request
7360 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7361
7362 _, cremsg = e2termConn1.RecvSubsReq(t)
7363
Markku Virtanen55d2a282021-06-04 14:46:56 +03007364 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007365
7366 // Subscription already created in E2 Node.
7367 fparams := &teststube2ap.E2StubSubsFailParams{}
7368 fparams.Set(crereq)
7369 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7370 e2termConn1.SendSubsFail(t, fparams, cremsg)
7371
Anssi Mannila51122392021-05-25 11:51:31 +03007372 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007373 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007374
Anssi Mannilab43397e2021-11-16 12:06:16 +02007375 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7376
Anssi Mannila51122392021-05-25 11:51:31 +03007377 // Wait that subs is cleaned
7378 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7379
7380 xappConn1.TestMsgChanEmpty(t)
7381 e2termConn1.TestMsgChanEmpty(t)
7382 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007383 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007384 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007385}
7386
7387//-----------------------------------------------------------------------------
7388// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7389//
7390// stub stub
7391// +-------+ +---------+ +---------+
7392// | xapp | | submgr | | e2term |
7393// +-------+ +---------+ +---------+
7394// | | |
7395// | RestSubReq | |
7396// |---------------->| |
7397// | | |
7398// | RESTSubResp | |
7399// |<----------------| |
7400// | | |
7401// | | SubReq |
7402// | |------------->|
7403// | | |
7404// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007405// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007406// | | |
7407// | | SubReq |
7408// | |------------->|
7409// | | |
7410// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007411// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007412// | RESTNotif (fail)| |
7413// |<----------------| |
7414// | | SubDelReq |
7415// | |------------->|
7416// | | |
7417// | | SubDelResp |
7418// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007419// | | |
7420// | [SUBS DELETE] |
7421// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007422//
7423//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007424
Anssi Mannila51122392021-05-25 11:51:31 +03007425func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007426
7427 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7428 Counter{cRestSubReqFromXapp, 1},
7429 Counter{cRestSubRespToXapp, 1},
7430 Counter{cSubReqToE2, 1},
7431 Counter{cSubReqTimerExpiry, 2},
7432 Counter{cSubReReqToE2, 1},
7433 Counter{cSubRespFromE2, 1},
7434 Counter{cSubFailFromE2, 1},
7435 Counter{cRestSubFailNotifToXapp, 1},
7436 Counter{cRestSubDelReqFromXapp, 1},
7437 Counter{cRestSubDelRespToXapp, 1},
7438 Counter{cSubDelReqToE2, 1},
7439 Counter{cSubDelRespFromE2, 1},
7440 })
7441
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007442 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007443
7444 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007445 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007446 restSubId := xappConn1.SendRESTSubsReq(t, params)
7447
7448 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7449
Anssi Mannila21782182021-12-10 10:56:02 +02007450 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007451 orgInstanceId := crereq.RequestId.InstanceId
7452 crereq.RequestId.InstanceId = 0
7453 e2termConn1.SendSubsResp(t, crereq, cremsg)
7454
7455 _, cremsg = e2termConn1.RecvSubsReq(t)
7456
Markku Virtanen55d2a282021-06-04 14:46:56 +03007457 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007458
Anssi Mannila21782182021-12-10 10:56:02 +02007459 // 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 +03007460 fparams := &teststube2ap.E2StubSubsFailParams{}
7461 fparams.Set(crereq)
7462 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7463 e2termConn1.SendSubsFail(t, fparams, cremsg)
7464
7465 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7466 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7467
7468 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007469 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007470
Anssi Mannilab43397e2021-11-16 12:06:16 +02007471 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7472
Anssi Mannila51122392021-05-25 11:51:31 +03007473 // Wait that subs is cleaned
7474 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7475
7476 xappConn1.TestMsgChanEmpty(t)
7477 e2termConn1.TestMsgChanEmpty(t)
7478 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007479 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007480 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007481}
7482
7483//-----------------------------------------------------------------------------
7484// TestRESTUnpackSubscriptionResponseNoTransaction
7485//
7486// stub stub
7487// +-------+ +---------+ +---------+
7488// | xapp | | submgr | | e2term |
7489// +-------+ +---------+ +---------+
7490// | | |
7491// | RestSubReq | |
7492// |---------------->| |
7493// | | |
7494// | RESTSubResp | |
7495// |<----------------| |
7496// | | |
7497// | | SubReq |
7498// | |------------->|
7499// | | |
7500// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007501// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007502// | | |
7503// | | SubReq |
7504// | |------------->|
7505// | | |
7506// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007507// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007508// | RESTNotif (fail)| |
7509// |<----------------| |
7510// | | SubDelReq |
7511// | |------------->|
7512// | | |
7513// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007514// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007515// | | |
7516// | | SubDelReq |
7517// | |------------->|
7518// | | |
7519// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007520// | |<-------------| Ongoing transaction not found.
7521// | | |
7522// | [SUBS DELETE] |
7523// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007524//
7525//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007526
Anssi Mannila51122392021-05-25 11:51:31 +03007527func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007528
7529 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7530 Counter{cRestSubReqFromXapp, 1},
7531 Counter{cRestSubRespToXapp, 1},
7532 Counter{cSubReqToE2, 1},
7533 Counter{cSubReqTimerExpiry, 2},
7534 Counter{cSubReReqToE2, 1},
7535 Counter{cSubRespFromE2, 1},
7536 Counter{cSubFailFromE2, 1},
7537 Counter{cRestSubFailNotifToXapp, 1},
7538 Counter{cRestSubDelReqFromXapp, 1},
7539 Counter{cRestSubDelRespToXapp, 1},
7540 Counter{cSubDelReqToE2, 1},
7541 Counter{cSubDelReqTimerExpiry, 2},
7542 Counter{cSubDelReReqToE2, 1},
7543 Counter{cSubDelRespFromE2, 2},
7544 })
7545
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007546 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007547
7548 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007549 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007550 restSubId := xappConn1.SendRESTSubsReq(t, params)
7551
7552 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7553
7554 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7555 // No transaction exist for this response which will result resending original request
7556 e2termConn1.SendSubsResp(t, crereq, cremsg)
7557
7558 _, cremsg = e2termConn1.RecvSubsReq(t)
7559
Markku Virtanen55d2a282021-06-04 14:46:56 +03007560 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007561
7562 // Subscription already created in E2 Node.
7563 fparams := &teststube2ap.E2StubSubsFailParams{}
7564 fparams.Set(crereq)
7565 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7566 e2termConn1.SendSubsFail(t, fparams, cremsg)
7567
7568 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7569 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7570
7571 // Resending happens because there no transaction
7572 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7573 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7574
7575 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007576 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007577
Anssi Mannilab43397e2021-11-16 12:06:16 +02007578 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7579
Anssi Mannila51122392021-05-25 11:51:31 +03007580 // Wait that subs is cleaned
7581 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7582
7583 xappConn1.TestMsgChanEmpty(t)
7584 e2termConn1.TestMsgChanEmpty(t)
7585 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007586 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007587 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007588}
7589
7590//-----------------------------------------------------------------------------
7591// TestRESTUnpackSubscriptionFailureDecodeFail
7592//
7593// stub stub
7594// +-------+ +---------+ +---------+
7595// | xapp | | submgr | | e2term |
7596// +-------+ +---------+ +---------+
7597// | | |
7598// | RestSubReq | |
7599// |---------------->| |
7600// | | |
7601// | RESTSubResp | |
7602// |<----------------| |
7603// | | |
7604// | | SubReq |
7605// | |------------->|
7606// | | |
7607// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007608// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007609// | | |
7610// | | SubReq |
7611// | |------------->|
7612// | | |
7613// | | SubFail | Duplicated action
7614// | |<-------------|
7615// | RESTNotif (fail)| |
7616// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007617// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007618// | [SUBS DELETE] |
7619// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007620//
7621//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007622
Anssi Mannila51122392021-05-25 11:51:31 +03007623func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007624
7625 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7626 Counter{cRestSubReqFromXapp, 1},
7627 Counter{cRestSubRespToXapp, 1},
7628 Counter{cSubReqToE2, 1},
7629 Counter{cSubReqTimerExpiry, 1},
7630 Counter{cSubReReqToE2, 1},
7631 Counter{cSubFailFromE2, 2},
7632 Counter{cRestSubFailNotifToXapp, 1},
7633 Counter{cRestSubDelReqFromXapp, 1},
7634 Counter{cRestSubDelRespToXapp, 1},
7635 })
7636
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007637 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007638
7639 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007640 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007641 restSubId := xappConn1.SendRESTSubsReq(t, params)
7642
7643 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7644
7645 // Decode of this response fails which will result resending original request
7646 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7647
7648 _, cremsg = e2termConn1.RecvSubsReq(t)
7649
Markku Virtanen55d2a282021-06-04 14:46:56 +03007650 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007651
7652 // Subscription already created in E2 Node.
7653 fparams := &teststube2ap.E2StubSubsFailParams{}
7654 fparams.Set(crereq)
7655 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7656 e2termConn1.SendSubsFail(t, fparams, cremsg)
7657
Anssi Mannila51122392021-05-25 11:51:31 +03007658 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007659 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007660
Anssi Mannilab43397e2021-11-16 12:06:16 +02007661 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7662
Anssi Mannila51122392021-05-25 11:51:31 +03007663 // Wait that subs is cleaned
7664 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7665
7666 xappConn1.TestMsgChanEmpty(t)
7667 e2termConn1.TestMsgChanEmpty(t)
7668 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007669 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007670 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007671}
7672
7673//-----------------------------------------------------------------------------
7674// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7675//
7676// stub stub
7677// +-------+ +---------+ +---------+
7678// | xapp | | submgr | | e2term |
7679// +-------+ +---------+ +---------+
7680// | | |
7681// | RestSubReq | |
7682// |---------------->| |
7683// | | |
7684// | RESTSubResp | |
7685// |<----------------| |
7686// | | |
7687// | | SubReq |
7688// | |------------->|
7689// | | |
7690// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007691// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007692// | | |
7693// | | SubReq |
7694// | |------------->|
7695// | | |
7696// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007697// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007698// | RESTNotif (fail)| |
7699// |<----------------| |
7700// | | SubDelReq |
7701// | |------------->|
7702// | | |
7703// | | SubDelResp |
7704// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007705// | | |
7706// | [SUBS DELETE] |
7707// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007708//
7709//-----------------------------------------------------------------------------
7710func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007711
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007712 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007713
Anssi Mannila21782182021-12-10 10:56:02 +02007714 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7715 Counter{cRestSubReqFromXapp, 1},
7716 Counter{cRestSubRespToXapp, 1},
7717 Counter{cSubReqToE2, 1},
7718 Counter{cSubReqTimerExpiry, 2},
7719 Counter{cSubReReqToE2, 1},
7720 Counter{cSubFailFromE2, 2},
7721 Counter{cRestSubFailNotifToXapp, 1},
7722 Counter{cRestSubDelReqFromXapp, 1},
7723 Counter{cRestSubDelRespToXapp, 1},
7724 Counter{cSubDelReqToE2, 1},
7725 Counter{cSubDelRespFromE2, 1},
7726 })
7727
Anssi Mannila51122392021-05-25 11:51:31 +03007728 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007729 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007730 restSubId := xappConn1.SendRESTSubsReq(t, params)
7731
7732 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7733
Anssi Mannila21782182021-12-10 10:56:02 +02007734 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007735 fparams := &teststube2ap.E2StubSubsFailParams{}
7736 fparams.Set(crereq)
7737 fparams.Fail.RequestId.InstanceId = 0
7738 e2termConn1.SendSubsFail(t, fparams, cremsg)
7739
7740 _, cremsg = e2termConn1.RecvSubsReq(t)
7741
Markku Virtanen55d2a282021-06-04 14:46:56 +03007742 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007743
Anssi Mannila21782182021-12-10 10:56:02 +02007744 // 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 +03007745 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7746 e2termConn1.SendSubsFail(t, fparams, cremsg)
7747
7748 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7749 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7750
7751 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007752 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007753
Anssi Mannilab43397e2021-11-16 12:06:16 +02007754 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7755
Anssi Mannila51122392021-05-25 11:51:31 +03007756 // Wait that subs is cleaned
7757 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7758
7759 xappConn1.TestMsgChanEmpty(t)
7760 e2termConn1.TestMsgChanEmpty(t)
7761 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007762 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007763 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007764}
7765
7766//-----------------------------------------------------------------------------
7767// TestRESTUnpackSubscriptionFailureNoTransaction
7768//
7769// stub stub
7770// +-------+ +---------+ +---------+
7771// | xapp | | submgr | | e2term |
7772// +-------+ +---------+ +---------+
7773// | | |
7774// | RestSubReq | |
7775// |---------------->| |
7776// | | |
7777// | RESTSubResp | |
7778// |<----------------| |
7779// | | |
7780// | | SubReq |
7781// | |------------->|
7782// | | |
7783// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007784// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007785// | | |
7786// | | SubReq |
7787// | |------------->|
7788// | | |
7789// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007790// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007791// | RESTNotif (fail)| |
7792// |<----------------| |
7793// | | SubDelReq |
7794// | |------------->|
7795// | | |
7796// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007797// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7798// | | |
7799// | | SubDelReq |
7800// | |------------->|
7801// | | |
7802// | | SubDelResp |
7803// | |<-------------| Ongoing transaction not found.
7804// | | |
7805// | [SUBS DELETE] |
7806// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007807//
7808//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007809
Anssi Mannila51122392021-05-25 11:51:31 +03007810func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007811
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007812 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007813
Anssi Mannila21782182021-12-10 10:56:02 +02007814 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7815 Counter{cRestSubReqFromXapp, 1},
7816 Counter{cRestSubRespToXapp, 1},
7817 Counter{cSubReqToE2, 1},
7818 Counter{cSubReqTimerExpiry, 2},
7819 Counter{cSubReReqToE2, 1},
7820 Counter{cSubFailFromE2, 2},
7821 Counter{cRestSubFailNotifToXapp, 1},
7822 Counter{cRestSubDelReqFromXapp, 1},
7823 Counter{cRestSubDelRespToXapp, 1},
7824 Counter{cSubDelReqToE2, 1},
7825 Counter{cSubDelReqTimerExpiry, 2},
7826 Counter{cSubDelReReqToE2, 1},
7827 Counter{cSubDelRespFromE2, 2},
7828 })
7829
Anssi Mannila51122392021-05-25 11:51:31 +03007830 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007831 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007832 restSubId := xappConn1.SendRESTSubsReq(t, params)
7833
7834 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7835
7836 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7837
7838 // No transaction exist for this response which will result resending original request
7839 fparams := &teststube2ap.E2StubSubsFailParams{}
7840 fparams.Set(crereq)
7841 e2termConn1.SendSubsFail(t, fparams, cremsg)
7842
7843 _, cremsg = e2termConn1.RecvSubsReq(t)
7844
Markku Virtanen55d2a282021-06-04 14:46:56 +03007845 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007846
7847 // Subscription already created in E2 Node.
7848 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7849 e2termConn1.SendSubsFail(t, fparams, cremsg)
7850
7851 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7852 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7853
7854 // Resending happens because there no transaction
7855 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7856 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7857
7858 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007859 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007860
Anssi Mannilab43397e2021-11-16 12:06:16 +02007861 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7862
Anssi Mannila51122392021-05-25 11:51:31 +03007863 // Wait that subs is cleaned
7864 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7865
7866 xappConn1.TestMsgChanEmpty(t)
7867 e2termConn1.TestMsgChanEmpty(t)
7868 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007869 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007870 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007871}
7872
7873//-----------------------------------------------------------------------------
7874// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7875//
7876// stub stub
7877// +-------+ +---------+ +---------+
7878// | xapp | | submgr | | e2term |
7879// +-------+ +---------+ +---------+
7880// | | |
7881// | [SUBS CREATE] |
7882// | | |
7883// | | |
7884// | RESTSubDelReq | |
7885// |---------------->| |
7886// | | |
7887// | RESTSubDelResp | |
7888// |<----------------| |
7889// | | |
7890// | | SubDelReq |
7891// | |------------->|
7892// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007893// | | SubDelResp | ASN.1 decode fails.
7894// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007895// | | |
7896// | | SubDelReq |
7897// | |------------->|
7898// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007899// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007900// | |<-------------|
7901// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007902// | [SUBS DELETE] |
7903// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007904//
7905//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007906
Anssi Mannila51122392021-05-25 11:51:31 +03007907func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007908
Anssi Mannila21782182021-12-10 10:56:02 +02007909 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7910 Counter{cRestSubReqFromXapp, 1},
7911 Counter{cRestSubRespToXapp, 1},
7912 Counter{cSubReqToE2, 1},
7913 Counter{cSubRespFromE2, 1},
7914 Counter{cRestSubNotifToXapp, 1},
7915 Counter{cRestSubDelReqFromXapp, 1},
7916 Counter{cRestSubDelRespToXapp, 1},
7917 Counter{cSubDelReqToE2, 1},
7918 Counter{cSubDelReqTimerExpiry, 1},
7919 Counter{cSubDelReReqToE2, 1},
7920 Counter{cSubDelFailFromE2, 1},
7921 Counter{cSubDelRespFromE2, 1},
7922 })
7923
Anssi Mannila51122392021-05-25 11:51:31 +03007924 // Req
7925 var params *teststube2ap.RESTSubsReqParams = nil
7926 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7927
7928 // Del
7929 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7930
7931 // E2t: Receive 1st SubsDelReq
7932 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7933
7934 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02007935 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03007936
7937 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7938 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7939
7940 // Subscription does not exist in in E2 Node.
7941 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7942
7943 // Wait that subs is cleaned
7944 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7945
7946 xappConn1.TestMsgChanEmpty(t)
7947 e2termConn1.TestMsgChanEmpty(t)
7948 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007949 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007950 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007951}
7952
7953//-----------------------------------------------------------------------------
7954// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
7955//
7956// stub stub
7957// +-------+ +---------+ +---------+
7958// | xapp | | submgr | | e2term |
7959// +-------+ +---------+ +---------+
7960// | | |
7961// | [SUBS CREATE] |
7962// | | |
7963// | | |
7964// | RESTSubDelReq | |
7965// |---------------->| |
7966// | | |
7967// | RESTSubDelResp | |
7968// |<----------------| |
7969// | | |
7970// | | SubDelReq |
7971// | |------------->|
7972// | | |
7973// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007974// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007975// | | |
7976// | | SubDelReq |
7977// | |------------->|
7978// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007979// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007980// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007981// | | |
7982// | [SUBS DELETE] |
7983// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007984//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007985
Anssi Mannila51122392021-05-25 11:51:31 +03007986func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007987
Anssi Mannila21782182021-12-10 10:56:02 +02007988 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7989 Counter{cRestSubReqFromXapp, 1},
7990 Counter{cRestSubRespToXapp, 1},
7991 Counter{cSubReqToE2, 1},
7992 Counter{cSubRespFromE2, 1},
7993 Counter{cRestSubNotifToXapp, 1},
7994 Counter{cRestSubDelReqFromXapp, 1},
7995 Counter{cRestSubDelRespToXapp, 1},
7996 Counter{cSubDelReqToE2, 1},
7997 Counter{cSubDelReqTimerExpiry, 1},
7998 Counter{cSubDelReReqToE2, 1},
7999 Counter{cSubDelRespFromE2, 1},
8000 Counter{cSubDelFailFromE2, 1},
8001 })
8002
Anssi Mannila51122392021-05-25 11:51:31 +03008003 // Req
8004 var params *teststube2ap.RESTSubsReqParams = nil
8005 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8006
8007 // Del
8008 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8009
8010 // E2t: Receive 1st SubsDelReq
8011 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8012
8013 // Unknown instanceId in this response which will result resending original request
8014 delreq.RequestId.InstanceId = 0
8015 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8016
8017 // E2t: Receive 2nd SubsDelReq
8018 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8019
8020 // Subscription does not exist in in E2 Node.
8021 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8022
8023 // Wait that subs is cleaned
8024 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8025
8026 xappConn1.TestMsgChanEmpty(t)
8027 e2termConn1.TestMsgChanEmpty(t)
8028 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008029 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008030 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008031}
8032
8033//-----------------------------------------------------------------------------
8034// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
8035//
8036// stub stub
8037// +-------+ +---------+ +---------+
8038// | xapp | | submgr | | e2term |
8039// +-------+ +---------+ +---------+
8040// | | |
8041// | [SUBS CREATE] |
8042// | | |
8043// | | |
8044// | RESTSubDelReq | |
8045// |---------------->| |
8046// | | |
8047// | RESTSubDelResp | |
8048// |<----------------| |
8049// | | |
8050// | | SubDelReq |
8051// | |------------->|
8052// | | |
8053// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008054// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008055// | | |
8056// | | SubDelReq |
8057// | |------------->|
8058// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008059// | | SubDelFail | Subscription does exist any more in E2 node
8060// | |<-------------| Ongoing transaction not found. This will result timer expiry
8061// | | |
8062// | [SUBS DELETE] |
8063// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008064//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008065
Anssi Mannila51122392021-05-25 11:51:31 +03008066func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008067
Anssi Mannila21782182021-12-10 10:56:02 +02008068 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8069 Counter{cRestSubReqFromXapp, 1},
8070 Counter{cRestSubRespToXapp, 1},
8071 Counter{cSubReqToE2, 1},
8072 Counter{cSubRespFromE2, 1},
8073 Counter{cRestSubNotifToXapp, 1},
8074 Counter{cRestSubDelReqFromXapp, 1},
8075 Counter{cRestSubDelRespToXapp, 1},
8076 Counter{cSubDelReqToE2, 1},
8077 Counter{cSubDelReqTimerExpiry, 2},
8078 Counter{cSubDelReReqToE2, 1},
8079 Counter{cSubDelRespFromE2, 1},
8080 Counter{cSubDelFailFromE2, 1},
8081 })
8082
Anssi Mannila51122392021-05-25 11:51:31 +03008083 // Req
8084 var params *teststube2ap.RESTSubsReqParams = nil
8085 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8086
8087 // Del
8088 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8089
8090 // E2t: Receive 1st SubsDelReq
8091 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8092
8093 mainCtrl.MakeTransactionNil(t, e2SubsId)
8094
8095 // No transaction exist for this response which will result resending original request
8096 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8097
8098 // E2t: Receive 2nd SubsDelReq
8099 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8100
8101 // Subscription does not exist in in E2 Node.
8102 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8103
8104 // Wait that subs is cleaned
8105 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8106
8107 xappConn1.TestMsgChanEmpty(t)
8108 e2termConn1.TestMsgChanEmpty(t)
8109 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008110 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008111 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008112}
8113
8114//-----------------------------------------------------------------------------
8115// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
8116//
8117// stub stub
8118// +-------+ +---------+ +---------+
8119// | xapp | | submgr | | e2term |
8120// +-------+ +---------+ +---------+
8121// | | |
8122// | [SUBS CREATE] |
8123// | | |
8124// | | |
8125// | RESTSubDelReq | |
8126// |---------------->| |
8127// | | |
8128// | RESTSubDelResp | |
8129// |<----------------| |
8130// | | |
8131// | | SubDelReq |
8132// | |------------->|
8133// | | |
8134// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02008135// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008136// | | |
8137// | | SubDelReq |
8138// | |------------->|
8139// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008140// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008141// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008142// | | |
8143// | [SUBS DELETE] |
8144// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008145//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008146
Anssi Mannila51122392021-05-25 11:51:31 +03008147func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008148
Anssi Mannila21782182021-12-10 10:56:02 +02008149 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8150 Counter{cRestSubReqFromXapp, 1},
8151 Counter{cRestSubRespToXapp, 1},
8152 Counter{cSubReqToE2, 1},
8153 Counter{cSubRespFromE2, 1},
8154 Counter{cRestSubNotifToXapp, 1},
8155 Counter{cRestSubDelReqFromXapp, 1},
8156 Counter{cRestSubDelRespToXapp, 1},
8157 Counter{cSubDelReqToE2, 1},
8158 Counter{cSubDelReqTimerExpiry, 1},
8159 Counter{cSubDelReReqToE2, 1},
8160 Counter{cSubDelFailFromE2, 2},
8161 })
8162
Anssi Mannila51122392021-05-25 11:51:31 +03008163 // Req
8164 var params *teststube2ap.RESTSubsReqParams = nil
8165 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8166
8167 // Del
8168 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8169
8170 // E2t: Receive 1st SubsDelReq
8171 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8172
8173 // Decode of this response fails which will result resending original request
8174 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
8175
8176 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8177 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8178
8179 // Subscription does not exist in in E2 Node.
8180 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8181
8182 // Wait that subs is cleaned
8183 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8184
8185 xappConn1.TestMsgChanEmpty(t)
8186 e2termConn1.TestMsgChanEmpty(t)
8187 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008188 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008189 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008190}
8191
8192//-----------------------------------------------------------------------------
8193// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8194//
8195// stub stub
8196// +-------+ +---------+ +---------+
8197// | xapp | | submgr | | e2term |
8198// +-------+ +---------+ +---------+
8199// | | |
8200// | [SUBS CREATE] |
8201// | | |
8202// | | |
8203// | RESTSubDelReq | |
8204// |---------------->| |
8205// | | |
8206// | RESTSubDelResp | |
8207// |<----------------| |
8208// | | |
8209// | | SubDelReq |
8210// | |------------->|
8211// | | |
8212// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008213// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008214// | | |
8215// | | SubDelReq |
8216// | |------------->|
8217// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008218// | | SubDelFail | Subscription does exist any more in E2 node
8219// | |<-------------| No valid subscription found with subIds [0].
8220// | | |
8221// | [SUBS DELETE] |
8222// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008223//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008224
Anssi Mannila51122392021-05-25 11:51:31 +03008225func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008226
Anssi Mannila21782182021-12-10 10:56:02 +02008227 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8228 Counter{cRestSubReqFromXapp, 1},
8229 Counter{cRestSubRespToXapp, 1},
8230 Counter{cSubReqToE2, 1},
8231 Counter{cSubRespFromE2, 1},
8232 Counter{cRestSubNotifToXapp, 1},
8233 Counter{cRestSubDelReqFromXapp, 1},
8234 Counter{cRestSubDelRespToXapp, 1},
8235 Counter{cSubDelReqToE2, 1},
8236 Counter{cSubDelReqTimerExpiry, 1},
8237 Counter{cSubDelReReqToE2, 1},
8238 Counter{cSubDelFailFromE2, 2},
8239 })
8240
Anssi Mannila51122392021-05-25 11:51:31 +03008241 // Req
8242 var params *teststube2ap.RESTSubsReqParams = nil
8243 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8244
8245 // Del
8246 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8247
8248 // E2t: Receive 1st SubsDelReq
8249 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8250
Anssi Mannila21782182021-12-10 10:56:02 +02008251 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008252 delreq.RequestId.InstanceId = 0
8253 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8254
8255 // E2t: Receive 2nd SubsDelReq
8256 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8257
Anssi Mannila21782182021-12-10 10:56:02 +02008258 // 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 +03008259 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8260
8261 // Wait that subs is cleaned
8262 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8263
8264 xappConn1.TestMsgChanEmpty(t)
8265 e2termConn1.TestMsgChanEmpty(t)
8266 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008267 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008268 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008269}
8270
8271//-----------------------------------------------------------------------------
8272// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8273//
8274// stub stub
8275// +-------+ +---------+ +---------+
8276// | xapp | | submgr | | e2term |
8277// +-------+ +---------+ +---------+
8278// | | |
8279// | [SUBS CREATE] |
8280// | | |
8281// | | |
8282// | RESTSubDelReq | |
8283// |---------------->| |
8284// | | |
8285// | RESTSubDelResp | |
8286// |<----------------| |
8287// | | |
8288// | | SubDelReq |
8289// | |------------->|
8290// | | |
8291// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008292// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008293// | | |
8294// | | SubDelReq |
8295// | |------------->|
8296// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008297// | | SubDelFail | Subscription does exist any more in E2 node
8298// | |<-------------| Ongoing transaction not found. This will result timer expiry
8299// | | |
8300// | [SUBS DELETE] |
8301// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008302//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008303
Anssi Mannila51122392021-05-25 11:51:31 +03008304func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008305
Anssi Mannila21782182021-12-10 10:56:02 +02008306 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8307 Counter{cRestSubReqFromXapp, 1},
8308 Counter{cRestSubRespToXapp, 1},
8309 Counter{cSubReqToE2, 1},
8310 Counter{cSubRespFromE2, 1},
8311 Counter{cRestSubNotifToXapp, 1},
8312 Counter{cRestSubDelReqFromXapp, 1},
8313 Counter{cRestSubDelRespToXapp, 1},
8314 Counter{cSubDelReqToE2, 1},
8315 Counter{cSubDelReqTimerExpiry, 2},
8316 Counter{cSubDelReReqToE2, 1},
8317 Counter{cSubDelFailFromE2, 2},
8318 })
8319
Anssi Mannila51122392021-05-25 11:51:31 +03008320 // Req
8321 var params *teststube2ap.RESTSubsReqParams = nil
8322 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8323
8324 // Del
8325 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8326
8327 // E2t: Receive 1st SubsDelReq
8328 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8329
8330 mainCtrl.MakeTransactionNil(t, e2SubsId)
8331
8332 // No transaction exist for this response which will result resending original request
8333 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8334
8335 // E2t: Receive 2nd SubsDelReq
8336 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8337
8338 // Subscription does not exist in in E2 Node.
8339 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8340
8341 // Wait that subs is cleaned
8342 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8343
8344 xappConn1.TestMsgChanEmpty(t)
8345 e2termConn1.TestMsgChanEmpty(t)
8346 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008347 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008348 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008349}
8350
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008351//-----------------------------------------------------------------------------
8352// TestRESTSubReqFailAsn1PackSubReqError
8353//
8354// stub stub
8355// +-------+ +---------+ +---------+
8356// | xapp | | submgr | | e2term |
8357// +-------+ +---------+ +---------+
8358// | | |
8359// | RESTSubReq | |
8360// |---------------->| |
8361// | | |
8362// | RESTSubResp | |
8363// |<----------------| |
8364// | | |
8365// | ASN.1 encode fails |
8366// | | |
8367// | | SubDelReq |
8368// | |------------->|
8369// | | |
8370// | | SubDelFail |
8371// | |<-------------|
8372// | | |
8373// | RESTNotif | |
8374// | unsuccess | |
8375// |<----------------| |
8376// | | |
8377// | [SUBS DELETE] |
8378// | | |
8379//
8380//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008381
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008382func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8383
8384 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008385 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008386 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008387 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008388 Counter{cRestSubDelReqFromXapp, 1},
8389 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008390 })
8391
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008392 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008393
8394 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008395 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008396 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8397
8398 // Req
8399 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008400 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008401
8402 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008403 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008404
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008405 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008406 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008407
8408 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008409
8410 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8411
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008412 // Wait that subs is cleaned
8413 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008414 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008415 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008416}
8417
Anssi Mannila27385172021-12-22 09:41:54 +02008418//-----------------------------------------------------------------------------
8419// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8420//
8421// stub stub
8422// +-------+ +---------+ +---------+
8423// | xapp | | submgr | | e2term |
8424// +-------+ +---------+ +---------+
8425// | | |
8426// | RESTSubReq | |
8427// |---------------->| |
8428// | | |
8429// | RESTSubResp | |
8430// |<----------------| |
8431// | | SubReq |
8432// | |------------->|
8433// | | |
8434// | | SubResp |
8435// | |<-------------|
8436// | | |
8437// | RESTNotif | |
8438// |<----------------| |
8439// | | |
8440// | RESTSubReq | | Policy modification
8441// |---------------->| |
8442// | | |
8443// | RESTSubResp | |
8444// |<----------------| |
8445// | | SubReq |
8446// | |------------->|
8447// | | |
8448// | | |
8449// | RESTNotif(Unsuccessful) | E2 timeout
8450// |<----------------| |
8451// | | |
8452// | RESTSubDelReq | |
8453// |---------------->| |
8454// | | |
8455// | | SubDelReq |
8456// | |------------->|
8457// | | |
8458// | | SubDelResp |
8459// | |<-------------|
8460// | | |
8461// | RESTSubDelResp | |
8462// |<----------------| |
8463//
8464//-----------------------------------------------------------------------------
8465
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008466func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008467
8468 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8469 Counter{cRestSubReqFromXapp, 2},
8470 Counter{cRestSubRespToXapp, 2},
8471 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008472 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008473 Counter{cSubRespFromE2, 1},
8474 Counter{cRestSubNotifToXapp, 1},
8475 Counter{cRestSubFailNotifToXapp, 1},
8476 Counter{cRestSubDelReqFromXapp, 1},
8477 Counter{cSubDelReqToE2, 1},
8478 Counter{cSubDelRespFromE2, 1},
8479 Counter{cRestSubDelRespToXapp, 1},
8480 })
8481
8482 const e2Timeout int64 = 1
8483 const e2RetryCount int64 = 0
8484 const routingNeeded bool = false
8485
8486 // Req1
8487 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8488 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8489
8490 // Subs Create
8491 restSubId := xappConn1.SendRESTSubsReq(t, params)
8492 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8493
8494 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8495 xappConn1.ExpectRESTNotification(t, restSubId)
8496 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8497 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8498 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8499
8500 // Policy change
8501 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8502 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8503 params.SetSubscriptionID(&restSubId)
8504 params.SetTimeToWait("w200ms")
8505 restSubId = xappConn1.SendRESTSubsReq(t, params)
8506 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8507
8508 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8509 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008510 // SubsResp is missing, e2SubsId will be 0
8511 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8512 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008513
8514 // Del
8515 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8516 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8517 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8518
8519 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008520 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008521 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008522}
8523
8524//-----------------------------------------------------------------------------
8525// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8526//
8527// stub stub
8528// +-------+ +---------+ +---------+
8529// | xapp | | submgr | | e2term |
8530// +-------+ +---------+ +---------+
8531// | | |
8532// | RESTSubReq | |
8533// |---------------->| |
8534// | | |
8535// | RESTSubResp | |
8536// |<----------------| |
8537// | | SubReq |
8538// | |------------->|
8539// | | |
8540// | | SubResp |
8541// | |<-------------|
8542// | | |
8543// | RESTNotif | |
8544// |<----------------| |
8545// | | |
8546// | RESTSubReq | |
8547// |---------------->| |
8548// | | |
8549// | RESTSubResp | |
8550// |<----------------| |
8551// | | SubReq |
8552// | |------------->|
8553// | |
8554// | Submgr restart |
8555// | | |
8556// | RESTSubDelReq | |
8557// |---------------->| |
8558// | | |
8559// | | SubDelReq |
8560// | |------------->|
8561// | | |
8562// | | SubDelResp |
8563// | |<-------------|
8564// | | |
8565// | RESTSubDelResp | |
8566// |<----------------| |
8567//
8568//-----------------------------------------------------------------------------
8569
8570func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008571
8572 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8573 Counter{cRestSubReqFromXapp, 2},
8574 Counter{cRestSubRespToXapp, 2},
8575 Counter{cSubReqToE2, 2},
8576 Counter{cSubRespFromE2, 1},
8577 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008578 Counter{cRestSubDelReqFromXapp, 1},
8579 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008580 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008581 Counter{cRestSubDelRespToXapp, 1},
8582 })
8583
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008584 const e2Timeout int64 = 1
8585 const e2RetryCount int64 = 0
8586 const routingNeeded bool = false
8587
8588 // Req1
8589 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8590 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8591 // Create subscription
8592 restSubId := xappConn1.SendRESTSubsReq(t, params)
8593 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8594
8595 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8596 xappConn1.ExpectRESTNotification(t, restSubId)
8597 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8598 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8599 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8600
8601 // Check subscription
8602 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8603
8604 // Policy change
8605 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8606 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8607 params.SetSubscriptionID(&restSubId)
8608 params.SetTimeToWait("w200ms")
8609 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8610 restSubId = xappConn1.SendRESTSubsReq(t, params)
8611 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8612
8613 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8614 mainCtrl.SetResetTestFlag(t, false)
8615
8616 // SubsResp is missing due to submgr restart
8617
8618 mainCtrl.SimulateRestart(t)
8619 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8620
Anssi Mannila54838ed2021-11-19 11:25:01 +02008621 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8622 // That needs to be completed before successful subscription query is possible
8623 <-time.After(time.Second * 1)
8624
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008625 // Check subscription
8626 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8627
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008628 // Delete subscription
8629 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8630 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8631 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8632
8633 //Wait that subs is cleaned
8634 waitSubsCleanup(t, e2SubsId, 10)
8635
8636 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008637 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008638}
8639
archaggeafbf95f2021-04-14 08:54:05 +03008640////////////////////////////////////////////////////////////////////////////////////
8641// Services for UT cases
8642////////////////////////////////////////////////////////////////////////////////////
8643const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008644const host string = "localhost"
8645
8646func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8647 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008648 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008649 }
8650 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008651 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008652
8653 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8654 fromXappConn.ExpectRESTNotification(t, restSubId)
8655 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8656 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008657 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008658
8659 return restSubId, e2SubsId
8660}
8661
8662func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8663
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008664 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008665 if meid != "" {
8666 params.SetMeid(meid)
8667 }
8668 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8669 restSubId := xappConn2.SendRESTSubsReq(t, params)
8670 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008671 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008672 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008673 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008674
8675 return restSubId, e2SubsId
8676}
8677
8678func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008679
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008680 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008681 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008682 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008683
8684 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8685 xappConn1.ExpectRESTNotification(t, restSubId)
8686 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8687 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008688 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008689
8690 return restSubId, e2SubsId
8691}
8692
8693func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008694 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008695 restSubId := xappConn1.SendRESTSubsReq(t, params)
8696
8697 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8698 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8699 fparams1.Set(crereq1)
8700 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8701
8702 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8703 xappConn1.ExpectRESTNotification(t, restSubId)
8704 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8705 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008706 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008707
8708 return restSubId, e2SubsId
8709}
8710
8711func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8712 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8713 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8714 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8715}
8716
8717func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8718 xappConn1.SendRESTSubsDelReq(t, restSubId)
8719 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8720 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8721}
8722
8723func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8724 xappConn2.SendRESTSubsDelReq(t, restSubId)
8725 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8726 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8727}
8728
8729func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8730 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008731 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8732 assert.Equal(t, meid, resp[0].Meid)
8733 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008734}
8735
8736func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8737 //Wait that subs is cleaned
8738 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8739
8740 xappConn1.TestMsgChanEmpty(t)
8741 xappConn2.TestMsgChanEmpty(t)
8742 e2termConn1.TestMsgChanEmpty(t)
8743 mainCtrl.wait_registry_empty(t, timeout)
8744}
8745
8746func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8747
8748 var e2SubsId []uint32
8749
8750 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008751 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008752 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8753 fromXappConn.ExpectRESTNotification(t, restSubId)
8754 toE2termConn.SendSubsResp(t, crereq, cremsg)
8755 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8756 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008757 xapp.Logger.Debug("TEST: %v", e2SubsId)
8758 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008759 <-time.After(100 * time.Millisecond)
8760 }
8761 return e2SubsId
8762}
8763
8764func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8765
8766 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008767 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008768 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8769 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8770 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008771 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008772 <-time.After(100 * time.Millisecond)
8773 }
8774
8775 // Wait that subs is cleaned
8776 for i := 0; i < len(e2SubsIds); i++ {
8777 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8778 }
8779
8780}