blob: 8bc9c0a113851b18738648dd49ca7528aef611cd [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannila92c38552021-12-29 09:59:24 +020023 "encoding/json"
aditverm323c77e2023-09-20 09:50:47 +053024 "fmt"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000025 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020026 "testing"
27 "time"
28
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000030 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030031 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020032 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020033 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
34 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020035)
36
Anssi Mannila27385172021-12-22 09:41:54 +020037// In below test cases there is done only one retry for E2 messages
38// In Helm chart retry count is currently 2 By default. Retry count
39// used in test cases is defined in submgr-config.yaml file.
40
Markku Virtanenac8bde42021-05-25 09:54:42 +000041func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030042 // The effect of this call shall endure though the UT suite!
43 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000044 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000045 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
46
Anssi Mannila3d80b722021-11-12 13:17:15 +020047 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000048 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030049 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000050
Markku Virtanenac8bde42021-05-25 09:54:42 +000051}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030052func TestRanStatusChangeViaSDLNotification(t *testing.T) {
53
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020054 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
55 Counter{cE2StateChangedToUp, 3},
56 })
57
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030058 // Current UT test cases use these ran names
59 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
60 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
61 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
62
63 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
64 mainCtrl.c.e2IfState.SubscribeChannels()
65
66 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
67 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
68 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020069
70 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030071}
72
73//-----------------------------------------------------------------------------
74// TestRESTSubReqAfterE2ConnBreak
75//
76// stub stub
77// +-------+ +---------+ +---------+
78// | xapp | | submgr | | e2term |
79// +-------+ +---------+ +---------+
80// | | |
81// | [E2 Conn. DOWN] |
82// | | |
83// | RESTSubReq | |
84// |---------------->| |
85// | RESTSubFail | |
86// |<----------------| |
87// | | |
88//
89//-----------------------------------------------------------------------------
90
91func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030092
93 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
94 Counter{cRestSubReqFromXapp, 1},
95 Counter{cRestReqRejDueE2Down, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020096 Counter{cE2StateChangedToDown, 1},
97 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030098 })
99
100 // E2 disconnect after E2term has received response
101 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
102 // Req
103 const subReqCount int = 1
104 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
105 xappConn1.SendRESTSubsReq(t, params)
106
107 // Restore E2 connection for following test cases
108 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
109
Anssi Mannilab43397e2021-11-16 12:06:16 +0200110 mainCtrl.VerifyAllClean(t)
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200111 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300112}
113
114//-----------------------------------------------------------------------------
115// TestRESTSubReqE2ConnBreak
116//
117// stub stub
118// +-------+ +---------+ +---------+
119// | xapp | | submgr | | e2term |
120// +-------+ +---------+ +---------+
121// | | |
122// | RESTSubReq | |
123// |---------------->| |
124// | RESTSubResp | |
125// |<----------------| |
126// | | SubReq |
127// | |------------->|
128// | | SubResp |
129// | |<-------------|
130// | | |
131// | [E2 Conn. DOWN] |
132// | [Int. SUBS DELETE] |
133// | | |
134// | RESTNotif(unsuccessful) |
135// |<----------------| |
136// | | |
137// | | |
138//
139//-----------------------------------------------------------------------------
140func TestRESTSubReqE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300141
142 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
143 Counter{cRestSubReqFromXapp, 1},
144 Counter{cRestSubRespToXapp, 1},
145 Counter{cSubReqToE2, 1},
146 Counter{cSubRespFromE2, 1},
147 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200148 Counter{cE2StateChangedToDown, 1},
149 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300150 })
151
152 // Req
153 const subReqCount int = 1
154 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
155 restSubId := xappConn1.SendRESTSubsReq(t, params)
156
157 crereq, cremsg := e2termConn1.RecvSubsReq(t)
158 xappConn1.ExpectRESTNotification(t, restSubId)
159
160 // E2 disconnect after E2term has received response
161 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
162
163 e2termConn1.SendSubsResp(t, crereq, cremsg)
164 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
165
166 <-time.After(time.Second * 1)
167 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
168 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
169
170 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
171 if err != nil {
172 xapp.Logger.Error("%v", err)
173 } else {
174 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
175 assert.Equal(t, 0, len(register))
176 }
177
178 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
179 if err != nil {
180 xapp.Logger.Error("%v", err)
181 } else {
182 assert.Equal(t, 0, len(restSubscriptions))
183 }
184
185 // Restore E2 connection for following test cases
186 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
187
188 // Wait that subs is cleaned
189 waitSubsCleanup(t, e2SubsId, 10)
190 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200191 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300192}
193
194//-----------------------------------------------------------------------------
195// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
196//
197// stub stub
198// +-------+ +---------+ +---------+
199// | xapp | | submgr | | e2term |
200// +-------+ +---------+ +---------+
201// | | |
202// | [SUBS CREATE] |
203// | | |
204// | [E2 Conn. DOWN] |
205// | | |
206// | RESTSubDelReq | |
207// |---------------->| |
208// | | |
209// | RESTSubDelResp | |
210// |<----------------| |
211// | | |
212// | [No valid subscription found] |
213// | | |
214//
215//-----------------------------------------------------------------------------
216func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
217 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
218
219 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
220 Counter{cRestSubReqFromXapp, 1},
221 Counter{cRestSubRespToXapp, 1},
222 Counter{cSubReqToE2, 1},
223 Counter{cSubRespFromE2, 1},
224 Counter{cRestSubNotifToXapp, 1},
225 Counter{cRestSubDelReqFromXapp, 1},
226 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200227 Counter{cE2StateChangedToDown, 1},
228 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300229 })
230
231 // Req
232 var params *teststube2ap.RESTSubsReqParams = nil
233 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
234
235 // E2 disconnect after E2term has received response
236 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
237
238 // Del
239 xappConn1.SendRESTSubsDelReq(t, &restSubId)
240
241 <-time.After(time.Second * 1)
242 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
243 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
244
245 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
246 if err != nil {
247 xapp.Logger.Error("%v", err)
248 } else {
249 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
250 assert.Equal(t, 0, len(register))
251 }
252
253 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
254 if err != nil {
255 xapp.Logger.Error("%v", err)
256 } else {
257 assert.Equal(t, 0, len(restSubscriptions))
258 }
259
260 // Restore E2 connection for following test cases
261 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
262
263 // Wait that subs is cleaned
264 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
265
266 xappConn1.TestMsgChanEmpty(t)
267 e2termConn1.TestMsgChanEmpty(t)
268 mainCtrl.wait_registry_empty(t, 10)
269 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200270 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300271}
272
273//-----------------------------------------------------------------------------
274// TestRESTOtherE2ConnectionChanges
275//
276
277// stub stub
278// +-------+ +---------+ +---------+
279// | xapp | | submgr | | e2term |
280// +-------+ +---------+ +---------+
281// | | |
282// | [SUBS CREATE] |
283// | | |
284// | [E2 CONNECTED_SETUP_FAILED] |
285// | [E2 CONNECTING] |
286// | [E2 SHUTTING_DOWN] |
287// | [E2 SHUT_DOWN] |
288// | | |
289// | [SUBS DELETE] |
290// | | |
291//
292//-----------------------------------------------------------------------------
293func TestRESTOtherE2ConnectionChanges(t *testing.T) {
294 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
295
296 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
297 Counter{cRestSubReqFromXapp, 1},
298 Counter{cRestSubRespToXapp, 1},
299 Counter{cSubReqToE2, 1},
300 Counter{cSubRespFromE2, 1},
301 Counter{cRestSubNotifToXapp, 1},
302 Counter{cRestSubDelReqFromXapp, 1},
303 Counter{cSubDelReqToE2, 1},
304 Counter{cSubDelRespFromE2, 1},
305 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200306 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300307 })
308
309 // Req
310 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
311 restSubId := xappConn1.SendRESTSubsReq(t, params)
312
313 crereq, cremsg := e2termConn1.RecvSubsReq(t)
314 xappConn1.ExpectRESTNotification(t, restSubId)
315 e2termConn1.SendSubsResp(t, crereq, cremsg)
316 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
317
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200318 // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300319 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
320 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
321 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
322 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
323
324 // Del
325 xappConn1.SendRESTSubsDelReq(t, &restSubId)
326 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
327 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
328
329 // Restore E2 connection for following test cases
330 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
331
332 // Wait that subs is cleaned
333 waitSubsCleanup(t, e2SubsId, 10)
334 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200335 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300336}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000337
338//-----------------------------------------------------------------------------
339// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
340//
341// stub stub stub
342// +-------+ +---------+ +---------+ +---------+
343// | xapp | | submgr | | e2term | | rtmgr |
344// +-------+ +---------+ +---------+ +---------+
345// | | | |
346// | RESTSubReq | | |
347// |---------------->| | |
348// | | RouteCreate | |
349// | |--------------------------->| // The order of these events may vary
350// | | | |
351// | RESTSubResp | | | // The order of these events may vary
352// |<----------------| | |
353// | | RouteResponse| |
354// | |<---------------------------| // The order of these events may vary
355// | | | |
356// | | SubReq | |
357// | |------------->| | // The order of these events may vary
358// | | | |
359// | | SubResp | |
360// | |<-------------| |
361// | RESTNotif1 | | |
362// |<----------------| | |
363// | | | |
364// | RESTSubDelReq | | |
365// |---------------->| | |
366// | | SubDelReq | |
367// | |------------->| |
368// | | | |
369// | RESTSubDelResp| | |
370// |<----------------| | |
371// | | | |
372// | | SubDelResp | |
373// | |<-------------| |
374// | | | |
375// | | | |
376//
377//-----------------------------------------------------------------------------
378func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000379
380 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
381
382 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
383
384 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200385 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000386}
387
Juha Hyttinenfa015662020-01-24 10:05:18 +0200388//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000389// TestRESTSubReqAndE1apDeleteReqPackingError
390//
391// stub stub stub
392// +-------+ +---------+ +---------+ +---------+
393// | xapp | | submgr | | e2term | | rtmgr |
394// +-------+ +---------+ +---------+ +---------+
395// | | | |
396// | RESTSubReq | | |
397// |---------------->| | |
398// | | RouteCreate | |
399// | |--------------------------->| // The order of these events may vary
400// | | | |
401// | RESTSubResp | | | // The order of these events may vary
402// |<----------------| | |
403// | | RouteResponse| |
404// | |<---------------------------| // The order of these events may vary
405// | | | |
406// | | SubReq | |
407// | |------------->| | // The order of these events may vary
408// | | | |
409// | | SubResp | |
410// | |<-------------| |
411// | RESTNotif1 | | |
412// |<----------------| | |
413// | | | |
414// | RESTSubDelReq | | |
415// |---------------->| | |
416// | | | |
417// | RESTSubDelResp| | |
418// |<----------------| | |
419// | | | |
420// | | | |
421//
422//-----------------------------------------------------------------------------
423func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
424
425 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
426
427 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
428 xappConn1.SendRESTSubsDelReq(t, &restSubId)
429 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
430
431 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200432 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000433}
434
435//-----------------------------------------------------------------------------
Anssi Mannila483bd162022-01-20 11:11:48 +0200436// TestRESTSubReqAndE2APDeleteRespUnpackingError
Markku Virtanenac8bde42021-05-25 09:54:42 +0000437//
438// stub stub stub
439// +-------+ +---------+ +---------+ +---------+
440// | xapp | | submgr | | e2term | | rtmgr |
441// +-------+ +---------+ +---------+ +---------+
442// | | | |
443// | RESTSubReq | | |
444// |---------------->| | |
445// | | RouteCreate | |
446// | |--------------------------->| // The order of these events may vary
447// | | | |
448// | RESTSubResp | | | // The order of these events may vary
449// |<----------------| | |
450// | | RouteResponse| |
451// | |<---------------------------| // The order of these events may vary
452// | | | |
453// | | SubReq | |
454// | |------------->| | // The order of these events may vary
455// | | | |
456// | | SubResp | |
457// | |<-------------| |
458// | RESTNotif1 | | |
459// |<----------------| | |
460// | | | |
461// | RESTSubDelReq | | |
462// |---------------->| | |
463// | | SubDelReq | |
464// | |------------->| |
465// | | | |
466// | RESTSubDelResp| | |
467// |<----------------| | | // The order of these events may vary
468// | | | |
469// | | SubDelResp | |
470// | |<-------------| | // 1.st NOK
471// | | | |
472// | | SubDelReq | |
473// | |------------->| |
474// | | | |
475// | | SubDelResp | |
476// | |<-------------| | // 2.nd NOK
477//
478//-----------------------------------------------------------------------------
479
Anssi Mannila483bd162022-01-20 11:11:48 +0200480func TestRESTSubReqAndE2APDeleteRespUnpackingError(t *testing.T) {
Markku Virtanenac8bde42021-05-25 09:54:42 +0000481
482 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
483
484 xappConn1.SendRESTSubsDelReq(t, &restSubId)
485 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
486 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
487 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
488
489 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
490 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
491
492 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
493
494 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200495 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000496}
497
498//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200499// TestSubReqAndRouteNok
500//
501// stub stub
502// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200503// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200504// +-------+ +---------+ +---------+
505// | | |
506// | SubReq | |
507// |------------->| |
508// | | |
509// | | RouteCreate |
510// | |------------->|
511// | | |
512// | | RouteCreate |
513// | | status:400 |
514// | |<-------------|
515// | | |
516// | [SUBS INT DELETE] |
517// | | |
518//
519//-----------------------------------------------------------------------------
520
521func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200522 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200523
Anssi Mannila4abf1802021-01-28 13:06:46 +0200524 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
526 Counter{cSubReqFromXapp, 1},
527 Counter{cRouteCreateFail, 1},
528 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200529
Juha Hyttinenfa015662020-01-24 10:05:18 +0200530 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300531 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200532 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200533 waiter.WaitResult(t)
534
535 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200536 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200537
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200538 xappConn1.TestMsgChanEmpty(t)
539 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200540 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200541 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200542
543 <-time.After(1 * time.Second)
544 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200545}
546
547//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200548// TestSubReqAndRouteUpdateNok
549
550// stub stub
551// +-------+ +-------+ +---------+ +---------+
552// | xapp2 | | xapp1 | | submgr | | rtmgr |
553// +-------+ +-------+ +---------+ +---------+
554// | | | |
555// | [SUBS CREATE] | |
556// | | | |
557// | | | |
558// | | | |
559// | SubReq (mergeable) | |
560// |--------------------------->| | |
561// | | | |
562// | | | RouteUpdate |
563// | | |------------->|
564// | | | |
565// | | | RouteUpdate |
566// | | | status:400 |
567// | | |<-------------|
568// | | | |
569// | [SUBS INT DELETE] | |
570// | | | |
571// | | | |
572// | [SUBS DELETE] | |
573// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300574
Anssi Mannila4abf1802021-01-28 13:06:46 +0200575func TestSubReqAndRouteUpdateNok(t *testing.T) {
576 CaseBegin("TestSubReqAndRouteUpdateNok")
577
578 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200579 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
580 Counter{cSubReqFromXapp, 2},
581 Counter{cSubReqToE2, 1},
582 Counter{cSubRespFromE2, 1},
583 Counter{cSubRespToXapp, 1},
584 Counter{cRouteCreateUpdateFail, 1},
585 Counter{cSubDelReqFromXapp, 1},
586 Counter{cSubDelReqToE2, 1},
587 Counter{cSubDelRespFromE2, 1},
588 Counter{cSubDelRespToXapp, 1},
589 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200590
591 cretrans := xappConn1.SendSubsReq(t, nil, nil)
592 crereq, cremsg := e2termConn1.RecvSubsReq(t)
593 e2termConn1.SendSubsResp(t, crereq, cremsg)
594 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
595
596 resp, _ := xapp.Subscription.QuerySubscriptions()
597 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
598 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300599 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200600
601 waiter := rtmgrHttp.AllocNextEvent(false)
602 newSubsId := mainCtrl.get_registry_next_subid(t)
603 xappConn2.SendSubsReq(t, nil, nil)
604 waiter.WaitResult(t)
605
606 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
607 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
608
609 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
610 xappConn1.RecvSubsDelResp(t, deltrans)
611
612 //Wait that subs is cleaned
613 mainCtrl.wait_subs_clean(t, newSubsId, 10)
614 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
615
616 xappConn1.TestMsgChanEmpty(t)
617 xappConn2.TestMsgChanEmpty(t)
618 e2termConn1.TestMsgChanEmpty(t)
619 mainCtrl.wait_registry_empty(t, 10)
620
621 mainCtrl.VerifyCounterValues(t)
622}
623
624//-----------------------------------------------------------------------------
625// TestSubDelReqAndRouteDeleteNok
626//
627// stub stub
628// +-------+ +---------+ +---------+ +---------+
629// | xapp | | submgr | | e2term | | rtmgr |
630// +-------+ +---------+ +---------+ +---------+
631// | | | |
632// | [SUBS CREATE] | |
633// | | | |
634// | | | |
635// | | | |
636// | SubDelReq | | |
637// |------------->| | |
638// | | SubDelReq | |
639// | |------------->| |
640// | | SubDelRsp | |
641// | |<-------------| |
642// | SubDelRsp | | |
643// |<-------------| | |
644// | | RouteDelete | |
645// | |---------------------------->|
646// | | | |
647// | | RouteDelete | |
648// | | status:400 | |
649// | |<----------------------------|
650// | | | |
651func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
652 CaseBegin("TestSubDelReqAndRouteDeleteNok")
653
654 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200655 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
656 Counter{cSubReqFromXapp, 1},
657 Counter{cSubReqToE2, 1},
658 Counter{cSubRespFromE2, 1},
659 Counter{cSubRespToXapp, 1},
660 Counter{cSubDelReqFromXapp, 1},
661 Counter{cRouteDeleteFail, 1},
662 Counter{cSubDelReqToE2, 1},
663 Counter{cSubDelRespFromE2, 1},
664 Counter{cSubDelRespToXapp, 1},
665 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200666
667 cretrans := xappConn1.SendSubsReq(t, nil, nil)
668 crereq, cremsg := e2termConn1.RecvSubsReq(t)
669 e2termConn1.SendSubsResp(t, crereq, cremsg)
670 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
671
672 resp, _ := xapp.Subscription.QuerySubscriptions()
673 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
674 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300675 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200676
677 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
678 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
679
680 waiter := rtmgrHttp.AllocNextEvent(false)
681 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
682 waiter.WaitResult(t)
683
684 xappConn1.RecvSubsDelResp(t, deltrans)
685
686 //Wait that subs is cleaned
687 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
688
689 xappConn1.TestMsgChanEmpty(t)
690 xappConn2.TestMsgChanEmpty(t)
691 e2termConn1.TestMsgChanEmpty(t)
692 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200693 mainCtrl.VerifyCounterValues(t)
694}
695
696//-----------------------------------------------------------------------------
697// TestSubMergeDelAndRouteUpdateNok
698// stub stub
699// +-------+ +-------+ +---------+ +---------+
700// | xapp2 | | xapp1 | | submgr | | e2term |
701// +-------+ +-------+ +---------+ +---------+
702// | | | |
703// | | | |
704// | | | |
705// | | SubReq1 | |
706// | |------------->| |
707// | | | |
708// | | | SubReq1 |
709// | | |------------->|
710// | | | SubResp1 |
711// | | |<-------------|
712// | | SubResp1 | |
713// | |<-------------| |
714// | | | |
715// | SubReq2 | |
716// |--------------------------->| |
717// | | | |
718// | SubResp2 | |
719// |<---------------------------| |
720// | | | |
721// | | SubDelReq 1 | |
722// | |------------->| |
723// | | | RouteUpdate |
724// | | |-----> rtmgr |
725// | | | |
726// | | | RouteUpdate |
727// | | | status:400 |
728// | | |<----- rtmgr |
729// | | | |
730// | | SubDelResp 1 | |
731// | |<-------------| |
732// | | | |
733// | SubDelReq 2 | |
734// |--------------------------->| |
735// | | | |
736// | | | SubDelReq 2 |
737// | | |------------->|
738// | | | |
739// | | | SubDelReq 2 |
740// | | |------------->|
741// | | | |
742// | SubDelResp 2 | |
743// |<---------------------------| |
744//
745//-----------------------------------------------------------------------------
746func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
747 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
748
749 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200750 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
751 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200752 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200753 Counter{cSubReqToE2, 1},
754 Counter{cSubRespFromE2, 1},
755 Counter{cSubRespToXapp, 2},
756 Counter{cSubDelReqFromXapp, 2},
757 Counter{cRouteDeleteUpdateFail, 1},
758 Counter{cSubDelReqToE2, 1},
759 Counter{cSubDelRespFromE2, 1},
760 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200761 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200762 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200763
764 //Req1
765 rparams1 := &teststube2ap.E2StubSubsReqParams{}
766 rparams1.Init()
767 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
768 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
769 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
770 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
771
772 //Req2
773 rparams2 := &teststube2ap.E2StubSubsReqParams{}
774 rparams2.Init()
775 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
776 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
777
778 resp, _ := xapp.Subscription.QuerySubscriptions()
779 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
780 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300781 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200782
783 //Del1
784 waiter := rtmgrHttp.AllocNextEvent(false)
785 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
786 waiter.WaitResult(t)
787
788 xappConn1.RecvSubsDelResp(t, deltrans1)
789
790 //Del2
791 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
792 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
793 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
794 xappConn2.RecvSubsDelResp(t, deltrans2)
795 //Wait that subs is cleaned
796 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
797
798 xappConn1.TestMsgChanEmpty(t)
799 xappConn2.TestMsgChanEmpty(t)
800 e2termConn1.TestMsgChanEmpty(t)
801 mainCtrl.wait_registry_empty(t, 10)
802
803 mainCtrl.VerifyCounterValues(t)
804}
805
806//-----------------------------------------------------------------------------
807
808//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200809// TestSubReqAndSubDelOk
810//
811// stub stub
812// +-------+ +---------+ +---------+
813// | xapp | | submgr | | e2term |
814// +-------+ +---------+ +---------+
815// | | |
816// | SubReq | |
817// |------------->| |
818// | | |
819// | | SubReq |
820// | |------------->|
821// | | |
822// | | SubResp |
823// | |<-------------|
824// | | |
825// | SubResp | |
826// |<-------------| |
827// | | |
828// | | |
829// | SubDelReq | |
830// |------------->| |
831// | | |
832// | | SubDelReq |
833// | |------------->|
834// | | |
835// | | SubDelResp |
836// | |<-------------|
837// | | |
838// | SubDelResp | |
839// |<-------------| |
840//
841//-----------------------------------------------------------------------------
842func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200843 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200844
Anssi Mannila4abf1802021-01-28 13:06:46 +0200845 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200846 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
847 Counter{cSubReqFromXapp, 1},
848 Counter{cSubReqToE2, 1},
849 Counter{cSubRespFromE2, 1},
850 Counter{cSubRespToXapp, 1},
851 Counter{cSubDelReqFromXapp, 1},
852 Counter{cSubDelReqToE2, 1},
853 Counter{cSubDelRespFromE2, 1},
854 Counter{cSubDelRespToXapp, 1},
855 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200856
857 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200858 crereq, cremsg := e2termConn1.RecvSubsReq(t)
859 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200860 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200861
862 resp, _ := xapp.Subscription.QuerySubscriptions()
863 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
864 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300865 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200866
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200867 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200868 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200869
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200871 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200872
873 //Wait that subs is cleaned
874 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
875
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200876 xappConn1.TestMsgChanEmpty(t)
877 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200878 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200879 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200880
881 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200882}
883
884//-----------------------------------------------------------------------------
Himanshu Puorhit84662c42023-08-29 15:46:18 +0530885
886//-----------------------------------------------------------------------------
887// TestSubReqAndSubDelOkOutofOrderIEs
888//
889// stub stub
890// +-------+ +---------+ +---------+
891// | xapp | | submgr | | e2term |
892// +-------+ +---------+ +---------+
893// | | |
894// | SubReq | |
895// |------------->| |
896// | | |
897// | | SubReq |
898// | |------------->|
899// | | |
900// | | SubResp | (Out of Order IEs)
901// | |<-------------|
902// | | |
903// | SubResp | |
904// |<-------------| |
905// | | |
906// | | |
907// | SubDelReq | |
908// |------------->| |
909// | | |
910// | | SubDelReq |
911// | |------------->|
912// | | |
913// | | SubDelResp |
914// | |<-------------|
915// | | |
916// | SubDelResp | |
917// |<-------------| |
918//
919//-----------------------------------------------------------------------------
920
921func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
922 CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs")
923
924 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
925 // Init counter check
926 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
927 Counter{cSubReqFromXapp, 1},
928 Counter{cSubReqToE2, 1},
929 Counter{cSubRespFromE2, 1},
930 Counter{cSubRespToXapp, 1},
931 Counter{cSubDelReqFromXapp, 1},
932 Counter{cSubDelReqToE2, 1},
933 Counter{cSubDelRespFromE2, 1},
934 Counter{cSubDelRespToXapp, 1},
935 })
936
937 cretrans := xappConn1.SendSubsReq(t, nil, nil)
938 if cretrans == nil {
939 t.Logf("Could not send SubsReq")
940 t.FailNow()
941 }
942 crereq, cremsg := e2termConn1.RecvSubsReq(t)
943 if crereq == nil || cremsg == nil {
944 t.Logf("Could not recieve SubsReq")
945 t.FailNow()
946 }
947
948 e2termConn1.SendSubsResp(t, crereq, cremsg)
949
950 mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
951
952 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
953 resp, _ := xapp.Subscription.QuerySubscriptions()
954 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
955 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
956 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
957
958 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
959 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
960
961 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
962 xappConn1.RecvSubsDelResp(t, deltrans)
963
964 //Wait that subs is cleaned
965 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
966
967 xappConn1.TestMsgChanEmpty(t)
968 xappConn2.TestMsgChanEmpty(t)
969 e2termConn1.TestMsgChanEmpty(t)
970 mainCtrl.wait_registry_empty(t, 10)
971
972 mainCtrl.VerifyCounterValues(t)
973 mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
974}
975
976//-----------------------------------------------------------------------------
977
978//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200979// TestSubReqRetransmission
980//
981// stub stub
982// +-------+ +---------+ +---------+
983// | xapp | | submgr | | e2term |
984// +-------+ +---------+ +---------+
985// | | |
986// | SubReq | |
987// |------------->| |
988// | | |
989// | | SubReq |
990// | |------------->|
991// | | |
992// | SubReq | |
993// | (retrans) | |
994// |------------->| |
995// | | |
996// | | SubResp |
997// | |<-------------|
998// | | |
999// | SubResp | |
1000// |<-------------| |
1001// | | |
1002// | [SUBS DELETE] |
1003// | | |
1004//
1005//-----------------------------------------------------------------------------
1006func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001007 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001008
1009 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001010 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001011 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001012
1013 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001014 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001015 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1016
Juha Hyttinen1683f912020-04-17 10:39:57 +03001017 // hack as there is no real way to see has message be handled.
1018 // Previuos counter check just tells that is has been received by submgr
1019 // --> artificial delay
1020 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001021 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001022 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001023
1024 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001025 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001026 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1027 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001028 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001029
1030 //Wait that subs is cleaned
1031 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1032
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001033 xappConn1.TestMsgChanEmpty(t)
1034 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001035 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001036 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001037}
1038
1039//-----------------------------------------------------------------------------
1040// TestSubDelReqRetransmission
1041//
1042// stub stub
1043// +-------+ +---------+ +---------+
1044// | xapp | | submgr | | e2term |
1045// +-------+ +---------+ +---------+
1046// | | |
1047// | [SUBS CREATE] |
1048// | | |
1049// | | |
1050// | SubDelReq | |
1051// |------------->| |
1052// | | |
1053// | | SubDelReq |
1054// | |------------->|
1055// | | |
1056// | SubDelReq | |
1057// | (same sub) | |
1058// | (same xid) | |
1059// |------------->| |
1060// | | |
1061// | | SubDelResp |
1062// | |<-------------|
1063// | | |
1064// | SubDelResp | |
1065// |<-------------| |
1066//
1067//-----------------------------------------------------------------------------
1068func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001069 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001070
1071 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001072 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001073 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1074 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001075 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001076
1077 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001078 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001079 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001080
1081 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001082 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001083 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1084
Juha Hyttinen1683f912020-04-17 10:39:57 +03001085 // hack as there is no real way to see has message be handled.
1086 // Previuos counter check just tells that is has been received by submgr
1087 // --> artificial delay
1088 <-time.After(1 * time.Second)
1089
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001090 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001091 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001092
1093 //Wait that subs is cleaned
1094 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1095
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001096 xappConn1.TestMsgChanEmpty(t)
1097 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001098 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001099 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001100}
1101
1102//-----------------------------------------------------------------------------
1103// TestSubDelReqCollision
1104//
1105// stub stub
1106// +-------+ +---------+ +---------+
1107// | xapp | | submgr | | e2term |
1108// +-------+ +---------+ +---------+
1109// | | |
1110// | [SUBS CREATE] |
1111// | | |
1112// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001113// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001114// |------------->| |
1115// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001116// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001117// | |------------->|
1118// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001119// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001120// | (same sub) | |
1121// | (diff xid) | |
1122// |------------->| |
1123// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001124// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001125// | |<-------------|
1126// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001127// | SubDelResp 1 | |
1128// |<-------------| |
1129// | | |
1130// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001131// |<-------------| |
1132//
1133//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001134
Juha Hyttinenfa015662020-01-24 10:05:18 +02001135func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001137
1138 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001139 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001140 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1141 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001142 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143
1144 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001146 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147
Juha Hyttinen3944a222020-01-24 11:51:46 +02001148 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001149 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001150 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1151 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1153
Juha Hyttinen1683f912020-04-17 10:39:57 +03001154 // hack as there is no real way to see has message be handled.
1155 // Previuos counter check just tells that is has been received by submgr
1156 // --> artificial delay
1157 <-time.After(1 * time.Second)
1158
Juha Hyttinen3944a222020-01-24 11:51:46 +02001159 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001160 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001161
1162 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001163 xappConn1.RecvSubsDelResp(t, nil)
1164 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001165
1166 //Wait that subs is cleaned
1167 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1168
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001169 xappConn1.TestMsgChanEmpty(t)
1170 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001171 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001172 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001173}
1174
1175//-----------------------------------------------------------------------------
1176// TestSubReqAndSubDelOkTwoParallel
1177//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001178// stub stub stub
1179// +-------+ +-------+ +---------+ +---------+
1180// | xapp | | xapp | | submgr | | e2term |
1181// +-------+ +-------+ +---------+ +---------+
1182// | | | |
1183// | | | |
1184// | | | |
1185// | | SubReq1 | |
1186// | |------------->| |
1187// | | | |
1188// | | | SubReq1 |
1189// | | |------------->|
1190// | | | |
1191// | SubReq2 | |
1192// |------------------------>| |
1193// | | | |
1194// | | | SubReq2 |
1195// | | |------------->|
1196// | | | |
1197// | | | SubResp1 |
1198// | | |<-------------|
1199// | | SubResp1 | |
1200// | |<-------------| |
1201// | | | |
1202// | | | SubResp2 |
1203// | | |<-------------|
1204// | SubResp2 | |
1205// |<------------------------| |
1206// | | | |
1207// | | [SUBS 1 DELETE] |
1208// | | | |
1209// | | [SUBS 2 DELETE] |
1210// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001211//
1212//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001213
Juha Hyttinenfa015662020-01-24 10:05:18 +02001214func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001215 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001216
1217 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001219 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001220 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001221 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001222
1223 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001224 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001225 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001226
1227 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1228 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1229 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1230
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001231 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001232 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001233
1234 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001235 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001236 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001237
1238 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001239 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001240 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001241
1242 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001243 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001244 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1245 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001246 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001247 //Wait that subs is cleaned
1248 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1249
1250 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001251 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001252 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1253 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001254 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001255 //Wait that subs is cleaned
1256 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1257
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001258 xappConn1.TestMsgChanEmpty(t)
1259 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001260 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001261 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001262}
1263
1264//-----------------------------------------------------------------------------
1265// TestSameSubsDiffRan
1266// Same subscription to different RANs
1267//
1268// stub stub
1269// +-------+ +---------+ +---------+
1270// | xapp | | submgr | | e2term |
1271// +-------+ +---------+ +---------+
1272// | | |
1273// | | |
1274// | | |
1275// | SubReq(r1) | |
1276// |------------->| |
1277// | | |
1278// | | SubReq(r1) |
1279// | |------------->|
1280// | | |
1281// | | SubResp(r1) |
1282// | |<-------------|
1283// | | |
1284// | SubResp(r1) | |
1285// |<-------------| |
1286// | | |
1287// | SubReq(r2) | |
1288// |------------->| |
1289// | | |
1290// | | SubReq(r2) |
1291// | |------------->|
1292// | | |
1293// | | SubResp(r2) |
1294// | |<-------------|
1295// | | |
1296// | SubResp(r2) | |
1297// |<-------------| |
1298// | | |
1299// | [SUBS r1 DELETE] |
1300// | | |
1301// | [SUBS r2 DELETE] |
1302// | | |
1303//
1304//-----------------------------------------------------------------------------
1305func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001306 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001307
1308 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001309 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1310 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001311 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1312 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001313 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001314
1315 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001316 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1317 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001318 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1319 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001320 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001321
1322 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001323 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1324 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001325 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1326 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001327 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001328 //Wait that subs is cleaned
1329 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1330
1331 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001332 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1333 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001334 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1335 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001336 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001337 //Wait that subs is cleaned
1338 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1339
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001340 xappConn1.TestMsgChanEmpty(t)
1341 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001342 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001343 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001344}
1345
1346//-----------------------------------------------------------------------------
1347// TestSubReqRetryInSubmgr
1348//
1349// stub stub
1350// +-------+ +---------+ +---------+
1351// | xapp | | submgr | | e2term |
1352// +-------+ +---------+ +---------+
1353// | | |
1354// | SubReq | |
1355// |------------->| |
1356// | | |
1357// | | SubReq |
1358// | |------------->|
1359// | | |
1360// | | |
1361// | | SubReq |
1362// | |------------->|
1363// | | |
1364// | | SubResp |
1365// | |<-------------|
1366// | | |
1367// | SubResp | |
1368// |<-------------| |
1369// | | |
1370// | [SUBS DELETE] |
1371// | | |
1372//
1373//-----------------------------------------------------------------------------
1374
1375func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001376 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001377
1378 // Init counter check
1379 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1380 Counter{cSubReqFromXapp, 1},
1381 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001382 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001383 Counter{cSubReReqToE2, 1},
1384 Counter{cSubRespFromE2, 1},
1385 Counter{cSubRespToXapp, 1},
1386 Counter{cSubDelReqFromXapp, 1},
1387 Counter{cSubDelReqToE2, 1},
1388 Counter{cSubDelRespFromE2, 1},
1389 Counter{cSubDelRespToXapp, 1},
1390 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001391
1392 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001393 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001394
1395 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001396 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001397
1398 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001399 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1400 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001401
1402 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001403 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001404
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001405 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001406 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1407 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001408 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001409
1410 // Wait that subs is cleaned
1411 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1412
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001413 xappConn1.TestMsgChanEmpty(t)
1414 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001415 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001416 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001417
1418 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001419}
1420
1421//-----------------------------------------------------------------------------
1422// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1423//
1424// stub stub
1425// +-------+ +---------+ +---------+
1426// | xapp | | submgr | | e2term |
1427// +-------+ +---------+ +---------+
1428// | | |
1429// | SubReq | |
1430// |------------->| |
1431// | | |
1432// | | SubReq |
1433// | |------------->|
1434// | | |
1435// | | |
1436// | | SubReq |
1437// | |------------->|
1438// | | |
1439// | | SubDelReq |
1440// | |------------->|
1441// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001442// | | SubDelResp |
1443// | |<-------------|
1444// | | |
1445//
1446//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001447func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001448 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001449
1450 // Init counter check
1451 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1452 Counter{cSubReqFromXapp, 1},
1453 Counter{cSubReqToE2, 1},
1454 Counter{cSubReReqToE2, 1},
1455 Counter{cSubReqTimerExpiry, 2},
1456 Counter{cSubDelReqToE2, 1},
1457 Counter{cSubDelRespFromE2, 1},
1458 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001459
1460 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001461 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001462
1463 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001464 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001465
1466 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001467 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001468
1469 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001470 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1471 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001472
1473 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001474 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001475
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001476 xappConn1.TestMsgChanEmpty(t)
1477 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001478 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001479 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001480
1481 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001482}
1483
1484//-----------------------------------------------------------------------------
1485// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1486//
1487// stub stub
1488// +-------+ +---------+ +---------+
1489// | xapp | | submgr | | e2term |
1490// +-------+ +---------+ +---------+
1491// | | |
1492// | SubReq | |
1493// |------------->| |
1494// | | |
1495// | | SubReq |
1496// | |------------->|
1497// | | |
1498// | | |
1499// | | SubReq |
1500// | |------------->|
1501// | | |
1502// | | SubDelReq |
1503// | |------------->|
1504// | | |
1505// | | |
1506// | | SubDelReq |
1507// | |------------->|
1508// | | |
1509// | | |
1510//
1511//-----------------------------------------------------------------------------
1512
1513func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001514 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001515
1516 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1517 Counter{cSubReqFromXapp, 1},
1518 Counter{cSubReqToE2, 1},
1519 Counter{cSubReReqToE2, 1},
1520 Counter{cSubReqTimerExpiry, 2},
1521 Counter{cSubDelReqToE2, 1},
1522 Counter{cSubDelReReqToE2, 1},
1523 Counter{cSubDelReqTimerExpiry, 2},
1524 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001525
1526 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001527 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001528
1529 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001530 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001531
1532 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001533 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001534
1535 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001536 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001537
1538 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001539 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001540
1541 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001542 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001543
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001544 xappConn1.TestMsgChanEmpty(t)
1545 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001546 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001547 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001548
1549 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001550}
1551
1552//-----------------------------------------------------------------------------
1553// TestSubReqSubFailRespInSubmgr
1554//
1555// stub stub
1556// +-------+ +---------+ +---------+
1557// | xapp | | submgr | | e2term |
1558// +-------+ +---------+ +---------+
1559// | | |
1560// | SubReq | |
1561// |------------->| |
1562// | | |
1563// | | SubReq |
1564// | |------------->|
1565// | | |
1566// | | SubFail |
1567// | |<-------------|
1568// | | |
1569// | SubFail | |
1570// |<-------------| |
1571// | | |
1572//
1573//-----------------------------------------------------------------------------
1574
1575func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001576 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001577
1578 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1579 Counter{cSubReqFromXapp, 1},
1580 Counter{cSubReqToE2, 1},
1581 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001582 Counter{cSubFailToXapp, 1},
1583 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001584
1585 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001586 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001587
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001588 // E2t: Receive SubsReq and send SubsFail (first)
1589 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1590 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1591 fparams1.Set(crereq1)
1592 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1593
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001594 // Xapp: Receive SubsFail
1595 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1596
1597 // Wait that subs is cleaned
1598 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1599
1600 xappConn1.TestMsgChanEmpty(t)
1601 xappConn2.TestMsgChanEmpty(t)
1602 e2termConn1.TestMsgChanEmpty(t)
1603 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001604
1605 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001606}
1607
1608//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001609// TestSubDelReqRetryInSubmgr
1610//
1611// stub stub
1612// +-------+ +---------+ +---------+
1613// | xapp | | submgr | | e2term |
1614// +-------+ +---------+ +---------+
1615// | | |
1616// | [SUBS CREATE] |
1617// | | |
1618// | | |
1619// | SubDelReq | |
1620// |------------->| |
1621// | | |
1622// | | SubDelReq |
1623// | |------------->|
1624// | | |
1625// | | SubDelReq |
1626// | |------------->|
1627// | | |
1628// | | SubDelResp |
1629// | |<-------------|
1630// | | |
1631// | SubDelResp | |
1632// |<-------------| |
1633//
1634//-----------------------------------------------------------------------------
1635
1636func TestSubDelReqRetryInSubmgr(t *testing.T) {
1637
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001638 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001639
1640 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001641 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001642 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1643 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001644 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001645
1646 // Subs Delete
1647 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001648 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001649
1650 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001651 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001652
1653 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001654 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1655 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001656
1657 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001658 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001659
1660 // Wait that subs is cleaned
1661 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1662
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001663 xappConn1.TestMsgChanEmpty(t)
1664 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001665 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001666 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001667}
1668
1669//-----------------------------------------------------------------------------
1670// TestSubDelReqTwoRetriesNoRespInSubmgr
1671//
1672// stub stub
1673// +-------+ +---------+ +---------+
1674// | xapp | | submgr | | e2term |
1675// +-------+ +---------+ +---------+
1676// | | |
1677// | [SUBS CREATE] |
1678// | | |
1679// | | |
1680// | SubDelReq | |
1681// |------------->| |
1682// | | |
1683// | | SubDelReq |
1684// | |------------->|
1685// | | |
1686// | | SubDelReq |
1687// | |------------->|
1688// | | |
1689// | | |
1690// | SubDelResp | |
1691// |<-------------| |
1692//
1693//-----------------------------------------------------------------------------
1694
1695func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1696
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001697 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001698
1699 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001700 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001701 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1702 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001703 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001704
1705 // Subs Delete
1706 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001707 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001708
1709 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001710 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001711
1712 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001713 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001714
1715 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001716 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001717
1718 // Wait that subs is cleaned
1719 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1720
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001721 xappConn1.TestMsgChanEmpty(t)
1722 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001723 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001724 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001725}
1726
1727//-----------------------------------------------------------------------------
1728// TestSubDelReqSubDelFailRespInSubmgr
1729//
1730// stub stub
1731// +-------+ +---------+ +---------+
1732// | xapp | | submgr | | e2term |
1733// +-------+ +---------+ +---------+
1734// | | |
1735// | [SUBS CREATE] |
1736// | | |
1737// | | |
1738// | SubDelReq | |
1739// |------------->| |
1740// | | |
1741// | | SubDelReq |
1742// | |------------->|
1743// | | |
1744// | | SubDelFail |
1745// | |<-------------|
1746// | | |
1747// | SubDelResp | |
1748// |<-------------| |
1749// | | |
1750//
1751//-----------------------------------------------------------------------------
1752
1753func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001754 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001755
1756 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1757 Counter{cSubReqFromXapp, 1},
1758 Counter{cSubReqToE2, 1},
1759 Counter{cSubRespFromE2, 1},
1760 Counter{cSubRespToXapp, 1},
1761 Counter{cSubDelReqFromXapp, 1},
1762 Counter{cSubDelReqToE2, 1},
1763 Counter{cSubDelFailFromE2, 1},
1764 Counter{cSubDelRespToXapp, 1},
1765 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001766
1767 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001769 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1770 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001771 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001772
1773 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001774 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001775
1776 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001777 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1778 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001779
1780 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001781 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001782
1783 // Wait that subs is cleaned
1784 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1785
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001786 xappConn1.TestMsgChanEmpty(t)
1787 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001788 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001789 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001790
1791 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001792}
1793
1794//-----------------------------------------------------------------------------
1795// TestSubReqAndSubDelOkSameAction
1796//
1797// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001798// +-------+ +-------+ +---------+ +---------+
1799// | xapp2 | | xapp1 | | submgr | | e2term |
1800// +-------+ +-------+ +---------+ +---------+
1801// | | | |
1802// | | | |
1803// | | | |
1804// | | SubReq1 | |
1805// | |------------->| |
1806// | | | |
1807// | | | SubReq1 |
1808// | | |------------->|
1809// | | | SubResp1 |
1810// | | |<-------------|
1811// | | SubResp1 | |
1812// | |<-------------| |
1813// | | | |
1814// | SubReq2 | |
1815// |--------------------------->| |
1816// | | | |
1817// | SubResp2 | |
1818// |<---------------------------| |
1819// | | | |
1820// | | SubDelReq 1 | |
1821// | |------------->| |
1822// | | | |
1823// | | SubDelResp 1 | |
1824// | |<-------------| |
1825// | | | |
1826// | SubDelReq 2 | |
1827// |--------------------------->| |
1828// | | | |
1829// | | | SubDelReq 2 |
1830// | | |------------->|
1831// | | | |
1832// | | | SubDelReq 2 |
1833// | | |------------->|
1834// | | | |
1835// | SubDelResp 2 | |
1836// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001837//
1838//-----------------------------------------------------------------------------
1839func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001840 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001841
Anssi Mannila4abf1802021-01-28 13:06:46 +02001842 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001843 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1844 Counter{cSubReqFromXapp, 2},
1845 Counter{cSubReqToE2, 1},
1846 Counter{cSubRespFromE2, 1},
1847 Counter{cSubRespToXapp, 2},
1848 Counter{cMergedSubscriptions, 1},
1849 Counter{cUnmergedSubscriptions, 1},
1850 Counter{cSubDelReqFromXapp, 2},
1851 Counter{cSubDelReqToE2, 1},
1852 Counter{cSubDelRespFromE2, 1},
1853 Counter{cSubDelRespToXapp, 2},
1854 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001855
Juha Hyttinen3944a222020-01-24 11:51:46 +02001856 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001857 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001858 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001859 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001860 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1861 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001862 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001863
1864 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001865 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001866 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001867 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001868 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001869
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001870 resp, _ := xapp.Subscription.QuerySubscriptions()
1871 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1872 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001873 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001874
Juha Hyttinen3944a222020-01-24 11:51:46 +02001875 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001876 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001877 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001878
1879 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001880 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001881 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1882 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001883 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001884 //Wait that subs is cleaned
1885 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1886
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001887 xappConn1.TestMsgChanEmpty(t)
1888 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001889 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001890 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001891
1892 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001893}
1894
1895//-----------------------------------------------------------------------------
1896// TestSubReqAndSubDelOkSameActionParallel
1897//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001898// stub stub stub
1899// +-------+ +-------+ +---------+ +---------+
1900// | xapp2 | | xapp1 | | submgr | | e2term |
1901// +-------+ +-------+ +---------+ +---------+
1902// | | | |
1903// | | | |
1904// | | | |
1905// | | SubReq1 | |
1906// | |------------->| |
1907// | | | |
1908// | | | SubReq1 |
1909// | | |------------->|
1910// | SubReq2 | |
1911// |--------------------------->| |
1912// | | | SubResp1 |
1913// | | |<-------------|
1914// | | SubResp1 | |
1915// | |<-------------| |
1916// | | | |
1917// | SubResp2 | |
1918// |<---------------------------| |
1919// | | | |
1920// | | SubDelReq 1 | |
1921// | |------------->| |
1922// | | | |
1923// | | SubDelResp 1 | |
1924// | |<-------------| |
1925// | | | |
1926// | SubDelReq 2 | |
1927// |--------------------------->| |
1928// | | | |
1929// | | | SubDelReq 2 |
1930// | | |------------->|
1931// | | | |
1932// | | | SubDelReq 2 |
1933// | | |------------->|
1934// | | | |
1935// | SubDelResp 2 | |
1936// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001937//
1938//-----------------------------------------------------------------------------
1939func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001940 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001941
1942 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001943 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001944 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001945 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001946 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001947
1948 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001949 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001950 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001951 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001952
1953 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001954 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001955 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001956
1957 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001958 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001959
1960 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001961 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1962 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001963
1964 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001965 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001966 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1967 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001968 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001969
1970 //Wait that subs is cleaned
1971 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1972
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001973 xappConn1.TestMsgChanEmpty(t)
1974 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001975 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001976 mainCtrl.wait_registry_empty(t, 10)
1977}
1978
1979//-----------------------------------------------------------------------------
1980// TestSubReqAndSubDelNokSameActionParallel
1981//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001982// stub stub stub
1983// +-------+ +-------+ +---------+ +---------+
1984// | xapp2 | | xapp1 | | submgr | | e2term |
1985// +-------+ +-------+ +---------+ +---------+
1986// | | | |
1987// | | | |
1988// | | | |
1989// | | SubReq1 | |
1990// | |------------->| |
1991// | | | |
1992// | | | SubReq1 |
1993// | | |------------->|
1994// | SubReq2 | |
1995// |--------------------------->| |
1996// | | | SubFail1 |
1997// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001998// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001999// | | SubFail1 | |
2000// | |<-------------| |
2001// | | | |
2002// | SubFail2 | |
2003// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02002004//
2005//-----------------------------------------------------------------------------
2006func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002007 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002008
2009 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002010 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002011 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002012 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002013
2014 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002015 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002016
2017 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002018 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002019 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002020 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002021 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002022 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002023
Juha Hyttinenf28853b2020-03-09 14:02:50 +02002024 // E2t: send SubsFail (first)
2025 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2026 fparams1.Set(crereq1)
2027 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2028
Juha Hyttinen3944a222020-01-24 11:51:46 +02002029 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002030 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002031 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002032 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002033
2034 //Wait that subs is cleaned
2035 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
2036
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002037 xappConn1.TestMsgChanEmpty(t)
2038 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002039 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002040 mainCtrl.wait_registry_empty(t, 10)
2041}
2042
2043//-----------------------------------------------------------------------------
2044// TestSubReqAndSubDelNoAnswerSameActionParallel
2045//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002046// stub stub stub
2047// +-------+ +-------+ +---------+ +---------+
2048// | xapp2 | | xapp1 | | submgr | | e2term |
2049// +-------+ +-------+ +---------+ +---------+
2050// | | | |
2051// | | | |
2052// | | | |
2053// | | SubReq1 | |
2054// | |------------->| |
2055// | | | |
2056// | | | SubReq1 |
2057// | | |------------->|
2058// | | SubReq2 | |
2059// |--------------------------->| |
2060// | | | |
2061// | | | SubReq1 |
2062// | | |------------->|
2063// | | | |
2064// | | | |
2065// | | | SubDelReq |
2066// | | |------------->|
2067// | | | |
2068// | | | SubDelResp |
2069// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02002070//
2071//-----------------------------------------------------------------------------
2072func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002073 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02002074
2075 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002076 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002077 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002078 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002079
Juha Hyttinen1683f912020-04-17 10:39:57 +03002080 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002081
2082 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002083 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02002084 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03002085 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002086 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03002087 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002088
2089 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002090 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002091
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002092 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2093 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002094
2095 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002096 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002097
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002098 xappConn1.TestMsgChanEmpty(t)
2099 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002100 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002101 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002102}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002103
2104//----------------------------- Policy cases ---------------------------------
2105//-----------------------------------------------------------------------------
2106// TestSubReqPolicyAndSubDelOk
2107//
2108// stub stub
2109// +-------+ +---------+ +---------+
2110// | xapp | | submgr | | e2term |
2111// +-------+ +---------+ +---------+
2112// | | |
2113// | SubReq | |
2114// |------------->| |
2115// | | |
2116// | | SubReq |
2117// | |------------->|
2118// | | |
2119// | | SubResp |
2120// | |<-------------|
2121// | | |
2122// | SubResp | |
2123// |<-------------| |
2124// | | |
2125// | | |
2126// | SubDelReq | |
2127// |------------->| |
2128// | | |
2129// | | SubDelReq |
2130// | |------------->|
2131// | | |
2132// | | SubDelResp |
2133// | |<-------------|
2134// | | |
2135// | SubDelResp | |
2136// |<-------------| |
2137//
2138//-----------------------------------------------------------------------------
2139func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2140 CaseBegin("TestSubReqAndSubDelOk")
2141
2142 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2143 rparams1.Init()
2144 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2145 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2146
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002147 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2148 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002149 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2150 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002151 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002152
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002153 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002154 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002155
2156 //Wait that subs is cleaned
2157 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2158
2159 xappConn1.TestMsgChanEmpty(t)
2160 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002161 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002162 mainCtrl.wait_registry_empty(t, 10)
2163}
2164
2165//-----------------------------------------------------------------------------
2166// TestSubReqPolicyChangeAndSubDelOk
2167//
2168// stub stub
2169// +-------+ +---------+ +---------+
2170// | xapp | | submgr | | e2term |
2171// +-------+ +---------+ +---------+
2172// | | |
2173// | SubReq | |
2174// |------------->| |
2175// | | |
2176// | | SubReq |
2177// | |------------->|
2178// | | |
2179// | | SubResp |
2180// | |<-------------|
2181// | | |
2182// | SubResp | |
2183// |<-------------| |
2184// | | |
2185// | SubReq | |
2186// |------------->| |
2187// | | |
2188// | | SubReq |
2189// | |------------->|
2190// | | |
2191// | | SubResp |
2192// | |<-------------|
2193// | | |
2194// | SubResp | |
2195// |<-------------| |
2196// | | |
2197// | SubDelReq | |
2198// |------------->| |
2199// | | |
2200// | | SubDelReq |
2201// | |------------->|
2202// | | |
2203// | | SubDelResp |
2204// | |<-------------|
2205// | | |
2206// | SubDelResp | |
2207// |<-------------| |
2208//
2209//-----------------------------------------------------------------------------
2210
2211func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2212 CaseBegin("TestSubReqAndSubDelOk")
2213
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002214 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2215 rparams1.Init()
2216 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2217 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002218
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002219 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2220 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002221 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2222
2223 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002224 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002225 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2226 xappConn1.SendSubsReq(t, rparams1, cretrans)
2227
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002228 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2229 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002230 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2231 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002232 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002233
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002234 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002235 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002236
2237 //Wait that subs is cleaned
2238 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2239
2240 xappConn1.TestMsgChanEmpty(t)
2241 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002242 e2termConn1.TestMsgChanEmpty(t)
2243 mainCtrl.wait_registry_empty(t, 10)
2244}
2245
2246//-----------------------------------------------------------------------------
2247// TestSubReqAndSubDelOkTwoE2termParallel
2248//
2249// stub stub stub
2250// +-------+ +---------+ +---------+ +---------+
2251// | xapp | | submgr | | e2term1 | | e2term2 |
2252// +-------+ +---------+ +---------+ +---------+
2253// | | | |
2254// | | | |
2255// | | | |
2256// | SubReq1 | | |
2257// |------------->| | |
2258// | | | |
2259// | | SubReq1 | |
2260// | |------------->| |
2261// | | | |
2262// | SubReq2 | | |
2263// |------------->| | |
2264// | | | |
2265// | | SubReq2 | |
2266// | |---------------------------->|
2267// | | | |
2268// | | SubResp1 | |
2269// | |<-------------| |
2270// | SubResp1 | | |
2271// |<-------------| | |
2272// | | SubResp2 | |
2273// | |<----------------------------|
2274// | SubResp2 | | |
2275// |<-------------| | |
2276// | | | |
2277// | [SUBS 1 DELETE] | |
2278// | | | |
2279// | [SUBS 2 DELETE] | |
2280// | | | |
2281//
2282//-----------------------------------------------------------------------------
2283func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2284 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2285
2286 //Req1
2287 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2288 xappConn1.SendSubsReq(t, nil, cretrans1)
2289 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2290
2291 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2292 xappConn1.SendSubsReq(t, nil, cretrans2)
2293 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2294
2295 //Resp1
2296 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2297 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2298
2299 //Resp2
2300 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2301 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2302
2303 //Del1
2304 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2305 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2306 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2307 xappConn1.RecvSubsDelResp(t, deltrans1)
2308 //Wait that subs is cleaned
2309 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2310
2311 //Del2
2312 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2313 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2314 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2315 xappConn1.RecvSubsDelResp(t, deltrans2)
2316 //Wait that subs is cleaned
2317 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2318
2319 xappConn1.TestMsgChanEmpty(t)
2320 xappConn2.TestMsgChanEmpty(t)
2321 e2termConn1.TestMsgChanEmpty(t)
2322 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002323 mainCtrl.wait_registry_empty(t, 10)
2324}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002325
2326//-----------------------------------------------------------------------------
2327// TestSubReqInsertAndSubDelOk
2328//
2329// stub stub
2330// +-------+ +---------+ +---------+
2331// | xapp | | submgr | | e2term |
2332// +-------+ +---------+ +---------+
2333// | | |
2334// | SubReq | |
2335// |------------->| |
2336// | | |
2337// | | SubReq |
2338// | |------------->|
2339// | | |
2340// | | SubResp |
2341// | |<-------------|
2342// | | |
2343// | SubResp | |
2344// |<-------------| |
2345// | | |
2346// | | |
2347// | SubDelReq | |
2348// |------------->| |
2349// | | |
2350// | | SubDelReq |
2351// | |------------->|
2352// | | |
2353// | | SubDelResp |
2354// | |<-------------|
2355// | | |
2356// | SubDelResp | |
2357// |<-------------| |
2358//
2359//-----------------------------------------------------------------------------
2360func TestSubReqInsertAndSubDelOk(t *testing.T) {
2361 CaseBegin("TestInsertSubReqAndSubDelOk")
2362
2363 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2364 rparams1.Init()
2365 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2366 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2367
2368 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2369 e2termConn1.SendSubsResp(t, crereq, cremsg)
2370 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2371 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2372 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2373
2374 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2375 xappConn1.RecvSubsDelResp(t, deltrans)
2376
2377 //Wait that subs is cleaned
2378 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2379
2380 xappConn1.TestMsgChanEmpty(t)
2381 xappConn2.TestMsgChanEmpty(t)
2382 e2termConn1.TestMsgChanEmpty(t)
2383 mainCtrl.wait_registry_empty(t, 10)
2384}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002385
2386//-----------------------------------------------------------------------------
2387// TestSubReqRetransmissionWithSameSubIdDiffXid
2388//
2389// This case simulates case where xApp restarts and starts sending same
2390// subscription requests which have already subscribed successfully
2391
2392// stub stub
2393// +-------+ +---------+ +---------+
2394// | xapp | | submgr | | e2term |
2395// +-------+ +---------+ +---------+
2396// | | |
2397// | SubReq | |
2398// |------------->| |
2399// | | |
2400// | | SubReq |
2401// | |------------->|
2402// | | |
2403// | | SubResp |
2404// | |<-------------|
2405// | | |
2406// | SubResp | |
2407// |<-------------| |
2408// | | |
2409// | xApp restart | |
2410// | | |
2411// | SubReq | |
2412// | (retrans with same xApp generated subid but diff xid)
2413// |------------->| |
2414// | | |
2415// | SubResp | |
2416// |<-------------| |
2417// | | |
2418// | [SUBS DELETE] |
2419// | | |
2420//
2421//-----------------------------------------------------------------------------
2422func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2423 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2424
2425 //Subs Create
2426 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2427 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2428 e2termConn1.SendSubsResp(t, crereq, cremsg)
2429 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2430
2431 // xApp restart here
2432 // --> artificial delay
2433 <-time.After(1 * time.Second)
2434
2435 //Subs Create
2436 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2437 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2438
2439 //Subs Delete
2440 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2441 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2442 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2443 xappConn1.RecvSubsDelResp(t, deltrans)
2444
2445 //Wait that subs is cleaned
2446 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2447
2448 xappConn1.TestMsgChanEmpty(t)
2449 xappConn2.TestMsgChanEmpty(t)
2450 e2termConn1.TestMsgChanEmpty(t)
2451 mainCtrl.wait_registry_empty(t, 10)
2452}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002453
2454//-----------------------------------------------------------------------------
2455// TestSubReqNokAndSubDelOkWithRestartInMiddle
2456//
2457// stub stub
2458// +-------+ +---------+ +---------+
2459// | xapp | | submgr | | e2term |
2460// +-------+ +---------+ +---------+
2461// | | |
2462// | SubReq | |
2463// |------------->| |
2464// | | |
2465// | | SubReq |
2466// | |------------->|
2467// | | |
2468// | | SubResp |
2469// | <----|
2470// | |
2471// | Submgr restart |
2472// | |
2473// | | |
2474// | | SubDelReq |
2475// | |------------->|
2476// | | |
2477// | | SubDelResp |
2478// | |<-------------|
2479// | | |
2480//
2481//-----------------------------------------------------------------------------
2482
2483func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2484 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2485
Anssi Mannilac92b4212020-12-07 14:59:34 +02002486 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2487 xappConn1.SendSubsReq(t, nil, nil)
2488 e2termConn1.RecvSubsReq(t)
2489 mainCtrl.SetResetTestFlag(t, false)
2490
2491 resp, _ := xapp.Subscription.QuerySubscriptions()
2492 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002493 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002494 e2SubsId := uint32(resp[0].SubscriptionID)
2495 t.Logf("e2SubsId = %v", e2SubsId)
2496
archaggeafbf95f2021-04-14 08:54:05 +03002497 mainCtrl.SimulateRestart(t)
2498 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002499
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002500 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002501 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2502 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2503
2504 // Wait that subs is cleaned
2505 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2506
2507 xappConn1.TestMsgChanEmpty(t)
2508 xappConn2.TestMsgChanEmpty(t)
2509 e2termConn1.TestMsgChanEmpty(t)
2510 mainCtrl.wait_registry_empty(t, 10)
2511}
2512
2513//-----------------------------------------------------------------------------
2514// TestSubReqAndSubDelOkWithRestartInMiddle
2515//
2516// stub stub
2517// +-------+ +---------+ +---------+
2518// | xapp | | submgr | | e2term |
2519// +-------+ +---------+ +---------+
2520// | | |
2521// | SubReq | |
2522// |------------->| |
2523// | | |
2524// | | SubReq |
2525// | |------------->|
2526// | | |
2527// | | SubResp |
2528// | |<-------------|
2529// | | |
2530// | SubResp | |
2531// |<-------------| |
2532// | | |
2533// | |
2534// | Submgr restart |
2535// | |
2536// | SubDelReq | |
2537// |------------->| |
2538// | | |
2539// | | SubDelReq |
2540// | |------------->|
2541// | | |
2542// | | SubDelResp |
2543// | |<-------------|
2544// | | |
2545// | SubDelResp | |
2546// |<-------------| |
2547//
2548//-----------------------------------------------------------------------------
2549
2550func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2551 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2552
2553 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2554 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2555 e2termConn1.SendSubsResp(t, crereq, cremsg)
2556 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2557
2558 // Check subscription
2559 resp, _ := xapp.Subscription.QuerySubscriptions()
2560 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2561 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002562 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002563
2564 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002565 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002566
Anssi Mannila54838ed2021-11-19 11:25:01 +02002567 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2568 // That needs to be completed before successful subscription query is possible
2569 <-time.After(time.Second * 1)
2570
Anssi Mannilac92b4212020-12-07 14:59:34 +02002571 // Check that subscription is restored correctly after restart
2572 resp, _ = xapp.Subscription.QuerySubscriptions()
2573 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2574 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002575 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002576
2577 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2578 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2579 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2580 xappConn1.RecvSubsDelResp(t, deltrans)
2581
2582 //Wait that subs is cleaned
2583 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2584
2585 xappConn1.TestMsgChanEmpty(t)
2586 xappConn2.TestMsgChanEmpty(t)
2587 e2termConn1.TestMsgChanEmpty(t)
2588 mainCtrl.wait_registry_empty(t, 10)
2589}
2590
2591//-----------------------------------------------------------------------------
2592// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2593//
2594// stub stub
2595// +-------+ +-------+ +---------+ +---------+
2596// | xapp2 | | xapp1 | | submgr | | e2term |
2597// +-------+ +-------+ +---------+ +---------+
2598// | | | |
2599// | | | |
2600// | | | |
2601// | | SubReq1 | |
2602// | |------------->| |
2603// | | | |
2604// | | | SubReq1 |
2605// | | |------------->|
2606// | | | SubResp1 |
2607// | | |<-------------|
2608// | | SubResp1 | |
2609// | |<-------------| |
2610// | | | |
2611// | |
2612// | submgr restart |
2613// | |
2614// | | | |
2615// | | | |
2616// | SubReq2 | |
2617// |--------------------------->| |
2618// | | | |
2619// | SubResp2 | |
2620// |<---------------------------| |
2621// | | | |
2622// | | SubDelReq 1 | |
2623// | |------------->| |
2624// | | | |
2625// | | SubDelResp 1 | |
2626// | |<-------------| |
2627// | | | |
2628// | | | |
2629// | |
2630// | submgr restart |
2631// | |
2632// | | | |
2633// | SubDelReq 2 | |
2634// |--------------------------->| |
2635// | | | |
2636// | | | SubDelReq 2 |
2637// | | |------------->|
2638// | | | |
2639// | | | SubDelReq 2 |
2640// | | |------------->|
2641// | | | |
2642// | SubDelResp 2 | |
2643// |<---------------------------| |
2644//
2645//-----------------------------------------------------------------------------
2646
2647func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2648 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2649
2650 //Req1
2651 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2652 rparams1.Init()
2653 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2654 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2655 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2656 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2657
2658 //Req2
2659 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2660 rparams2.Init()
2661 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2662 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2663
2664 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002665 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002666 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2667 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002668 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002669
2670 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002671 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002672
Anssi Mannila54838ed2021-11-19 11:25:01 +02002673 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2674 // That needs to be completed before successful subscription query is possible
2675 <-time.After(time.Second * 1)
2676
Anssi Mannilac92b4212020-12-07 14:59:34 +02002677 // Check that subscription is restored correctly after restart
2678 resp, _ = xapp.Subscription.QuerySubscriptions()
2679 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2680 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002681 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002682
2683 //Del1
2684 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2685 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2686 xappConn1.RecvSubsDelResp(t, deltrans1)
2687 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2688
2689 mainCtrl.SimulateRestart(t)
2690 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2691
Anssi Mannila54838ed2021-11-19 11:25:01 +02002692 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2693 // Submgr need be ready before successful subscription deletion is possible
2694 <-time.After(time.Second * 1)
2695
Anssi Mannilac92b4212020-12-07 14:59:34 +02002696 //Del2
2697 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2698 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2699
2700 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2701 xappConn2.RecvSubsDelResp(t, deltrans2)
2702
2703 //Wait that subs is cleaned
2704 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2705
2706 xappConn1.TestMsgChanEmpty(t)
2707 xappConn2.TestMsgChanEmpty(t)
2708 e2termConn1.TestMsgChanEmpty(t)
2709 mainCtrl.wait_registry_empty(t, 10)
2710}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002711
archaggeafbf95f2021-04-14 08:54:05 +03002712//*****************************************************************************
2713// REST interface test cases
2714//*****************************************************************************
2715
Anssi Mannila47518ae2021-04-16 09:27:07 +03002716//-----------------------------------------------------------------------------
2717// Test debug GET and POST requests
2718//
2719// curl
2720// +-------+ +---------+
2721// | user | | submgr |
2722// +-------+ +---------+
2723// | |
2724// | GET/POST Req |
2725// |------------->|
2726// | Resp |
2727// |<-------------|
2728// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002729func TestGetSubscriptions(t *testing.T) {
2730
Anssi Mannila92c38552021-12-29 09:59:24 +02002731 mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002732}
2733
2734func TestGetSymptomData(t *testing.T) {
2735
Anssi Mannila92c38552021-12-29 09:59:24 +02002736 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002737}
2738
2739func TestPostdeleteSubId(t *testing.T) {
2740
Anssi Mannila92c38552021-12-29 09:59:24 +02002741 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002742}
2743
2744func TestPostEmptyDb(t *testing.T) {
2745
Anssi Mannila92c38552021-12-29 09:59:24 +02002746 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002747}
archaggeafbf95f2021-04-14 08:54:05 +03002748
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002749func TestGetRestSubscriptions(t *testing.T) {
2750
Anssi Mannila92c38552021-12-29 09:59:24 +02002751 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2752}
2753
2754//-----------------------------------------------------------------------------
2755// TestDelAllE2nodeSubsViaDebugIf
2756//
2757// stub stub stub
2758// +-------+ +---------+ +---------+ +---------+
2759// | xapp | | submgr | | e2term | | rtmgr |
2760// +-------+ +---------+ +---------+ +---------+
2761// | | | |
2762// | RESTSubReq | | |
2763// |---------------->| | |
2764// | RESTSubResp | | |
2765// |<----------------| | |
2766// | | RouteCreate | |
2767// | |--------------------------->|
2768// | | RouteResponse| |
2769// | |<---------------------------|
2770// | | SubReq | |
2771// | |------------->| |
2772// | | SubResp | |
2773// | |<-------------| |
2774// | RESTNotif1 | | |
2775// |<----------------| | |
2776// | | | |
2777// | REST get_all_e2nodes | |
2778// |---------------->| | |
2779// | OK 200 | | |
2780// |<----------------| | |
2781// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1
2782// |---------------->| | |
2783// | OK 200 | | |
2784// |<----------------| | |
2785// | | SubDelReq | |
2786// | |------------->| |
2787// | | SubDelResp | |
2788// | |<-------------| |
2789// | | | |
2790// | | RouteDelete | |
2791// | |--------------------------->|
2792// | | RouteResponse| |
2793// | |<---------------------------|
2794//
2795//-----------------------------------------------------------------------------
2796
2797func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
2798
2799 // Init counter check
2800 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2801 Counter{cRestSubReqFromXapp, 1},
2802 Counter{cRestSubRespToXapp, 1},
2803 Counter{cSubReqToE2, 1},
2804 Counter{cSubRespFromE2, 1},
2805 Counter{cRestSubNotifToXapp, 1},
2806 Counter{cRestSubDelReqFromXapp, 1},
2807 Counter{cSubDelReqToE2, 1},
2808 Counter{cSubDelRespFromE2, 1},
2809 Counter{cRestSubDelRespToXapp, 1},
2810 })
2811
2812 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2813 restSubId := xappConn1.SendRESTSubsReq(t, params)
2814 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2815
2816 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2817 xappConn1.ExpectRESTNotification(t, restSubId)
2818 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2819 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2820 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2821
2822 e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes")
2823
2824 var e2nodesList []string
2825 err := json.Unmarshal(e2nodesJson, &e2nodesList)
2826 if err != nil {
2827 t.Errorf("Unmarshal error: %s", err)
2828 }
2829 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList))
2830
2831 e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2832 var e2RestSubsMap map[string]RESTSubscription
2833 err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap)
2834 if err != nil {
2835 t.Errorf("Unmarshal error: %s", err)
2836 }
2837
2838 if len(e2RestSubsMap) != 1 {
2839 t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap))
2840 }
2841
2842 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002843 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 +02002844 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2845 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2846
2847 // Wait that subs is cleaned
2848 waitSubsCleanup(t, e2SubsId, 10)
2849 mainCtrl.VerifyCounterValues(t)
2850 mainCtrl.VerifyAllClean(t)
2851}
2852
2853//-----------------------------------------------------------------------------
2854// TestDelAllxAppSubsViaDebugIf
2855//
2856// stub stub stub
2857// +-------+ +---------+ +---------+ +---------+
2858// | xapp | | submgr | | e2term | | rtmgr |
2859// +-------+ +---------+ +---------+ +---------+
2860// | | | |
2861// | RESTSubReq | | |
2862// |---------------->| | |
2863// | RESTSubResp | | |
2864// |<----------------| | |
2865// | | RouteCreate | |
2866// | |--------------------------->|
2867// | | RouteResponse| |
2868// | |<---------------------------|
2869// | | SubReq | |
2870// | |------------->| |
2871// | | SubResp | |
2872// | |<-------------| |
2873// | RESTNotif1 | | |
2874// |<----------------| | |
2875// | | | |
2876// | REST get_all_xapps | |
2877// |---------------->| | |
2878// | OK 200 | | |
2879// |<----------------| | |
2880// | REST delete_all_xapp_subscriptions | xappServiceName = localhost
2881// |---------------->| | |
2882// | OK 200 | | |
2883// |<----------------| | |
2884// | | SubDelReq | |
2885// | |------------->| |
2886// | | SubDelResp | |
2887// | |<-------------| |
2888// | | | |
2889// | | RouteDelete | |
2890// | |--------------------------->|
2891// | | RouteResponse| |
2892// | |<---------------------------|
2893//
2894//-----------------------------------------------------------------------------
2895
2896func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
2897
2898 // Init counter check
2899 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2900 Counter{cRestSubReqFromXapp, 1},
2901 Counter{cRestSubRespToXapp, 1},
2902 Counter{cSubReqToE2, 1},
2903 Counter{cSubRespFromE2, 1},
2904 Counter{cRestSubNotifToXapp, 1},
2905 Counter{cRestSubDelReqFromXapp, 1},
2906 Counter{cSubDelReqToE2, 1},
2907 Counter{cSubDelRespFromE2, 1},
2908 Counter{cRestSubDelRespToXapp, 1},
2909 })
2910
2911 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2912 restSubId := xappConn1.SendRESTSubsReq(t, params)
2913 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2914
2915 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2916 xappConn1.ExpectRESTNotification(t, restSubId)
2917 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2918 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2919 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2920
2921 xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps")
2922
2923 var xappList []string
2924 err := json.Unmarshal(xappsJson, &xappList)
2925 if err != nil {
2926 t.Errorf("Unmarshal error: %s", err)
2927 }
2928 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
2929
2930 // Simulate deletion through REST test and debug interface
Anssi Mannilad13ba632022-01-04 14:22:26 +02002931 mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
Anssi Mannila92c38552021-12-29 09:59:24 +02002932 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2933 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2934
2935 // Wait that subs is cleaned
2936 waitSubsCleanup(t, e2SubsId, 10)
2937 mainCtrl.VerifyCounterValues(t)
2938 mainCtrl.VerifyAllClean(t)
2939}
2940
2941//-----------------------------------------------------------------------------
2942// TestDelViaxAppSubsIf
2943//
2944// stub stub stub
2945// +-------+ +---------+ +---------+ +---------+
2946// | xapp | | submgr | | e2term | | rtmgr |
2947// +-------+ +---------+ +---------+ +---------+
2948// | | | |
2949// | RESTSubReq | | |
2950// |---------------->| | |
2951// | RESTSubResp | | |
2952// |<----------------| | |
2953// | | RouteCreate | |
2954// | |--------------------------->|
2955// | | RouteResponse| |
2956// | |<---------------------------|
2957// | | SubReq | |
2958// | |------------->| |
2959// | | SubResp | |
2960// | |<-------------| |
2961// | RESTNotif1 | | |
2962// |<----------------| | |
2963// | | | |
2964// | REST get_xapp_rest_restsubscriptions |
2965// |---------------->| | |
2966// | OK 200 | | |
2967// |<----------------| | |
2968// | RESTSudDel | | |
2969// |---------------->| | | Via user curl command (port 8088)
2970// | RESTSudDel | | |
2971// |<----------------| | |
2972// | | SubDelReq | |
2973// | |------------->| |
2974// | | SubDelResp | |
2975// | |<-------------| |
2976// | | | |
2977// | | RouteDelete | |
2978// | |--------------------------->|
2979// | | RouteResponse| |
2980// | |<---------------------------|
2981//
2982//-----------------------------------------------------------------------------
2983
2984func TestDelViaxAppSubsIf(t *testing.T) {
2985
2986 // Init counter check
2987 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2988 Counter{cRestSubReqFromXapp, 1},
2989 Counter{cRestSubRespToXapp, 1},
2990 Counter{cSubReqToE2, 1},
2991 Counter{cSubRespFromE2, 1},
2992 Counter{cRestSubNotifToXapp, 1},
2993 Counter{cRestSubDelReqFromXapp, 1},
2994 Counter{cSubDelReqToE2, 1},
2995 Counter{cSubDelRespFromE2, 1},
2996 Counter{cRestSubDelRespToXapp, 1},
2997 })
2998
2999 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3000 restSubId := xappConn1.SendRESTSubsReq(t, params)
3001 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3002
3003 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3004 xappConn1.ExpectRESTNotification(t, restSubId)
3005 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3006 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3007 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
3008
3009 restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName
3010
3011 var restSubsMap map[string]RESTSubscription
3012 err := json.Unmarshal(restSubsListJson, &restSubsMap)
3013 if err != nil {
3014 t.Errorf("Unmarshal error: %s", err)
3015 }
3016 _, ok := restSubsMap[restSubId]
3017 if !ok {
3018 t.Errorf("REST subscription not found. restSubId=%s", restSubId)
3019 }
3020
3021 var e2Subscriptions []Subscription
3022 e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId)
3023 err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions)
3024 if err != nil {
3025 t.Errorf("Unmarshal error: %s", err)
3026 }
3027 if len(e2Subscriptions) != 1 {
3028 t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions))
3029 }
3030
3031 // Simulate deletion through xapp REST test interface
3032 mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId)
3033 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3034 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3035
3036 // Wait that subs is cleaned
3037 waitSubsCleanup(t, e2SubsId, 10)
3038 mainCtrl.VerifyCounterValues(t)
3039 mainCtrl.VerifyAllClean(t)
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03003040}
3041
archaggeafbf95f2021-04-14 08:54:05 +03003042//-----------------------------------------------------------------------------
3043// TestRESTSubReqAndRouteNok
3044//
3045// stub stub
3046// +-------+ +---------+ +---------+
3047// | xapp | | submgr | | rtmgr |
3048// +-------+ +---------+ +---------+
3049// | | |
3050// | RESTSubReq | |
3051// |---------------->| |
3052// | | |
3053// | RESTSubResp | |
3054// |<----------------| |
3055// | | RouteCreate |
3056// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03003057// | | RouteCreate |
3058// | | status:400 |
3059// | |(Bad request) |
3060// | |<-------------|
3061// | RESTNotif | |
3062// |<----------------| |
3063// | | |
3064// | [SUBS INT DELETE] |
3065// | | |
3066// | RESTSubDelReq | |
3067// |---------------->| |
3068// | RESTSubDelResp | |
3069// |<----------------| |
3070//
3071//-----------------------------------------------------------------------------
3072func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003073
3074 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003075 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003076 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003077 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003078 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003079 Counter{cRestSubDelReqFromXapp, 1},
3080 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003081 })
3082
3083 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003084
Markku Virtanenda34eec2021-05-20 08:22:04 +00003085 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
3086 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03003087 newSubsId := mainCtrl.get_registry_next_subid(t)
3088
3089 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003090 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003091 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003092 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03003093 waiter.WaitResult(t)
3094
archaggeafbf95f2021-04-14 08:54:05 +03003095 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003096 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003097
3098 // Del
3099 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3100
3101 // Wait that subs is cleaned
3102 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3103 waitSubsCleanup(t, e2SubsId, 10)
3104 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003105 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003106}
3107
Anssi Mannila27385172021-12-22 09:41:54 +02003108//-----------------------------------------------------------------------------
3109// TestRESTSubReqAndRouteUpdateNok
3110//
3111// stub stub stub stub
3112// +-------+ +-------+ +---------+ +---------+ +---------+
3113// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3114// +-------+ +-------+ +---------+ +---------+ +---------+
3115// | | | | |
3116// | RESTSubReq1 | | |
3117// |------------------------>| | |
3118// | RESTSubResp2 | | |
3119// |<------------------------| | |
3120// | | | | |
3121// | | | RouteCreate | |
3122// | | |------------->| |
3123// | | | CreateResp | |
3124// | | |<-------------| |
3125// | | | SubReq | |
3126// | | |---------------------------->|
3127// | | | SubResp | |
3128// | | |<----------------------------|
3129// | RESTNotif1 | | |
3130// |<------------------------| | |
3131// | | | | |
3132// | | RESTSubReq2 | | |
3133// | |------------>| | |
3134// | | RESTSubResp2| | |
3135// | |<------------| | |
3136// | | | RouteUpdate | |
3137// | | |------------->| |
3138// | | | RouteUpdate | |
3139// | | | status:400 | |
3140// | | |(Bad request) | |
3141// | | |<-------------| |
3142// | | RESTNotif2(unsuccessful) | |
3143// | |<------------| | |
3144// | | | | |
3145// | [SUBS INT DELETE] | |
3146// | | | | |
3147// | RESTSubDelReq1 | | |
3148// |------------------------>| | |
3149// | RESTSubDelResp1 | | |
3150// |<------------------------| | |
3151// | | | | |
3152// | | | [SUBS DELETE] |
3153//
3154//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003155func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003156
3157 //Init counter check
3158 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003159 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003160 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003161 Counter{cSubReqToE2, 1},
3162 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003163 Counter{cRestSubNotifToXapp, 1},
3164 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003165 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003166 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003167 Counter{cSubDelReqToE2, 1},
3168 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003169 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003170 })
3171
3172 var params *teststube2ap.RESTSubsReqParams = nil
3173
Anssi Mannila27385172021-12-22 09:41:54 +02003174 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03003175 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3176
3177 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3178
3179 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
3180 waiter := rtmgrHttp.AllocNextEvent(false)
3181 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003182 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003183 params.SetMeid("RAN_NAME_1")
3184 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003185 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003186 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003187 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003188 xappConn2.WaitRESTNotification(t, restSubId2)
3189
3190 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3191
3192 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003193 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003194
3195 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3196 //Wait that subs is cleaned
3197 waitSubsCleanup(t, e2SubsId, 10)
3198
3199 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003200 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003201}
3202
Anssi Mannila27385172021-12-22 09:41:54 +02003203//-----------------------------------------------------------------------------
3204// TestRESTSubDelReqAndRouteDeleteNok
3205//
3206// stub stub stub
3207// +-------+ +---------+ +---------+ +---------+
3208// | xapp | | submgr | | rtmgr | | e2term |
3209// +-------+ +---------+ +---------+ +---------+
3210// | | | |
3211// | RESTSubReq | | |
3212// |---------------->| | |
3213// | | | |
3214// | RESTSubResp | | |
3215// |<----------------| | |
3216// | | SubReq | |
3217// | |---------------------------->|
3218// | | SubResp | |
3219// | |<----------------------------|
3220// | RESTNotif | | |
3221// |<----------------| | |
3222// | | | |
3223// | | | |
3224// | RESTSubDelReq | | |
3225// |---------------->| | |
3226// | RESTSubDelResp | | |
3227// |<----------------| | |
3228// | | SubSelReq | |
3229// | |---------------------------->|
3230// | | SubSelResp | |
3231// | |<----------------------------|
3232// | | RouteDelete | |
3233// | |------------->| |
3234// | | Routedelete | |
3235// | | status:400 | |
3236// | |(Bad request) | |
3237// | |<-------------| |
3238//
3239//-----------------------------------------------------------------------------
3240
archaggeafbf95f2021-04-14 08:54:05 +03003241func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003242
3243 // Init counter check
3244 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003245 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003246 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003247 Counter{cSubReqToE2, 1},
3248 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003249 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003250 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003251 Counter{cRouteDeleteFail, 1},
3252 Counter{cSubDelReqToE2, 1},
3253 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003254 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003255 })
3256
3257 var params *teststube2ap.RESTSubsReqParams = nil
3258
3259 //Subs Create
3260 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3261
3262 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3263
3264 waiter := rtmgrHttp.AllocNextEvent(false)
3265 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3266 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3267 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3268 waiter.WaitResult(t)
3269
3270 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003271 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003272 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003273}
3274
Anssi Mannila27385172021-12-22 09:41:54 +02003275//-----------------------------------------------------------------------------
3276// TestRESTSubMergeDelAndRouteUpdateNok
3277//
3278// stub stub stub stub
3279// +-------+ +-------+ +---------+ +---------+ +---------+
3280// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3281// +-------+ +-------+ +---------+ +---------+ +---------+
3282// | | | | |
3283// | RESTSubReq1 | | |
3284// |------------------------>| | |
3285// | RESTSubResp2 | | |
3286// |<------------------------| | |
3287// | | | | |
3288// | | | RouteCreate | |
3289// | | |------------->| |
3290// | | | CreateResp | |
3291// | | |<-------------| |
3292// | | | SubReq | |
3293// | | |---------------------------->|
3294// | | | SubResp | |
3295// | | |<----------------------------|
3296// | RESTNotif1 | | |
3297// |<------------------------| | |
3298// | | | | |
3299// | | RESTSubReq2 | | |
3300// | |------------>| | |
3301// | | RESTSubResp2| | |
3302// | |<------------| | |
3303// | | | RouteCreate | |
3304// | | |------------->| |
3305// | | | CreateResp | |
3306// | | |<-------------| |
3307// | | | SubReq | |
3308// | | |---------------------------->|
3309// | | | SubResp | |
3310// | | |<----------------------------|
3311// | | RESTNotif2 | | |
3312// | |<------------| | |
3313// | | | | |
3314// | [SUBS INT DELETE] | |
3315// | | | | |
3316// | RESTSubDelReq1 | | |
3317// |------------------------>| | |
3318// | RESTSubDelResp1 | | |
3319// |<------------------------| | |
3320// | | | SubDelReq | |
3321// | | |---------------------------->|
3322// | | | SubDelResp | |
3323// | | |<----------------------------|
3324// | | | RouteUpdate | |
3325// | | |------------->| |
3326// | | | RouteUpdate | |
3327// | | | status:400 | |
3328// | | |(Bad request) | |
3329// | | |<-------------| |
3330// | | | | |
3331// | | RESTSubDelReq2 | |
3332// | |------------>| | |
3333// | | RESTSubDelResp2 | |
3334// | |<------------| | |
3335// | | | SubDelReq | |
3336// | | |---------------------------->|
3337// | | | SubdelResp | |
3338// | | |<----------------------------|
3339// | | | RouteDelete | |
3340// | | |------------->| |
3341// | | | Deleteresp | |
3342// | | |<-------------| |
3343
3344//-----------------------------------------------------------------------------
3345
archaggeafbf95f2021-04-14 08:54:05 +03003346func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003347
3348 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003349 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003350 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003351 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003352 Counter{cSubReqToE2, 1},
3353 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003354 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003355 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003356 Counter{cRouteDeleteUpdateFail, 1},
3357 Counter{cSubDelReqToE2, 1},
3358 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003359 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003360 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003361 })
3362
3363 var params *teststube2ap.RESTSubsReqParams = nil
3364
3365 //Subs Create
3366 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3367
3368 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3369 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
3370
3371 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3372
3373 //Del1, this shall fail on rtmgr side
3374 waiter := rtmgrHttp.AllocNextEvent(false)
3375 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3376 waiter.WaitResult(t)
3377
3378 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
3379
3380 //Del2
3381 deleteXapp2Subscription(t, &restSubId2)
3382
3383 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003384 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003385 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003386}
3387
3388//-----------------------------------------------------------------------------
3389// TestRESTSubReqRetransmission
3390//
3391// stub stub
3392// +-------+ +---------+ +---------+
3393// | xapp | | submgr | | e2term |
3394// +-------+ +---------+ +---------+
3395// | | |
3396// | RESTSubReq1 | |
3397// |---------------->| |
3398// | | |
3399// | RESTSubResp | |
3400// |<----------------| |
3401// | | SubReq1 |
3402// | |------------->|
3403// | | |
3404// | RESTSubReq2 | |
3405// | (retrans) | |
3406// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003407// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003408// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003409// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003410// | | SubResp1 |
3411// | |<-------------|
3412// | RESTNotif1 | |
3413// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003414// | | |
3415// | [SUBS DELETE] |
3416// | | |
3417//
3418//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003419
archaggeafbf95f2021-04-14 08:54:05 +03003420func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003421
3422 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003423 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003424 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003425 Counter{cSubReqToE2, 1},
3426 Counter{cSubRespFromE2, 1},
3427 Counter{cRestSubNotifToXapp, 1},
3428 Counter{cRestSubDelReqFromXapp, 1},
3429 Counter{cSubDelReqToE2, 1},
3430 Counter{cSubDelRespFromE2, 1},
3431 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003432 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003433 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003434 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3435 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3436
3437 // Subs Create
3438 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003439
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003440 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003441 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003442
Anssi Mannilab43397e2021-11-16 12:06:16 +02003443 xappConn1.SendRESTSubsReq(t, params)
3444 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003445
Anssi Mannilab43397e2021-11-16 12:06:16 +02003446 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003447
3448 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003449 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003450 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3451 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003452
Anssi Mannilab43397e2021-11-16 12:06:16 +02003453 e2SubsId := <-xappConn1.ListedRESTNotifications
3454
3455 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003456
3457 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003458 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003459 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3460 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3461
Anssi Mannilab43397e2021-11-16 12:06:16 +02003462 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003463
3464 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003465 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003466}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003467
Markku Virtanen42723e22021-06-15 10:09:23 +03003468//-----------------------------------------------------------------------------
3469// stub stub stub
3470// +-------+ +---------+ +---------+ +---------+
3471// | xapp | | submgr | | e2term | | rtmgr |
3472// +-------+ +---------+ +---------+ +---------+
3473// | | | |
3474// | RESTSubReq | | |
3475// |---------------->| | |
3476// | RESTSubResp | | |
3477// |<----------------| | |
3478// | | RouteCreate | |
3479// | |--------------------------->|
3480// | | RouteResponse| |
3481// | |<---------------------------| // The order of these events may vary
3482// | | SubReq | |
3483// | |------------->| | // The order of these events may vary
3484// | | SubResp | |
3485// | |<-------------| |
3486// | RESTNotif1 | | |
3487// |<----------------| | |
3488// | RESTSubReq | | |
3489// | [RETRANS1] | | |
3490// |---------------->| | |
3491// | RESTNotif1 | | |
3492// |<----------------| | |
3493// | RESTSubReq | | |
3494// | [RETRANS2] | | |
3495// |---------------->| | |
3496// | RESTNotif1 | | |
3497// |<----------------| | |
3498// | RESTSubDelReq | | |
3499// |---------------->| | |
3500// | | SubDelReq | |
3501// | |------------->| |
3502// | RESTSubDelResp| | |
3503// |<----------------| | |
3504// | | SubDelResp | |
3505// | |<-------------| |
3506// | | | |
3507//
3508//-----------------------------------------------------------------------------
3509
3510func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003511
3512 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3513 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003514 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003515 Counter{cRestSubRespToXapp, 3},
3516 Counter{cSubReqToE2, 1},
3517 Counter{cSubRespFromE2, 1},
3518 Counter{cRestSubNotifToXapp, 3},
3519 Counter{cRestSubDelReqFromXapp, 1},
3520 Counter{cSubDelReqToE2, 1},
3521 Counter{cSubDelRespFromE2, 1},
3522 Counter{cRestSubDelRespToXapp, 1},
3523 })
3524
3525 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3526
3527 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3528
3529 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3530
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003531 mainCtrl.WaitOngoingRequestMapEmpty()
3532
Markku Virtanen42723e22021-06-15 10:09:23 +03003533 //1.st resend
3534 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3535
3536 assert.Equal(t, restSubId_resend, restSubId)
3537
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003538 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003539
3540 //2.nd resend
3541 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3542
3543 assert.Equal(t, restSubId_resend2, restSubId)
3544
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003545 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003546
3547 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3548
3549 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003550 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003551 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003552}
3553
3554//-----------------------------------------------------------------------------
3555// stub stub stub
3556// +-------+ +---------+ +---------+ +---------+
3557// | xapp | | submgr | | e2term | | rtmgr |
3558// +-------+ +---------+ +---------+ +---------+
3559// | | | |
3560// | RESTSubReq | | |
3561// |---------------->| | |
3562// | RESTSubResp | | |
3563// |<----------------| | |
3564// | | RouteCreate | |
3565// | |--------------------------->|
3566// | | RouteResponse| |
3567// | |<---------------------------| // The order of these events may vary
3568// | | SubReq | |
3569// | |------------->| | // The order of these events may vary
3570// | | SubResp | |
3571// | |<-------------| |
3572// | RESTNotif1 | | |
3573// |<----------------| | |
3574// | RESTSubReq | | |
3575// | [RETRANS, with RESTsubsId] | |
3576// |---------------->| | |
3577// | RESTNotif1 | | |
3578// |<----------------| | |
3579// | RESTSubReq | | |
3580// | [RETRANS, without RESTsubsId] | |
3581// |---------------->| | |
3582// | RESTNotif1 | | |
3583// |<----------------| | |
3584// | RESTSubDelReq | | |
3585// |---------------->| | |
3586// | | SubDelReq | |
3587// | |------------->| |
3588// | RESTSubDelResp| | |
3589// |<----------------| | |
3590// | | SubDelResp | |
3591// | |<-------------| |
3592// | | | |
3593//
3594//-----------------------------------------------------------------------------
3595func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003596
3597 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3598 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003599 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003600 Counter{cRestSubRespToXapp, 3},
3601 Counter{cSubReqToE2, 1},
3602 Counter{cSubRespFromE2, 1},
3603 Counter{cRestSubNotifToXapp, 3},
3604 Counter{cRestSubDelReqFromXapp, 1},
3605 Counter{cSubDelReqToE2, 1},
3606 Counter{cSubDelRespFromE2, 1},
3607 Counter{cRestSubDelRespToXapp, 1},
3608 })
3609
3610 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3611
3612 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3613
3614 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3615
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003616 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003617
3618 //1.st resend with subscription ID
3619 params.SetSubscriptionID(&restSubId)
3620 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3621
3622 assert.Equal(t, restSubId_resend, restSubId)
3623
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003624 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003625
3626 //2.nd resend without subscription ID (faking app restart)
3627 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3628 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3629
3630 assert.Equal(t, restSubId_resend2, restSubId)
3631
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003632 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003633
3634 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3635
3636 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003637 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003638 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003639}
3640
3641//-----------------------------------------------------------------------------
3642// stub stub stub
3643// +-------+ +---------+ +---------+ +---------+
3644// | xapp | | submgr | | e2term | | rtmgr |
3645// +-------+ +---------+ +---------+ +---------+
3646// | | | |
3647// | RESTSubReq | | |
3648// |---------------->| | |
3649// | RESTSubResp | | |
3650// |<----------------| | |
3651// | | RouteCreate | |
3652// | |--------------------------->|
3653// | | RouteResponse| |
3654// | |<---------------------------|
3655// | | SubReq | |
3656// | |------------->| |
3657// | | SubResp | |
3658// | |<-------------| |
3659// | RESTNotif1 | | |
3660// |<----------------| | |
3661// | RESTSubReq | | |
3662// | [with RestSUbsId + one additional e2 subDetail]
3663// |---------------->| | |
3664// | RESTNotif1 | | |
3665// | [for initial e2 subDetail] | |
3666// |<----------------| | |
3667// | | RouteCreate | |
3668// | |--------------------------->|
3669// | | RouteResponse| |
3670// | |<---------------------------|
3671// | | SubReq | |
3672// | |------------->| |
3673// | | SubResp | |
3674// | |<-------------| |
3675// | RESTNotif1 | | |
3676// |<----------------| | |
3677// | RESTSubReq | | |
3678// | [with RESTsubsId initial request] |
3679// |---------------->| | |
3680// | RESTNotif1 | | |
3681// |<----------------| | |
3682// | RESTSubDelReq | | |
3683// |---------------->| | |
3684// | RESTSubDelResp| | |
3685// |<----------------| | |
3686// | | SubDelReq | |
3687// | |------------->| |
3688// | | SubDelResp | |
3689// | |<-------------| |
3690// | | SubDelReq | |
3691// | |------------->| |
3692// | | SubDelResp | |
3693// | |<-------------| |
3694// | | | |
3695//
3696//-----------------------------------------------------------------------------
3697
3698func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003699
3700 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3701 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003702 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003703 Counter{cRestSubRespToXapp, 3},
3704 Counter{cSubReqToE2, 2},
3705 Counter{cSubRespFromE2, 2},
3706 Counter{cRestSubNotifToXapp, 4},
3707 Counter{cRestSubDelReqFromXapp, 1},
3708 Counter{cSubDelReqToE2, 2},
3709 Counter{cSubDelRespFromE2, 2},
3710 Counter{cRestSubDelRespToXapp, 1},
3711 })
3712
3713 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3714
3715 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3716
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003717 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003718
3719 // Send modified requst, this time with e2 subscriptions.
3720 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3721 params2.SetSubscriptionID(&restSubId)
3722
3723 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003724 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003725 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3726 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003727 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3728 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003729
3730 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3731
Markku Virtanen2b512b62021-07-30 12:04:00 +00003732 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003733 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3734 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3735 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3736 assert.NotEqual(t, e2SubsId2, 0)
3737
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003738 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003739
3740 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3741 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3742 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003743 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003744 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3745 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3746 assert.Equal(t, restSubId_resend, restSubId_resend2)
3747
Markku Virtanen2b512b62021-07-30 12:04:00 +00003748 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3749 assert.Equal(t, e2SubsId, e2SubsId1)
3750
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003751 mainCtrl.WaitOngoingRequestMapEmpty()
3752
Markku Virtanen42723e22021-06-15 10:09:23 +03003753 // Delete both e2 subscriptions
3754 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3755 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3756 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3757
3758 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003759 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003760 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003761}
3762
3763//-----------------------------------------------------------------------------
3764// stub stub stub
3765// +-------+ +---------+ +---------+ +---------+
3766// | xapp | | submgr | | e2term | | rtmgr |
3767// +-------+ +---------+ +---------+ +---------+
3768// | | | |
3769// | RESTSubReq | | |
3770// |---------------->| | |
3771// | RESTSubResp | | |
3772// |<----------------| | |
3773// | | RouteCreate | |
3774// | |--------------------------->|
3775// | | RouteResponse| |
3776// | |<---------------------------|
3777// | | SubReq | |
3778// | |------------->| |
3779// | | SubResp | |
3780// | |<-------------| |
3781// | RESTNotif1 | | |
3782// |<----------------| | |
3783// | RESTSubReq | | |
3784// | [with RestSUbsId + one additional e2 subDetail]
3785// |---------------->| | |
3786// | RESTNotif1 | | |
3787// | [for initial e2 subDetail] | |
3788// |<----------------| | |
3789// | | RouteCreate | |
3790// | |--------------------------->|
3791// | | RouteResponse| |
3792// | |<---------------------------|
3793// | | SubReq | |
3794// | |------------->| |
3795// | | SubResp | |
3796// | |<-------------| |
3797// | RESTNotif1 | | |
3798// |<----------------| | |
3799// | RESTSubReq | | |
3800// | [without RESTsubsId initial request] |
3801// |---------------->| | |
3802// | RESTNotif1 | | |
3803// |<----------------| | |
3804// | RESTSubDelReq | | |
3805// |---------------->| | |
3806// | RESTSubDelResp| | |
3807// |<----------------| | |
3808// | | SubDelReq | |
3809// | |------------->| |
3810// | | SubDelResp | |
3811// | |<-------------| |
3812// | | SubDelReq | |
3813// | |------------->| |
3814// | | SubDelResp | |
3815// | |<-------------| |
3816// | | | |
3817//
3818//-----------------------------------------------------------------------------
3819
3820func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003821
3822 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3823 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003824 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003825 Counter{cRestSubRespToXapp, 3},
3826 Counter{cSubReqToE2, 2},
3827 Counter{cSubRespFromE2, 2},
3828 Counter{cRestSubNotifToXapp, 4},
3829 Counter{cRestSubDelReqFromXapp, 1},
3830 Counter{cSubDelReqToE2, 2},
3831 Counter{cSubDelRespFromE2, 2},
3832 Counter{cRestSubDelRespToXapp, 1},
3833 })
3834
3835 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3836
3837 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3838
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003839 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003840
Anssi Mannila21782182021-12-10 10:56:02 +02003841 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003842 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3843 params2.SetSubscriptionID(&restSubId)
3844
3845 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003846 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003847 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3848 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3849
Markku Virtanen2b512b62021-07-30 12:04:00 +00003850 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3851 assert.Equal(t, e2SubsId, e2SubsId1)
3852 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3853 xappConn1.DecrementRequestCount()
3854
Markku Virtanen42723e22021-06-15 10:09:23 +03003855 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3856
3857 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3858 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3859 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3860 assert.NotEqual(t, e2SubsId2, 0)
3861
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003862 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003863
3864 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3865 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003866 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003867 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3868 // md5sum shall find the original request
3869 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3870 assert.Equal(t, restSubId_resend, restSubId_resend2)
3871
Markku Virtanen2b512b62021-07-30 12:04:00 +00003872 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3873 assert.Equal(t, e2SubsId, e2SubsId1)
3874
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003875 mainCtrl.WaitOngoingRequestMapEmpty()
3876
Markku Virtanen42723e22021-06-15 10:09:23 +03003877 // Delete both e2 subscriptions
3878 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3879 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3880 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3881
3882 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003883 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003884 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003885}
3886
3887//-----------------------------------------------------------------------------
3888// stub stub stub
3889// +-------+ +---------+ +---------+ +---------+
3890// | xapp | | submgr | | e2term | | rtmgr |
3891// +-------+ +---------+ +---------+ +---------+
3892// | | | |
3893// | RESTSubReq | | |
3894// |---------------->| | |
3895// | RESTSubResp | | |
3896// |<----------------| | |
3897// | | RouteCreate | |
3898// | |--------------------------->|
3899// | | RouteResponse| |
3900// | |<---------------------------|
3901// | | SubReq | |
3902// | |------------->| |
3903// | | SubResp | |
3904// | |<-------------| |
3905// | RESTNotif1 | | |
3906// |<----------------| | |
3907// | RESTSubReq | | |
3908// | [with RestSUbsId + one additional e2 subDetail]
3909// |---------------->| | |
3910// | RESTNotif1 | | |
3911// | [for initial e2 subDetail] | |
3912// |<----------------| | |
3913// | | RouteCreate | |
3914// | |--------------------------->|
3915// | | RouteResponse| |
3916// | |<---------------------------|
3917// | | SubReq | |
3918// | |------------->| |
3919// | | SubResp | |
3920// | |<-------------| |
3921// | RESTNotif1 | | |
3922// |<----------------| | |
3923// | RESTSubDelReq | | |
3924// |---------------->| | |
3925// | RESTSubDelResp| | |
3926// |<----------------| | |
3927// | | SubDelReq | |
3928// | |------------->| |
3929// | | SubDelResp | |
3930// | |<-------------| |
3931// | | SubDelReq | |
3932// | |------------->| |
3933// | | SubDelResp | |
3934// | |<-------------| |
3935// | RESTSubReq | | |
3936// | [with RESTsubsId initial request] |
3937// |---------------->| | |
3938// | RESTSubResp | | |
3939// |<----------------| | |
3940// | | RouteCreate | |
3941// | |--------------------------->|
3942// | | RouteResponse| |
3943// | |<---------------------------|
3944// | | SubReq | |
3945// | |------------->| |
3946// | | SubResp | |
3947// | |<-------------| |
3948// | RESTNotif1 | | |
3949// |<----------------| | |
3950// | | | |
3951//
3952//-----------------------------------------------------------------------------
3953func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003954
3955 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3956 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003957 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003958 Counter{cRestSubRespToXapp, 3},
3959 Counter{cSubReqToE2, 3},
3960 Counter{cSubRespFromE2, 3},
3961 Counter{cRestSubNotifToXapp, 4},
3962 Counter{cRestSubDelReqFromXapp, 2},
3963 Counter{cSubDelReqToE2, 3},
3964 Counter{cSubDelRespFromE2, 3},
3965 Counter{cRestSubDelRespToXapp, 2},
3966 })
3967
3968 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3969
3970 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3971
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003972 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003973
3974 // Send modified requst, this time with e2 subscriptions.
3975 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3976 params2.SetSubscriptionID(&restSubId)
3977
3978 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003979 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003980 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3981 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3982
Markku Virtanen2b512b62021-07-30 12:04:00 +00003983 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3984 assert.Equal(t, e2SubsId, e2SubsId1)
3985
Markku Virtanen42723e22021-06-15 10:09:23 +03003986 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3987
3988 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3989 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3990 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3991 assert.NotEqual(t, e2SubsId2, 0)
3992
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003993 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003994
3995 // Delete both e2 subscriptions
3996 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3997 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3998 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3999
4000 waitSubsCleanup(t, e2SubsId, 10)
4001
4002 // Resend the original request, we shall find it's previous md5sum/restsubs
4003 // but the restsubscription has been already removed. This shall trigger a
4004 // fresh create.
4005 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4006
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02004007 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03004008
4009 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4010
4011 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03004012 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004013 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03004014}
4015
Anssi Mannila27385172021-12-22 09:41:54 +02004016//-----------------------------------------------------------------------------
4017// TestRESTSubDelReqRetransmission
4018//
4019// stub stub
4020// +-------+ +---------+ +---------+
4021// | xapp | | submgr | | e2term |
4022// +-------+ +---------+ +---------+
4023// | | |
4024// | RESTSubReq | |
4025// |---------------->| |
4026// | | |
4027// | RESTSubResp | |
4028// |<----------------| |
4029// | | SubReq |
4030// | |------------->|
4031// | | SubResp |
4032// | |<-------------|
4033// | RESTNotif1 | |
4034// |<----------------| |
4035// | | |
4036// | RESTSubDelReq | |
4037// |---------------->| |
4038// | RESTSubDelResp | |
4039// |<----------------| |
4040// | | SubDelReq |
4041// | |------------->|
4042// | RESTSubDelReq | |
4043// |---------------->| |
4044// | RESTSubDelResp | |
4045// |<----------------| |
4046// | | SubDelResp |
4047// | |<-------------|
4048// | | |
4049//
4050//-----------------------------------------------------------------------------
4051
archaggeafbf95f2021-04-14 08:54:05 +03004052func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004053
4054 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004055 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004056 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004057 Counter{cSubReqToE2, 1},
4058 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004059 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004060 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004061 Counter{cSubDelReqToE2, 1},
4062 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004063 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004064 })
4065
4066 var params *teststube2ap.RESTSubsReqParams = nil
4067
4068 //Subs Create
4069 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4070
4071 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4072
4073 //Subs Delete
4074 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4075 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4076
Anssi Mannila27385172021-12-22 09:41:54 +02004077 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03004078 seqBef := mainCtrl.get_msgcounter(t)
4079 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4080 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
4081
Anssi Mannila27385172021-12-22 09:41:54 +02004082 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03004083 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4084
4085 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004086 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004087 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004088}
4089
4090//-----------------------------------------------------------------------------
4091// TestRESTSubReqDelReq
4092//
4093// stub stub
4094// +-------+ +---------+ +---------+
4095// | xapp | | submgr | | e2term |
4096// +-------+ +---------+ +---------+
4097// | | |
4098// | RESTSubReq | |
4099// |---------------->| |
4100// | | |
4101// | RESTSubResp | |
4102// |<----------------| |
4103// | | SubReq |
4104// | |------------->|
4105// | RESTSubDelReq | |
4106// |---------------->| |
4107// | RESTSubDelResp | |
4108// | unsuccess | |
4109// |<----------------| |
4110// | | SubResp |
4111// | |<-------------|
4112// | RESTNotif1 | |
4113// |<----------------| |
4114// | | |
4115// | [SUBS DELETE] |
4116// | | |
4117//
4118//-----------------------------------------------------------------------------
4119func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004120
4121 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004122 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004123 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004124 Counter{cSubReqToE2, 1},
4125 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004126 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004127 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004128 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004129 Counter{cSubDelReqToE2, 1},
4130 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004131 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004132 })
4133
4134 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004135
4136 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004137 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004138 restSubId := xappConn1.SendRESTSubsReq(t, params)
4139
4140 // Del. This will fail as processing of the subscription
4141 // is still ongoing in submgr. Deletion is not allowed before
4142 // subscription creation has been completed.
4143 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4144 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4145 xappConn1.ExpectRESTNotification(t, restSubId)
4146 e2termConn1.SendSubsResp(t, crereq, cremsg)
4147 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4148
4149 // Retry del
4150 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4151
4152 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4153 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4154
4155 // Wait that subs is cleaned
4156 waitSubsCleanup(t, e2SubsId, 10)
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// TestRESTSubReqAndSubDelOkTwoParallel
4163//
4164// stub stub stub
4165// +-------+ +-------+ +---------+ +---------+
4166// | xapp2 | | xapp1 | | submgr | | e2term |
4167// +-------+ +-------+ +---------+ +---------+
4168// | | | |
4169// | | RESTSubReq1 | |
4170// | |------------->| |
4171// | | RESTSubResp1 | |
4172// | |<-------------| |
4173// | | | |
4174// | | | SubReq1 |
4175// | | |------------->|
4176// | | | |
4177// | RESTSubReq2 | |
4178// |------------------------>| |
4179// | RESTSubResp2 | |
4180// |<------------------------| |
4181// | | | |
4182// | | | SubReq2 |
4183// | | |------------->|
4184// | | | |
4185// | | | SubResp1 |
4186// | | |<-------------|
4187// | | RESTNotif1 | |
4188// | |<-------------| |
4189// | | | |
4190// | | | SubResp2 |
4191// | | |<-------------|
4192// | RESTNotif2 | |
4193// |<------------------------| |
4194// | | | |
4195// | | [SUBS 1 DELETE] |
4196// | | | |
4197// | | [SUBS 2 DELETE] |
4198// | | | |
4199//
4200//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004201
4202func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004203
4204 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004205 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004206 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004207 Counter{cSubReqToE2, 2},
4208 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004209 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004210 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004211 Counter{cSubDelReqToE2, 2},
4212 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004213 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004214 })
4215
4216 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004217 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004218 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004219 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004220
4221 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004222 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004223 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004224 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004225
4226 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4227 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4228
4229 //XappConn1 receives both of the responses
4230 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4231
4232 //Resp1
4233 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4234 //Resp2
4235 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4236
4237 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004238 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004239 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004240 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004241
4242 //Del1
4243 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4244 //Del2
4245 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
4246
4247 //Wait that subs is cleaned
4248 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
4249 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4250
4251 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004252 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004253}
4254
Anssi Mannila27385172021-12-22 09:41:54 +02004255//-----------------------------------------------------------------------------
4256// TestRESTSameSubsDiffRan
4257// Same subscription to different RANs
4258//
4259// stub stub
4260// +-------+ +---------+ +---------+
4261// | xapp | | submgr | | e2term |
4262// +-------+ +---------+ +---------+
4263// | | |
4264// | RESTSubReq(r1) | |
4265// |---------------->| |
4266// | RESTSubResp(r1) | |
4267// |<----------------| |
4268// | | |
4269// | | SubReq(r1) |
4270// | |------------->|
4271// | | |
4272// | | SubResp(r1) |
4273// | |<-------------|
4274// | | |
4275// | RESTNotif(r1) | |
4276// |<----------------| |
4277// | | |
4278// | RESTSubReq(r2) | |
4279// |---------------->| |
4280// | | |
4281// | RESTSubResp(r2) | |
4282// |<----------------| |
4283// | | SubReq(r2) |
4284// | |------------->|
4285// | | |
4286// | | SubResp(r2) |
4287// | |<-------------|
4288// | | |
4289// | RESTNotif(r2) | |
4290// |<----------------| |
4291// | | |
4292// | [SUBS r1 DELETE] |
4293// | | |
4294// | [SUBS r2 DELETE] |
4295// | | |
4296//
4297//-----------------------------------------------------------------------------
4298
archaggeafbf95f2021-04-14 08:54:05 +03004299func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004300
4301 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004302 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004303 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004304 Counter{cSubReqToE2, 2},
4305 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004306 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004307 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004308 Counter{cSubDelReqToE2, 2},
4309 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004310 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004311 })
4312
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004313 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004314 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004315 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004316
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004317 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004318 params.SetMeid("RAN_NAME_2")
4319 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004320 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004321
4322 //Del1
4323 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4324 //Del2
4325 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
4326
4327 //Wait that subs is cleaned
4328 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4329 waitSubsCleanup(t, e2SubsId2, 10)
4330
4331 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004332 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004333}
4334
Anssi Mannila27385172021-12-22 09:41:54 +02004335//-----------------------------------------------------------------------------
4336// TestRESTSubReqRetryInSubmgr
4337//
4338// stub stub
4339// +-------+ +---------+ +---------+
4340// | xapp | | submgr | | e2term |
4341// +-------+ +---------+ +---------+
4342// | | |
4343// | RESTSubReq | |
4344// |---------------->| |
4345// | RESTSubResp | |
4346// |<----------------| |
4347// | | SubReq |
Anssi Mannila92c38552021-12-29 09:59:24 +02004348// | |------------->|
Anssi Mannila27385172021-12-22 09:41:54 +02004349// | | |
4350// | | |
4351// | | SubReq |
4352// | |------------->|
4353// | | SubResp |
4354// | |<-------------|
4355// | | |
4356// | RESTNotif | |
4357// |<----------------| |
4358// | | |
4359// | [SUBS DELETE] |
4360// | | |
4361//
4362//-----------------------------------------------------------------------------
4363
archaggeafbf95f2021-04-14 08:54:05 +03004364func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004365
4366 // Init counter check
4367 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004368 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004369 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004370 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004371 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004372 Counter{cSubReReqToE2, 1},
4373 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004374 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004375 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004376 Counter{cSubDelReqToE2, 1},
4377 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004378 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004379 })
4380
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004381 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004382 restSubId := xappConn1.SendRESTSubsReq(t, params)
4383
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004384 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004385
4386 // Catch the first message and ignore it
4387 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004388 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004389
4390 // The second request is being handled normally
4391 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4392 xappConn1.ExpectRESTNotification(t, restSubId)
4393 e2termConn1.SendSubsResp(t, crereq, cremsg)
4394 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4395
4396 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4397
Anssi Mannila27385172021-12-22 09:41:54 +02004398 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004399 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4400
4401 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4402 //Wait that subs is cleaned
4403 waitSubsCleanup(t, e2SubsId, 10)
4404
4405 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004406 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004407}
4408
4409//-----------------------------------------------------------------------------
4410// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4411//
4412// stub stub
4413// +-------+ +---------+ +---------+
4414// | xapp | | submgr | | e2term |
4415// +-------+ +---------+ +---------+
4416// | | |
4417// | RESTSubReq | |
4418// |---------------->| |
4419// | | |
4420// | RESTSubResp | |
4421// |<----------------| |
4422// | | SubReq |
4423// | |------------->|
4424// | | |
4425// | | |
4426// | | SubReq |
4427// | |------------->|
4428// | | |
4429// | | SubDelReq |
4430// | |------------->|
4431// | | |
4432// | | |
4433// | | SubDelReq |
4434// | |------------->|
4435// | | |
4436// | | |
4437// | | SubDelResp |
4438// | |<-------------|
4439// | RESTNotif | |
4440// | unsuccess | |
4441// |<----------------| |
4442// | | |
4443// | [SUBS DELETE] |
4444// | | |
4445//
4446//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004447
archaggeafbf95f2021-04-14 08:54:05 +03004448func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004449
4450 // Init counter check
4451 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004452 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004453 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004454 Counter{cSubReqToE2, 1},
4455 Counter{cSubReReqToE2, 1},
4456 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004457 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004458 Counter{cSubDelReqToE2, 1},
4459 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004460 Counter{cRestSubDelReqFromXapp, 1},
4461 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004462 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004463
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004464 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004465 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004466 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004467
4468 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004469 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004470
4471 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004472 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004473
4474 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004475 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004476 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004477 xappConn1.WaitRESTNotification(t, restSubId)
4478
Anssi Mannilab43397e2021-11-16 12:06:16 +02004479 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4480
archaggeafbf95f2021-04-14 08:54:05 +03004481 // Wait that subs is cleaned
4482 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004483 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004484 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004485}
4486
Anssi Mannila27385172021-12-22 09:41:54 +02004487//-----------------------------------------------------------------------------
4488// TestREST2eTermNotRespondingToSubReq
4489//
4490// stub stub
4491// +-------+ +---------+ +---------+
4492// | xapp | | submgr | | e2term |
4493// +-------+ +---------+ +---------+
4494// | | |
4495// | RESTSubReq | |
4496// |---------------->| |
4497// | RESTSubResp | |
4498// |<----------------| |
4499// | | SubReq |
4500// | |------------->|
4501// | | |
4502// | | SubReq |
4503// | |------------->|
4504// | | |
4505// | | SubDelReq |
4506// | |------------->|
4507// | | |
4508// | | SubDelReq |
4509// | |------------->|
4510// | RESTNotif(Unsuccessful) |
4511// |<----------------| |
4512// | | |
4513// | RESTSubDelReq | |
4514// |---------------->| |
4515// | RESTSubDelResp | |
4516// |<----------------| |
4517// | | |
4518//
4519//-----------------------------------------------------------------------------
4520
archaggeafbf95f2021-04-14 08:54:05 +03004521func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004522
4523 // Init counter check
4524 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004525 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004526 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004527 Counter{cSubReqToE2, 1},
4528 Counter{cSubReReqToE2, 1},
4529 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004530 Counter{cSubDelReReqToE2, 1},
4531 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004532 Counter{cSubDelReqToE2, 1},
4533 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004534 Counter{cRestSubDelReqFromXapp, 1},
4535 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004536 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004537
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004538 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004539 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004540 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004541
4542 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004543 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004544
4545 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004546 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004547
4548 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004549 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004550
Markku Virtanen55d2a282021-06-04 14:46:56 +03004551 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004552 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004553 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004554
4555 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4556
Anssi Mannilab43397e2021-11-16 12:06:16 +02004557 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004558
Anssi Mannilab43397e2021-11-16 12:06:16 +02004559 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004560 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004561 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004562}
4563
4564//-----------------------------------------------------------------------------
4565// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4566//
4567// stub stub
4568// +-------+ +---------+ +---------+
4569// | xapp | | submgr | | e2term |
4570// +-------+ +---------+ +---------+
4571// | | |
4572// | RESTSubReq | |
4573// |---------------->| |
4574// | | |
4575// | RESTSubResp | |
4576// |<----------------| |
4577// | | SubReq |
4578// | |------------->|
4579// | | |
4580// | | |
4581// | | SubReq |
4582// | |------------->|
4583// | | |
4584// | | SubDelReq |
4585// | |------------->|
4586// | | |
4587// | | |
4588// | | SubDelReq |
4589// | |------------->|
4590// | | |
4591// | | |
4592// | | SubDelResp |
4593// | |<-------------|
4594// | RESTNotif | |
4595// | unsuccess | |
4596// |<----------------| |
4597// | | |
4598// | [SUBS DELETE] |
4599// | | |
4600//
4601//-----------------------------------------------------------------------------
4602func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004603
4604 // Init counter check
4605 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004606 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004607 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004608 Counter{cSubReqToE2, 1},
4609 Counter{cSubReReqToE2, 1},
4610 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004611 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004612 Counter{cSubDelReqToE2, 1},
4613 Counter{cSubDelReReqToE2, 1},
4614 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004615 Counter{cRestSubDelReqFromXapp, 1},
4616 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004617 })
4618
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004619 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004620 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004621 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004622
4623 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004624 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004625
4626 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004627 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004628
4629 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004630 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004631
Markku Virtanen55d2a282021-06-04 14:46:56 +03004632 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004633 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004634 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004635
4636 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4637
Anssi Mannilab43397e2021-11-16 12:06:16 +02004638 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004639
Anssi Mannilab43397e2021-11-16 12:06:16 +02004640 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004641 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004642 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004643}
4644
4645//-----------------------------------------------------------------------------
4646// TestRESTSubReqSubFailRespInSubmgr
4647//
4648// stub stub
4649// +-------+ +---------+ +---------+
4650// | xapp | | submgr | | e2term |
4651// +-------+ +---------+ +---------+
4652// | | |
4653// | RESTSubReq | |
4654// |---------------->| |
4655// | | |
4656// | RESTSubResp | |
4657// |<----------------| |
4658// | | SubReq |
4659// | |------------->|
4660// | | |
4661// | | SubFail |
4662// | |<-------------|
4663// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004664// | RESTNotif | |
4665// | unsuccess | |
4666// |<----------------| |
4667// | | |
4668// | [SUBS DELETE] |
4669// | | |
4670//
4671//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004672
archaggeafbf95f2021-04-14 08:54:05 +03004673func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004674
4675 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004676 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004677 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004678 Counter{cSubReqToE2, 1},
4679 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004680 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004681 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004682 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004683 })
4684
4685 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004686 const e2Timeout int64 = 2
4687 const e2RetryCount int64 = 1
4688 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004689
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004690 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004691 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004692 restSubId := xappConn1.SendRESTSubsReq(t, params)
4693
4694 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4695 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4696 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004697 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004698 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4699
archaggeafbf95f2021-04-14 08:54:05 +03004700 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004701 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004702
4703 // REST subscription sill there to be deleted
4704 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4705
4706 // Wait that subs is cleaned
4707 waitSubsCleanup(t, e2SubsId, 10)
4708
4709 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004710 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004711}
4712
4713//-----------------------------------------------------------------------------
Anssi Mannila56233b02022-01-24 13:26:42 +02004714// TestRESTSubReqPartialResp
4715//
4716// stub stub
4717// +-------+ +---------+ +---------+
4718// | xapp | | submgr | | e2term |
4719// +-------+ +---------+ +---------+
4720// | | |
4721// | RESTSubReq | |
4722// |---------------->| |
4723// | RESTSubResp | |
4724// |<----------------| |
4725// | | SubReq |
4726// | |------------->|
4727// | | SubResp | Partially accepted
4728// | |<-------------|
4729// | | |
4730// | RESTNotif | |
4731// |<----------------| |
4732// | | |
4733// | [SUBS DELETE] |
4734// | | |
4735//
4736//-----------------------------------------------------------------------------
4737
4738func TestRESTSubReqPartialResp(t *testing.T) {
4739
4740 // Init counter check
4741 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4742 Counter{cRestSubReqFromXapp, 1},
4743 Counter{cRestSubRespToXapp, 1},
4744 Counter{cSubReqToE2, 1},
4745 Counter{cSubRespFromE2, 1},
4746 Counter{cPartialSubRespFromE2, 1},
4747 Counter{cRestSubNotifToXapp, 1},
4748 Counter{cRestSubDelReqFromXapp, 1},
4749 Counter{cSubDelReqToE2, 1},
4750 Counter{cSubDelRespFromE2, 1},
4751 Counter{cRestSubDelRespToXapp, 1},
4752 })
4753
4754 // Req
4755 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
4756
4757 actionId := int64(2)
4758 actionType := "report"
4759 actionDefinition := []int64{5678, 1}
4760 subsequestActionType := "continue"
4761 timeToWait := "w10ms"
4762 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4763
4764 restSubId := xappConn1.SendRESTSubsReq(t, params)
4765 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4766 xappConn1.ExpectRESTNotification(t, restSubId)
4767
4768 actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{}
4769 actionNotAdmittedItem.ActionId = 1
4770 actionNotAdmittedItem.Cause.Content = 1
4771 actionNotAdmittedItem.Cause.Value = 8
4772 actionNotAdmittedList := e2ap.ActionNotAdmittedList{}
4773 actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem)
4774 e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList)
4775 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4776
4777 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4778
4779 // Del
4780 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4781
4782 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4783 //Wait that subs is cleaned
4784 waitSubsCleanup(t, e2SubsId, 10)
4785
4786 mainCtrl.VerifyCounterValues(t)
4787 mainCtrl.VerifyAllClean(t)
4788}
4789
4790//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004791// TestRESTSubDelReqRetryInSubmgr
4792//
4793// stub stub
4794// +-------+ +---------+ +---------+
4795// | xapp | | submgr | | e2term |
4796// +-------+ +---------+ +---------+
4797// | | |
4798// | [SUBS CREATE] |
4799// | | |
4800// | | |
4801// | RESTSubDelReq | |
4802// |---------------->| |
4803// | | |
4804// | RESTSubDelResp | |
4805// |<----------------| |
4806// | | SubDelReq |
4807// | |------------->|
4808// | | |
4809// | | SubDelReq |
4810// | |------------->|
4811// | | |
4812// | | SubDelResp |
4813// | |<-------------|
4814// | | |
4815//
4816//-----------------------------------------------------------------------------
4817func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004818
4819 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004820 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004821 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004822 Counter{cSubReqToE2, 1},
4823 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004824 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004825 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004826 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004827 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004828 Counter{cSubDelReReqToE2, 1},
4829 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004830 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004831 })
4832 // Req
4833 var params *teststube2ap.RESTSubsReqParams = nil
4834 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4835
4836 // Del
4837 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4838
4839 // E2t: Receive 1st SubsDelReq
4840 e2termConn1.RecvSubsDelReq(t)
4841
4842 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4843 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4844 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4845
4846 //Wait that subs is cleaned
4847 waitSubsCleanup(t, e2SubsId, 10)
4848
4849 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004850 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004851}
4852
4853//-----------------------------------------------------------------------------
4854// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4855//
4856// stub stub
4857// +-------+ +---------+ +---------+
4858// | xapp | | submgr | | e2term |
4859// +-------+ +---------+ +---------+
4860// | | |
4861// | [SUBS CREATE] |
4862// | | |
4863// | | |
4864// | RESTSubDelReq | |
4865// |---------------->| |
4866// | | |
4867// | RESTSubDelResp | |
4868// |<----------------| |
4869// | | SubDelReq |
4870// | |------------->|
4871// | | |
4872// | | SubDelReq |
4873// | |------------->|
4874// | | |
4875// | | |
4876//
4877//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004878
archaggeafbf95f2021-04-14 08:54:05 +03004879func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004880
4881 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004882 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004883 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004884 Counter{cSubReqToE2, 1},
4885 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004886 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004887 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004888 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004889 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004890 Counter{cSubDelReReqToE2, 1},
4891 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004892 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004893 })
4894
4895 // Req
4896 var params *teststube2ap.RESTSubsReqParams = nil
4897 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4898
4899 // Del
4900 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4901
4902 // E2t: Receive 1st SubsDelReq
4903 e2termConn1.RecvSubsDelReq(t)
4904
4905 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4906 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4907 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4908
4909 //Wait that subs is cleaned
4910 waitSubsCleanup(t, e2SubsId, 10)
4911
4912 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004913 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004914}
4915
4916//-----------------------------------------------------------------------------
4917// TestRESTSubDelReqSubDelFailRespInSubmgr
4918//
4919// stub stub
4920// +-------+ +---------+ +---------+
4921// | xapp | | submgr | | e2term |
4922// +-------+ +---------+ +---------+
4923// | | |
4924// | [SUBS CREATE] |
4925// | | |
4926// | | |
4927// | RESTSubDelReq | |
4928// |---------------->| |
4929// | | |
4930// | RESTSubDelResp | |
4931// |<----------------| |
4932// | | SubDelReq |
4933// | |------------->|
4934// | | |
4935// | | SubDelFail |
4936// | |<-------------|
4937// | | |
4938//
4939//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004940
archaggeafbf95f2021-04-14 08:54:05 +03004941func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004942
4943 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004944 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004945 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004946 Counter{cSubReqToE2, 1},
4947 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004948 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004949 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004950 Counter{cSubDelReqToE2, 1},
4951 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004952 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004953 })
4954
4955 // Req
4956 var params *teststube2ap.RESTSubsReqParams = nil
4957 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4958
4959 // Del
4960 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4961
4962 // E2t: Send receive SubsDelReq and send SubsDelFail
4963 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4964 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4965
4966 //Wait that subs is cleaned
4967 waitSubsCleanup(t, e2SubsId, 10)
4968
4969 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004970 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004971}
4972
4973//-----------------------------------------------------------------------------
4974// TestRESTSubReqAndSubDelOkSameAction
4975//
4976// stub stub
4977// +-------+ +-------+ +---------+ +---------+
4978// | xapp2 | | xapp1 | | submgr | | e2term |
4979// +-------+ +-------+ +---------+ +---------+
4980// | | | |
4981// | | RESTSubReq1 | |
4982// | |---------------->| |
4983// | | | |
4984// | | RESTSubResp1 | |
4985// | |<----------------| |
4986// | | | |
4987// | | | SubReq1 |
4988// | | |------------->|
4989// | | | SubResp1 |
4990// | | |<-------------|
4991// | | RESTNotif1 | |
4992// | |<----------------| |
4993// | | | |
4994// | RESTSubReq2 | |
4995// |------------------------------>| |
4996// | | | |
4997// | RESTSubResp2 | |
4998// |<------------------------------| |
4999// | | | |
5000// | | RESTNotif2 | |
5001// |<------------------------------| |
5002// | | | |
5003// | | RESTSubDelReq1 | |
5004// | |---------------->| |
5005// | | | |
5006// | | RESTSubDelResp1 | |
5007// | |<----------------| |
5008// | | | |
5009// | RESTSubDelReq2 | |
5010// |------------------------------>| |
5011// | | | |
5012// | RESTSubDelResp2 | |
5013// |<------------------------------| |
5014// | | | |
5015// | | | SubDelReq2 |
5016// | | |------------->|
5017// | | | |
5018// | | | SubDelResp2 |
5019// | | |<-------------|
5020// | | | |
5021//
5022//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005023
archaggeafbf95f2021-04-14 08:54:05 +03005024func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005025
5026 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005027 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005028 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005029 Counter{cSubReqToE2, 1},
5030 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005031 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005032 Counter{cMergedSubscriptions, 1},
5033 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005034 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005035 Counter{cSubDelReqToE2, 1},
5036 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005037 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005038 })
5039
5040 // Req1
5041 var params *teststube2ap.RESTSubsReqParams = nil
5042
5043 //Subs Create
5044 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5045 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5046
5047 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005048 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005049 params.SetMeid("RAN_NAME_1")
5050
5051 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005052 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005053 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03005054 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00005055 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005056 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005057 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005058 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005059
5060 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5061
5062 // Del1
5063 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5064
5065 // Del2
5066 deleteXapp2Subscription(t, &restSubId2)
5067
5068 //Wait that subs is cleaned
5069 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005070 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005071 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005072}
5073
5074//-----------------------------------------------------------------------------
5075// TestSubReqAndSubDelOkSameActionParallel
5076//
5077// stub stub stub
5078// +-------+ +-------+ +---------+ +---------+
5079// | xapp2 | | xapp1 | | submgr | | e2term |
5080// +-------+ +-------+ +---------+ +---------+
5081// | | | |
5082// | | | |
5083// | | | |
5084// | | SubReq1 | |
5085// | |------------->| |
5086// | | | |
5087// | | | SubReq1 |
5088// | | |------------->|
5089// | SubReq2 | |
5090// |--------------------------->| |
5091// | | | SubResp1 |
5092// | | |<-------------|
5093// | | SubResp1 | |
5094// | |<-------------| |
5095// | | | SubReq2 |
5096// | | |------------->|
5097// | | | |
5098// | | | SubResp2 |
5099// | | |<-------------|
5100// | SubResp2 | |
5101// |<---------------------------| |
5102// | | | |
5103// | | SubDelReq 1 | |
5104// | |------------->| |
5105// | | | |
5106// | | SubDelResp 1 | |
5107// | |<-------------| |
5108// | | | |
5109// | SubDelReq 2 | |
5110// |--------------------------->| |
5111// | | | |
5112// | | | SubDelReq 2 |
5113// | | |------------->|
5114// | | | |
5115// | | | SubDelReq 2 |
5116// | | |------------->|
5117// | | | |
5118// | SubDelResp 2 | |
5119// |<---------------------------| |
5120//
5121func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005122
5123 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005124 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005125 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005126 Counter{cSubReqToE2, 2},
5127 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005128 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005129 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005130 Counter{cSubDelReqToE2, 2},
5131 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005132 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005133 })
5134
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005135 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005136 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5137 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5138
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005139 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005140 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5141
5142 xappConn1.ExpectRESTNotification(t, restSubId1)
5143 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5144 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
5145
5146 xappConn2.ExpectRESTNotification(t, restSubId2)
5147 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
5148 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
5149 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5150
5151 // Del1
5152 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5153 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5154 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5155 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5156
5157 // Del2
5158 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5159 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
5160 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
5161
5162 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005163 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005164 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005165}
5166
5167//-----------------------------------------------------------------------------
5168// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
5169//
5170// stub stub stub
5171// +-------+ +-------+ +---------+ +---------+
5172// | xapp2 | | xapp1 | | submgr | | e2term |
5173// +-------+ +-------+ +---------+ +---------+
5174// | | | |
5175// | | | |
5176// | | | |
5177// | | RESTSubReq1 | |
5178// | |---------------->| |
5179// | | | |
5180// | | RESTSubResp1 | |
5181// | |<----------------| |
5182// | | | SubReq1 |
5183// | | |------------->|
5184// | RESTSubReq2 | |
5185// |------------------------------>| |
5186// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005187// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005188// |<------------------------------| |
5189// | | | SubReq1 |
5190// | | |------------->|
5191// | | | |
5192// | | | |
5193// | | | SubDelReq |
5194// | | |------------->|
5195// | | | |
5196// | | | SubDelResp |
5197// | | |<-------------|
5198// | | RESTNotif1 | |
5199// | | unsuccess | |
5200// | |<----------------| |
5201// | RESTNotif2 | |
5202// | | unsuccess | |
5203// |<------------------------------| |
5204// | | | |
5205// | | RESTSubDelReq1 | |
5206// | |---------------->| |
5207// | | | |
5208// | | RESTSubDelResp1 | |
5209// | |<----------------| |
5210// | | | |
5211// | RESTSubDelReq2 | |
5212// |------------------------------>| |
5213// | | | |
5214// | RESTSubDelResp2 | |
5215// |<------------------------------| |
5216//
5217//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005218
archaggeafbf95f2021-04-14 08:54:05 +03005219func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005220
5221 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005222 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005223 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005224 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005225 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005226 Counter{cSubReqTimerExpiry, 2},
5227 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005228 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005229 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005230 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005231 Counter{cSubDelReqToE2, 1},
5232 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005233 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005234 })
archaggeafbf95f2021-04-14 08:54:05 +03005235 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005236
5237 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005238 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005239 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5240 crereq1, _ := e2termConn1.RecvSubsReq(t)
5241
5242 // Req2
5243 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005244 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005245 params2.SetMeid("RAN_NAME_1")
5246 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5247 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5248
5249 //Req1 (retransmitted)
5250 e2termConn1.RecvSubsReq(t)
5251
5252 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005253
5254 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005255 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5256
Markku Virtanenda34eec2021-05-20 08:22:04 +00005257 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005258 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005259 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005260 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005261
5262 // Del1
5263 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5264
5265 // Del2
5266 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5267
Markku Virtanenda34eec2021-05-20 08:22:04 +00005268 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5269
archaggeafbf95f2021-04-14 08:54:05 +03005270 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005271 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005272 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005273 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005274}
5275
5276//-----------------------------------------------------------------------------
5277// TestRESTSubReqAndSubDelNokSameActionParallel
5278//
5279// stub stub stub
5280// +-------+ +-------+ +---------+ +---------+
5281// | xapp2 | | xapp1 | | submgr | | e2term |
5282// +-------+ +-------+ +---------+ +---------+
5283// | | | |
5284// | | | |
5285// | | | |
5286// | | RESTSubReq1 | |
5287// | |---------------->| |
5288// | | | |
5289// | | RESTSubResp1 | |
5290// | |<----------------| |
5291// | | | SubReq1 |
5292// | | |------------->|
5293// | RESTSubReq2 | |
5294// |------------------------------>| |
5295// | | | |
5296// | RESTSubDelResp2 | |
5297// |<------------------------------| |
5298// | | | SubFail1 |
5299// | | |<-------------|
5300// | | | |
5301// | | RESTNotif1 | |
5302// | | unsuccess | |
5303// | |<----------------| |
5304// | RESTNotif2 | |
5305// | | unsuccess | |
5306// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005307// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005308// | | 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 +03005309// | |---------------->| |
5310// | | | |
5311// | | RESTSubDelResp1 | |
5312// | |<----------------| |
5313// | | | |
5314// | RESTSubDelReq2 | |
5315// |------------------------------>| |
5316// | | | |
5317// | RESTSubDelResp2 | |
5318// |<------------------------------| |
5319//
5320//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005321
archaggeafbf95f2021-04-14 08:54:05 +03005322func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005323
5324 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005325 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005326 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005327 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005328 Counter{cSubReqToE2, 1},
5329 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005330 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005331 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005332 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005333 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005334 })
5335
5336 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005337
5338 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005339 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005340 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5341 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5342
5343 // Req2
5344 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005345 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005346 params2.SetMeid("RAN_NAME_1")
5347 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5348 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5349
5350 // E2t: send SubsFail (first)
5351 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5352 fparams1.Set(crereq1)
5353 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5354
archaggeafbf95f2021-04-14 08:54:05 +03005355 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005356 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005357 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005358 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005359 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005360
5361 // Del1
5362 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5363
5364 // Del2
5365 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5366
5367 //Wait that subs is cleaned
5368 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5369 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005370 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005371 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005372}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005373
Anssi Mannila27385172021-12-22 09:41:54 +02005374//-----------------------------------------------------------------------------
5375// TestRESTSubReqPolicyAndSubDelOk
5376//
5377// stub stub
5378// +-------+ +---------+ +---------+
5379// | xapp | | submgr | | e2term |
5380// +-------+ +---------+ +---------+
5381// | | |
5382// | RESTSubReq | |
5383// |--------------->| |
5384// | RESTSubResp | |
5385// |<---------------| |
5386// | | |
5387// | | SubReq |
5388// | |------------->|
5389// | | |
5390// | | SubResp |
5391// | |<-------------|
5392// | | |
5393// | RESTNotif | |
5394// |<---------------| |
5395// | | |
5396// | | |
5397// | RESTSubDelReq | |
5398// |--------------->| |
5399// | RESTSubDelResp | |
5400// |<---------------| |
5401// | | |
5402// | | SubDelReq |
5403// | |------------->|
5404// | | |
5405// | | SubDelResp |
5406// | |<-------------|
5407// | | |
5408//
5409//-----------------------------------------------------------------------------
5410
archaggeafbf95f2021-04-14 08:54:05 +03005411func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005412
5413 // Init counter check
5414 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005415 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005416 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005417 Counter{cSubReqToE2, 1},
5418 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005419 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005420 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005421 Counter{cSubDelReqToE2, 1},
5422 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005423 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005424 })
5425
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005426 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005427 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005428 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005429
5430 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5431 xappConn1.ExpectRESTNotification(t, restSubId)
5432 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5433 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005434 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005435
5436 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5437 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5438 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5439
5440 // Wait that subs is cleaned
5441 waitSubsCleanup(t, e2SubsId, 10)
5442 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005443 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005444}
5445
5446//-----------------------------------------------------------------------------
5447// TestRESTSubReqPolicyChangeAndSubDelOk
5448//
5449// stub stub
5450// +-------+ +---------+ +---------+
5451// | xapp | | submgr | | e2term |
5452// +-------+ +---------+ +---------+
5453// | | |
5454// | RESTSubReq | |
5455// |---------------->| |
5456// | | |
5457// | RESTSubResp | |
5458// |<----------------| |
5459// | | SubReq |
5460// | |------------->|
5461// | | |
5462// | | SubResp |
5463// | |<-------------|
5464// | | |
5465// | RESTNotif | |
5466// |<----------------| |
5467// | | |
5468// | RESTSubReq | |
5469// |---------------->| |
5470// | | |
5471// | RESTSubResp | |
5472// |<----------------| |
5473// | | SubReq |
5474// | |------------->|
5475// | | |
5476// | | SubResp |
5477// | |<-------------|
5478// | | |
5479// | RESTNotif | |
5480// |<----------------| |
5481// | | |
5482// | RESTSubDelReq | |
5483// |---------------->| |
5484// | | |
5485// | | SubDelReq |
5486// | |------------->|
5487// | | |
5488// | | SubDelResp |
5489// | |<-------------|
5490// | | |
5491// | RESTSubDelResp | |
5492// |<----------------| |
5493//
5494//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005495
archaggeafbf95f2021-04-14 08:54:05 +03005496func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005497
5498 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005499 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005500 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005501 Counter{cSubReqToE2, 2},
5502 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005503 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005504 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005505 Counter{cSubDelReqToE2, 1},
5506 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005507 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005508 })
5509
5510 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005511 const e2Timeout int64 = 1
5512 const e2RetryCount int64 = 0
5513 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005514
5515 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005516 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005517 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005518 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5519
5520 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005521 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005522
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005523 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005524 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005525 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005526 params.SetTimeToWait("w200ms")
5527 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5528
5529 // Del
5530 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5531
5532 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5533 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5534
5535 // Wait that subs is cleaned
5536 waitSubsCleanup(t, e2SubsId, 10)
5537 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005538 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005539}
5540
5541//-----------------------------------------------------------------------------
aditverm323c77e2023-09-20 09:50:47 +05305542// TestRESTSubReqPolicyChangeNokAndSubDelOk
5543//
5544// stub stub
5545// +-------+ +---------+ +---------+
5546// | xapp | | submgr | | e2term |
5547// +-------+ +---------+ +---------+
5548// | | |
5549// | RESTSubReq | |
5550// |---------------->| |
5551// | | |
5552// | RESTSubResp | |
5553// |<----------------| |
5554// | | SubReq |
5555// | |------------->|
5556// | | |
5557// | | SubResp |
5558// | |<-------------|
5559// | | |
5560// | RESTNotif | |
5561// |<----------------| |
5562// | | |
5563// | RESTSubReq | |
5564// |---------------->| |
5565// | | |
5566// | RESTSubResp | |
5567// |<----------------| |
5568// | | SubReq |
5569// | |------------->|
5570// | | |
5571// | | SubFail |
5572// | |<-------------|
5573// | | |
5574// | RESTNotif | |
5575// |<----------------| |
5576// | | |
5577// | RESTSubDelReq | |
5578// |---------------->| |
5579// | | |
5580// | | SubDelReq |
5581// | |------------->|
5582// | | |
5583// | | SubDelResp |
5584// | |<-------------|
5585// | | |
5586// | RESTSubDelResp | |
5587// |<----------------| |
5588//
5589//-----------------------------------------------------------------------------
5590
5591func TestRESTSubReqPolicyChangeNokAndSubDelOk(t *testing.T) {
5592
5593 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5594 Counter{cRestSubReqFromXapp, 2},
5595 Counter{cRestSubRespToXapp, 2},
5596 Counter{cSubReqToE2, 2},
5597 Counter{cSubRespFromE2, 1},
5598 Counter{cSubFailFromE2, 1},
5599 Counter{cRestSubNotifToXapp, 1},
5600 Counter{cRestSubFailNotifToXapp, 1},
5601 Counter{cRestSubDelReqFromXapp, 1},
5602 Counter{cSubDelReqToE2, 1},
5603 Counter{cSubDelRespFromE2, 1},
5604 Counter{cRestSubDelRespToXapp, 1},
5605 })
5606
5607 const subReqCount int = 1
5608 const e2Timeout int64 = 1
5609 const e2RetryCount int64 = 0
5610 const routingNeeded bool = false
5611
5612 // Req
5613 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5614 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5615 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5616 fmt.Printf("restSubId: %v", restSubId)
5617
5618 // Policy change
5619 // GetRESTSubsReqPolicyParams sets some counters on tc side.
5620 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5621 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
5622 params.SetSubscriptionID(&restSubId)
5623 params.SetTimeToWait("w200ms")
5624
5625 restSubId = xappConn1.SendRESTSubsReq(t, params)
5626 fmt.Printf("restSubId: %v", restSubId)
5627
5628 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5629 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
5630
5631 // Gnb sends RICSubscriptionFailure
5632 fparams := &teststube2ap.E2StubSubsFailParams{}
5633 fparams.Set(crereq)
5634 fparams.SetCauseVal(0, 1, 5) // CauseRIC / function-resource-limit
5635 e2termConn1.SendSubsFail(t, fparams, cremsg)
5636
5637 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5638 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
5639
5640 // Del
5641 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5642
5643 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5644 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5645
5646 // Wait that subs is cleaned
5647 waitSubsCleanup(t, e2SubsId, 10)
5648 mainCtrl.VerifyCounterValues(t)
5649 mainCtrl.VerifyAllClean(t)
5650}
5651
5652//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005653// TestRESTSubReqPolicyChangeNOk
5654//
5655// stub stub
5656// +-------+ +---------+ +---------+
5657// | xapp | | submgr | | e2term |
5658// +-------+ +---------+ +---------+
5659// | | |
5660// | RESTSubReq | |
5661// |---------------->| |
5662// | | |
5663// | RESTSubResp | |
5664// |<----------------| |
5665// | | SubReq |
5666// | |------------->|
5667// | | |
5668// | | SubResp |
5669// | |<-------------|
5670// | | |
5671// | RESTNotif | |
5672// |<----------------| |
5673// | | |
5674// | RESTSubReq | |
5675// |---------------->| |
5676// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005677// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005678// | | |
5679// | RESTSubDelReq | |
5680// |---------------->| |
5681// | | |
5682// | | SubDelReq |
5683// | |------------->|
5684// | | |
5685// | | SubDelResp |
5686// | |<-------------|
5687// | | |
5688// | RESTSubDelResp | |
5689// |<----------------| |
5690//
5691//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005692
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005693func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005694
5695 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5696 Counter{cRestSubReqFromXapp, 2},
5697 Counter{cRestSubRespToXapp, 1},
5698 Counter{cSubReqToE2, 1},
5699 Counter{cSubRespFromE2, 1},
5700 Counter{cRestSubNotifToXapp, 1},
5701 Counter{cRestSubFailToXapp, 1},
5702 Counter{cRestSubDelReqFromXapp, 1},
5703 Counter{cSubDelReqToE2, 1},
5704 Counter{cSubDelRespFromE2, 1},
5705 Counter{cRestSubDelRespToXapp, 1},
5706 })
5707
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005708 // Req
5709 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5710 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5711
5712 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005713 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5714
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005715 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005716 params.SetSubscriptionID(&restSubIdUpd)
5717 params.SetTimeToWait("w200ms")
5718
5719 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5720 assert.Equal(t, restSubId2, "")
5721
5722 // Del
5723 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5724
5725 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5726 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5727
5728 // Wait that subs is cleaned
5729 waitSubsCleanup(t, e2SubsId, 10)
5730 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005731 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005732}
5733
5734//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005735// TestRESTSubReqAndSubDelOkTwoE2termParallel
5736//
5737// stub stub stub
5738// +-------+ +---------+ +---------+ +---------+
5739// | xapp | | submgr | | e2term1 | | e2term2 |
5740// +-------+ +---------+ +---------+ +---------+
5741// | | | |
5742// | | | |
5743// | | | |
5744// | RESTSubReq1 | | |
5745// |---------------->| | |
5746// | | | |
5747// | RESTSubResp1 | | |
5748// |<----------------| | |
5749// | | SubReq1 | |
5750// | |------------->| |
5751// | | | |
5752// | RESTSubReq2 | | |
5753// |---------------->| | |
5754// | | | |
5755// | RESTSubResp2 | | |
5756// |<----------------| | |
5757// | | SubReq2 | |
5758// | |---------------------------->|
5759// | | | |
5760// | | SubResp1 | |
5761// | |<-------------| |
5762// | RESTNotif1 | | |
5763// |<----------------| | |
5764// | | SubResp2 | |
5765// | |<----------------------------|
5766// | RESTNotif2 | | |
5767// |<----------------| | |
5768// | | | |
5769// | [SUBS 1 DELETE] | |
5770// | | | |
5771// | [SUBS 2 DELETE] | |
5772// | | | |
5773//
5774//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005775
archaggeafbf95f2021-04-14 08:54:05 +03005776func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005777
5778 // Init counter check
5779 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005780 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005781 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005782 Counter{cSubReqToE2, 2},
5783 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005784 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005785 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005786 Counter{cSubDelReqToE2, 2},
5787 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005788 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005789 })
5790
5791 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005792
5793 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005794 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005795 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5796 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5797
5798 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005799 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005800 params.SetMeid("RAN_NAME_11")
5801 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5802 // would not work as notification would not be received
5803 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5804 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5805
5806 // Resp1
5807 xappConn1.ExpectRESTNotification(t, restSubId1)
5808 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5809 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005810 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005811
5812 // Resp2
5813 xappConn2.ExpectRESTNotification(t, restSubId2)
5814 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5815 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005816 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005817
5818 // Delete1
5819 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5820 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5821 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5822
5823 // Wait that subs is cleaned
5824 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5825
5826 // Delete2
5827 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5828 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5829 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5830
5831 // Wait that subs is cleaned
5832 waitSubsCleanup(t, e2SubsId2, 10)
5833
5834 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005835 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005836}
5837
5838//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005839// TestRESTSubReqInsertAndSubDelOk
5840//
5841// stub stub
5842// +-------+ +---------+ +---------+
5843// | xapp | | submgr | | e2term |
5844// +-------+ +---------+ +---------+
5845// | | |
5846// | RestSubReq | |
5847// |---------------->| |
5848// | | |
5849// | RESTSubResp | |
5850// |<----------------| |
5851// | | |
5852// | | SubReq |
5853// | |------------->|
5854// | | |
5855// | | SubResp |
5856// | |<-------------|
5857// | RESTNotif | |
5858// |<----------------| |
5859// | ... | ... |
5860// | | |
5861// | RESTSubDelReq | |
5862// |---------------->| |
5863// | | |
5864// | | SubDelReq |
5865// | |------------->|
5866// | | |
5867// | | SubDelResp |
5868// | |<-------------|
5869// | | |
5870// | RESTSubDelResp| |
5871// |<----------------| |
5872//
5873//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005874
archaggeafbf95f2021-04-14 08:54:05 +03005875func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005876
5877 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005878 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005879 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005880 Counter{cSubReqToE2, 1},
5881 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005882 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005883 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005884 Counter{cSubDelReqToE2, 1},
5885 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005886 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005887 })
5888
5889 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005890
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005891 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005892 params.SetSubActionTypes("insert")
5893
5894 // Req
5895 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5896
5897 // Del
5898 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5899
5900 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5901 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5902
5903 // Wait that subs is cleaned
5904 waitSubsCleanup(t, e2SubsId, 10)
5905 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005906 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005907}
5908
5909//-----------------------------------------------------------------------------
5910// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5911//
5912// stub stub
5913// +-------+ +---------+ +---------+
5914// | xapp | | submgr | | e2term |
5915// +-------+ +---------+ +---------+
5916// | | |
5917// | RESTSubReq | |
5918// |------------->| |
5919// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005920// | RESTSubResp | |
5921// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005922// | | SubReq |
5923// | |------------->|
5924// | | |
5925// | | SubResp |
5926// | <----|
5927// | |
5928// | Submgr restart |
5929// | |
5930// | | |
5931// | | SubDelReq |
5932// | |------------->|
5933// | | |
5934// | | SubDelResp |
5935// | |<-------------|
5936// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005937// | RESTNotif | |
5938// | unsuccess | |
5939// |<-------------| |
5940// | | |
5941// | RESTSubDelReq| |
5942// |------------->| |
5943// | | |
5944// |RESTSubDelResp| |
5945// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005946//
5947//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005948
archaggeafbf95f2021-04-14 08:54:05 +03005949func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005950
5951 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005952 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005953 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005954 Counter{cSubReqToE2, 1},
5955 Counter{cSubDelReqFromXapp, 1},
5956 Counter{cSubDelReqToE2, 1},
5957 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005958 Counter{cRestSubDelReqFromXapp, 1},
5959 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005960 })
5961
5962 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005963
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005964 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005965
5966 //Req
5967 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5968 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005969 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005970
5971 e2termConn1.RecvSubsReq(t)
5972
5973 mainCtrl.SetResetTestFlag(t, false)
5974
5975 mainCtrl.SimulateRestart(t)
5976 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5977
Anssi Mannilab43397e2021-11-16 12:06:16 +02005978 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005979 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5980 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5981
Anssi Mannilab43397e2021-11-16 12:06:16 +02005982 //Del
5983 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5984
archaggeafbf95f2021-04-14 08:54:05 +03005985 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005986 e2termConn1.TestMsgChanEmpty(t)
5987 mainCtrl.wait_registry_empty(t, 10)
5988
5989 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005990 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005991}
5992
5993//-----------------------------------------------------------------------------
5994// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5995//
5996// stub stub
5997// +-------+ +---------+ +---------+
5998// | xapp | | submgr | | e2term |
5999// +-------+ +---------+ +---------+
6000// | | |
6001// | RESTSubReq | |
6002// |---------------->| |
6003// | | |
6004// | RESTSubResp | |
6005// |<----------------| |
6006// | | SubReq |
6007// | |------------->|
6008// | | |
6009// | | SubResp |
6010// | |<-------------|
6011// | | |
6012// | RESTNotif | |
6013// |<----------------| |
6014// | | |
6015// | |
6016// | Submgr restart |
6017// | | |
6018// | RESTSubDelReq | |
6019// |---------------->| |
6020// | | |
6021// | | SubDelReq |
6022// | |------------->|
6023// | | |
6024// | | SubDelResp |
6025// | |<-------------|
6026// | | |
6027// | RESTSubDelResp | |
6028// |<----------------| |
6029//
6030//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006031
archaggeafbf95f2021-04-14 08:54:05 +03006032func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006033
6034 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006035 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006036 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006037 Counter{cSubReqToE2, 1},
6038 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006039 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006040 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006041 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006042 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006043 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006044 })
archaggeafbf95f2021-04-14 08:54:05 +03006045
6046 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02006047 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006048 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006049 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006050
6051 // Check subscription
6052 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6053
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006054 mainCtrl.SimulateRestart(t)
6055 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03006056
Anssi Mannila54838ed2021-11-19 11:25:01 +02006057 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6058 // That needs to be completed before successful subscription query is possible
6059 <-time.After(time.Second * 1)
6060
archaggeafbf95f2021-04-14 08:54:05 +03006061 // Check subscription
6062 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6063
6064 // Delete subscription
6065 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
6066
6067 //Wait that subs is cleaned
6068 waitSubsCleanup(t, e2SubsId, 10)
6069
6070 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006071 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006072}
6073
6074//-----------------------------------------------------------------------------
6075// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
6076//
6077// stub stub
6078// +-------+ +-------+ +---------+ +---------+
6079// | xapp2 | | xapp1 | | submgr | | e2term |
6080// +-------+ +-------+ +---------+ +---------+
6081// | | | |
6082// | | RESTSubReq1 | |
6083// | |---------------->| |
6084// | | | |
6085// | | RESTSubResp1 | |
6086// | |<----------------| |
6087// | | | |
6088// | | | SubReq1 |
6089// | | |------------->|
6090// | | | SubResp1 |
6091// | | |<-------------|
6092// | | RESTNotif1 | |
6093// | |<----------------| |
6094// | | | |
6095// | RESTSubReq2 | |
6096// |------------------------------>| |
6097// | | | |
6098// | RESTSubResp2 | |
6099// |<------------------------------| |
6100// | | | |
6101// | | RESTNotif2 | |
6102// |<------------------------------| |
6103// | | | |
6104// | | Submgr restart |
6105// | | | |
6106// | | RESTSubDelReq1 | |
6107// | |---------------->| |
6108// | | | |
6109// | | RESTSubDelResp1 | |
6110// | |<----------------| |
6111// | | | |
6112// | | Submgr restart |
6113// | | | |
6114// | RESTSubDelReq2 | |
6115// |------------------------------>| |
6116// | | | |
6117// | RESTSubDelResp2 | |
6118// |<------------------------------| |
6119// | | | |
6120// | | | SubDelReq2 |
6121// | | |------------->|
6122// | | | |
6123// | | | SubDelResp2 |
6124// | | |<-------------|
6125// | | | |
6126//
6127//-----------------------------------------------------------------------------
6128func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006129
6130 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006131 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006132 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006133 Counter{cSubReqToE2, 1},
6134 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006135 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006136 Counter{cMergedSubscriptions, 1},
6137 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006138 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006139 Counter{cSubDelReqToE2, 1},
6140 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006141 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03006142 })
6143
archaggeafbf95f2021-04-14 08:54:05 +03006144 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02006145 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03006146 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006147 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03006148
6149 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006150 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006151 params.SetMeid("RAN_NAME_1")
6152 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006153 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03006154 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006155 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00006156 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006157 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03006158
6159 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
6160
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006161 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006162 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
6163
6164 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6165 // That needs to be completed before successful subscription delete is possible
6166 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03006167
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006168 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03006169 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02006170 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006171 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02006172
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006173 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02006174 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
6175
6176 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
6177 // That needs to be completed before successful subscription query is possible
6178 <-time.After(time.Second * 1)
6179
archaggeafbf95f2021-04-14 08:54:05 +03006180 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
6181
6182 // Delete subscription 2
6183 deleteXapp2Subscription(t, &restSubId2)
6184
6185 //Wait that subs is cleaned
6186 waitSubsCleanup(t, e2SubsId2, 10)
6187
6188 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006189 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006190}
6191
6192//-----------------------------------------------------------------------------
6193// TestRESTReportSubReqAndSubDelOk
6194//
6195// stub stub
6196// +-------+ +---------+ +---------+
6197// | xapp | | submgr | | e2term |
6198// +-------+ +---------+ +---------+
6199// | | |
6200// | RestSubReq | |
6201// |---------------->| |
6202// | | |
6203// | RESTSubResp | |
6204// |<----------------| |
6205// | | |
6206// | | SubReq |
6207// | |------------->|
6208// | | |
6209// | | SubResp |
6210// | |<-------------|
6211// | RESTNotif | |
6212// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02006213// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03006214// | |------------->|
6215// | | |
6216// | | SubResp |
6217// | |<-------------|
6218// | RESTNotif | |
6219// |<----------------| |
6220// | ... | ... |
6221// | | |
6222// | | |
6223// | RESTSubDelReq | |
6224// |---------------->| |
6225// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006226// | RESTSubDelResp| |
6227// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03006228// | | SubDelReq |
6229// | |------------->|
6230// | | |
6231// | | SubDelResp |
6232// | |<-------------|
6233// | | |
archaggeafbf95f2021-04-14 08:54:05 +03006234//
6235//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006236
archaggeafbf95f2021-04-14 08:54:05 +03006237func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006238 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006239 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006240 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006241}
6242
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006243func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006244 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03006245
Anssi Mannila21782182021-12-10 10:56:02 +02006246 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6247 Counter{cRestSubReqFromXapp, 1},
6248 Counter{cRestSubRespToXapp, 1},
6249 Counter{cSubReqToE2, uint64(subReqCount)},
6250 Counter{cSubRespFromE2, uint64(subReqCount)},
6251 Counter{cRestSubNotifToXapp, 1},
6252 Counter{cRestSubDelReqFromXapp, 1},
6253 Counter{cRestSubDelRespToXapp, 1},
6254 Counter{cSubDelReqToE2, uint64(subReqCount)},
6255 Counter{cSubDelRespFromE2, uint64(subReqCount)},
6256 })
6257
archaggeafbf95f2021-04-14 08:54:05 +03006258 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006259 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006260 restSubId := xappConn1.SendRESTSubsReq(t, params)
6261
6262 var e2SubsId []uint32
6263 for i := 0; i < subReqCount; i++ {
6264 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6265 xappConn1.ExpectRESTNotification(t, restSubId)
6266
6267 e2termConn1.SendSubsResp(t, crereq, cremsg)
6268 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006269 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03006270 e2SubsId = append(e2SubsId, instanceId)
6271 resp, _ := xapp.Subscription.QuerySubscriptions()
6272 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
6273 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
6274 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
6275
6276 }
6277
6278 // Del
6279 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6280
6281 for i := 0; i < subReqCount; i++ {
6282 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6283 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6284 }
6285
6286 // Wait that subs is cleaned
6287 for i := 0; i < subReqCount; i++ {
6288 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6289 }
6290
6291 xappConn1.TestMsgChanEmpty(t)
6292 e2termConn1.TestMsgChanEmpty(t)
6293 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006294 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006295 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006296}
6297
Anssi Mannila27385172021-12-22 09:41:54 +02006298//-----------------------------------------------------------------------------
6299// TestRESTTwoPolicySubReqAndSubDelOk
6300//
6301// stub stub
6302// +-------+ +---------+ +---------+
6303// | xapp | | submgr | | e2term |
6304// +-------+ +---------+ +---------+
6305// | | |
6306// | RestSubReq | |
6307// |---------------->| |
6308// | | |
6309// | RESTSubResp | |
6310// |<----------------| |
6311// | | |
6312// | | SubReq |
6313// | |------------->|
6314// | | |
6315// | | SubResp |
6316// | |<-------------|
6317// | RESTNotif | |
6318// |<----------------| |
6319// | | SubReq |
6320// | |------------->|
6321// | | |
6322// | | SubResp |
6323// | |<-------------|
6324// | RESTNotif | |
6325// |<----------------| |
6326// | | |
6327// | RESTSubDelReq | |
6328// |---------------->| |
6329// | | |
6330// | RESTSubDelResp| |
6331// |<----------------| |
6332// | | SubDelReq |
6333// | |------------->|
6334// | | |
6335// | | SubDelResp |
6336// | |<-------------|
6337// | | |
6338// | | SubDelReq |
6339// | |------------->|
6340// | | |
6341// | | SubDelResp |
6342// | |<-------------|
6343// | | |
6344//
6345//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006346
archaggeafbf95f2021-04-14 08:54:05 +03006347func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6348
archaggeafbf95f2021-04-14 08:54:05 +03006349 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006350 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006351 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006352 Counter{cSubReqToE2, 2},
6353 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006354 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006355 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006356 Counter{cSubDelReqToE2, 2},
6357 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006358 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006359 })
6360
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006361 const subReqCount int = 2
6362
archaggeafbf95f2021-04-14 08:54:05 +03006363 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006364 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006365 restSubId := xappConn1.SendRESTSubsReq(t, params)
6366 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6367
6368 assert.Equal(t, len(e2SubsIds), 2)
6369
6370 // Del
6371 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6372 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6373
6374 xappConn1.TestMsgChanEmpty(t)
6375 e2termConn1.TestMsgChanEmpty(t)
6376 mainCtrl.wait_registry_empty(t, 10)
6377
6378 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006379 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006380}
Anssi Mannila27385172021-12-22 09:41:54 +02006381
6382//-----------------------------------------------------------------------------
6383// TestRESTPolicySubReqAndSubDelOk19E2Subs
6384//
6385// stub stub
6386// +-------+ +---------+ +---------+
6387// | xapp | | submgr | | e2term |
6388// +-------+ +---------+ +---------+
6389// | | |
6390// | RestSubReq | |
6391// |---------------->| |
6392// | | |
6393// | RESTSubResp | |
6394// |<----------------| |
6395// | | | ------
6396// | | SubReq |
6397// | |------------->|
6398// | | | E2 subscription x 19
6399// | | SubResp |
6400// | |<-------------|
6401// | RESTNotif | |
6402// |<----------------| |
6403// | | | ------
6404// | RESTSubDelReq | |
6405// |---------------->| |
6406// | | |
6407// | RESTSubDelResp| |
6408// |<----------------| |
6409// | | SubDelReq | ------
6410// | |------------->|
6411// | | | E2 subscription delete x 19
6412// | | SubDelResp |
6413// | |<-------------|
6414// | | | ------
6415// | | |
6416//
6417//-----------------------------------------------------------------------------
6418
6419func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006420
archaggeafbf95f2021-04-14 08:54:05 +03006421 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006422 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006423 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006424 Counter{cSubReqToE2, 19},
6425 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006426 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006427 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006428 Counter{cSubDelReqToE2, 19},
6429 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006430 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006431 })
6432
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006433 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006434 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006435 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006436 restSubId := xappConn1.SendRESTSubsReq(t, params)
6437 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6438
6439 assert.Equal(t, len(e2SubsIds), 19)
6440
6441 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6442 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6443
6444 xappConn1.TestMsgChanEmpty(t)
6445 e2termConn1.TestMsgChanEmpty(t)
6446 mainCtrl.wait_registry_empty(t, 10)
6447
6448 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006449 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006450}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006451
Anssi Mannila27385172021-12-22 09:41:54 +02006452//-----------------------------------------------------------------------------
6453// TestRESTTwoPolicySubReqAndSubDelOk
6454//
6455// stub stub
6456// +-------+ +---------+ +---------+
6457// | xapp | | submgr | | e2term |
6458// +-------+ +---------+ +---------+
6459// | | |
6460// | RestSubReq | |
6461// |---------------->| |
6462// | | |
6463// | RESTSubResp | |
6464// |<----------------| |
6465// | | |
6466// | | SubReq |
6467// | |------------->|
6468// | | |
6469// | | SubResp |
6470// | |<-------------|
6471// | RESTNotif | |
6472// |<----------------| |
6473// | | SubReq |
6474// | |------------->|
6475// | | |
6476// | | SubResp |
6477// | |<-------------|
6478// | RESTNotif | |
6479// |<----------------| |
6480// | | |
6481// | RESTSubDelReq | |
6482// |---------------->| |
6483// | | |
6484// | RESTSubDelResp| |
6485// |<----------------| |
6486// | | SubDelReq |
6487// | |------------->|
6488// | | |
6489// | | SubDelResp |
6490// | |<-------------|
6491// | | |
6492// | | SubDelReq |
6493// | |------------->|
6494// | | |
6495// | | SubDelResp |
6496// | |<-------------|
6497// | | |
6498//
6499//-----------------------------------------------------------------------------
6500
archaggeafbf95f2021-04-14 08:54:05 +03006501func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6502
6503 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006504
6505 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006506 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006507 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006508 Counter{cSubReqToE2, uint64(subReqCount)},
6509 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006510 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006511 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006512 Counter{cSubDelReqToE2, uint64(subReqCount)},
6513 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006514 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006515 })
6516
6517 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006518 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006519 restSubId := xappConn1.SendRESTSubsReq(t, params)
6520 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6521
6522 assert.Equal(t, len(e2SubsIds), subReqCount)
6523
6524 // Del
6525 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6526 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6527
6528 xappConn1.TestMsgChanEmpty(t)
6529 e2termConn1.TestMsgChanEmpty(t)
6530 mainCtrl.wait_registry_empty(t, 10)
6531
6532 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006533 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006534}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006535
Anssi Mannila27385172021-12-22 09:41:54 +02006536//-----------------------------------------------------------------------------
6537// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6538//
6539// stub stub
6540// +-------+ +---------+ +---------+
6541// | xapp | | submgr | | e2term |
6542// +-------+ +---------+ +---------+
6543// | | |
6544// | RestSubReq | |
6545// |---------------->| |
6546// | | |
6547// | RESTSubResp | |
6548// |<----------------| |
6549// | | |
6550// | | SubReq |
6551// | |------------->|
6552// | | |
6553// | | SubResp |
6554// | |<-------------|
6555// | RESTNotif | |
6556// |<----------------| |
6557// | | SubReq |
6558// | |------------->|
6559// | | |
6560// | | SubResp |
6561// | |<-------------|
6562// | RESTNotif | |
6563// |<----------------| |
6564// | | |
6565// | RESTSubDelReq | |
6566// |---------------->| |
6567// | | |
6568// | RESTSubDelResp| |
6569// |<----------------| |
6570// | | SubDelReq |
6571// | |------------->|
6572// | | |
6573// | | SubDelResp |
6574// | |<-------------|
6575// | | |
6576// | | SubDelReq |
6577// | |------------->|
6578// | | |
6579// | | SubDelResp |
6580// | |<-------------|
6581// | | |
6582//
6583//-----------------------------------------------------------------------------
6584
archaggeafbf95f2021-04-14 08:54:05 +03006585func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6586
6587 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006588
6589 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006590 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006591 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006592 Counter{cSubReqToE2, uint64(subReqCount)},
6593 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006594 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006595 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006596 Counter{cSubDelReqToE2, uint64(subReqCount)},
6597 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006598 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006599 })
6600
6601 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006602 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006603 restSubId := xappConn1.SendRESTSubsReq(t, params)
6604 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6605
6606 assert.Equal(t, len(e2SubsIds), subReqCount)
6607
6608 // Del
6609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6610 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6611
6612 xappConn1.TestMsgChanEmpty(t)
6613 e2termConn1.TestMsgChanEmpty(t)
6614 mainCtrl.wait_registry_empty(t, 10)
6615
6616 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006617 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006618}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006619
Anssi Mannila27385172021-12-22 09:41:54 +02006620//-----------------------------------------------------------------------------
6621// TestRESTReportSubReqAndSubDelOk19E2Subs
6622//
6623// stub stub
6624// +-------+ +---------+ +---------+
6625// | xapp | | submgr | | e2term |
6626// +-------+ +---------+ +---------+
6627// | | |
6628// | RestSubReq | |
6629// |---------------->| |
6630// | | |
6631// | RESTSubResp | |
6632// |<----------------| |
6633// | | | ------
6634// | | SubReq |
6635// | |------------->|
6636// | | | E2 subscription x 19
6637// | | SubResp |
6638// | |<-------------|
6639// | RESTNotif | |
6640// |<----------------| |
6641// | | | ------
6642// | RESTSubDelReq | |
6643// |---------------->| |
6644// | | |
6645// | RESTSubDelResp| |
6646// |<----------------| |
6647// | | SubDelReq | ------
6648// | |------------->|
6649// | | | E2 subscription delete x 19
6650// | | SubDelResp |
6651// | |<-------------|
6652// | | | ------
6653// | | |
6654//
6655//-----------------------------------------------------------------------------
6656
6657func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006658
6659 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006660
6661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006662 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006663 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006664 Counter{cSubReqToE2, uint64(subReqCount)},
6665 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006666 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006667 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006668 Counter{cSubDelReqToE2, uint64(subReqCount)},
6669 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006670 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006671 })
6672
6673 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006674 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006675 restSubId := xappConn1.SendRESTSubsReq(t, params)
6676 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6677
6678 assert.Equal(t, len(e2SubsIds), subReqCount)
6679
6680 // Del
6681 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6682 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6683
6684 xappConn1.TestMsgChanEmpty(t)
6685 e2termConn1.TestMsgChanEmpty(t)
6686 mainCtrl.wait_registry_empty(t, 10)
6687
6688 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006689 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006690}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006691
Anssi Mannila27385172021-12-22 09:41:54 +02006692//-----------------------------------------------------------------------------
6693// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6694//
6695// stub stub stub
6696// +-------+ +-------+ +---------+ +---------+
6697// | xapp2 | | xapp1 | | submgr | | e2term |
6698// +-------+ +-------+ +---------+ +---------+
6699// | | | |
6700// | | RESTSubReq1 | |
6701// | |------------->| |
6702// | | RESTSubResp1 | |
6703// | |<-------------| |
6704// | | | |
6705// | | | SubReq1 |
6706// | | |------------->|
6707// | | | |
6708// | RESTSubReq2 | |
6709// |------------------------>| |
6710// | RESTSubResp2 | |
6711// |<------------------------| |
6712// | | | |
6713// | | | SubReq2 |
6714// | | |------------->|
6715// | | | |
6716// | | | SubResp1 |
6717// | | |<-------------|
6718// | | RESTNotif1 | |
6719// | |<-------------| |
6720// | | | |
6721// | | | SubResp2 |
6722// | | |<-------------|
6723// | RESTNotif2 | |
6724// |<------------------------| |
6725// | | | |
6726// | | [SUBS 1 DELETE] |
6727// | | | |
6728// | | [SUBS 2 DELETE] |
6729// | | | |
6730//
6731//-----------------------------------------------------------------------------
6732
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006733func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006734
6735 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006736 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006737 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006738 Counter{cSubReqToE2, 2},
6739 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006740 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006741 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006742 Counter{cSubDelReqToE2, 2},
6743 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006744 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006745 })
6746
6747 // Req1
6748 var params *teststube2ap.RESTSubsReqParams = nil
6749
6750 //Subs Create
6751 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006752 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006753
6754 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6755
6756 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006757 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006758 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006759 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006760 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6761
6762 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006763 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006764 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6765 xappConn2.ExpectRESTNotification(t, restSubId2)
6766 e2termConn1.SendSubsResp(t, crereq, cremsg)
6767 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6768
6769 deleteXapp1Subscription(t, &restSubId1)
6770 deleteXapp2Subscription(t, &restSubId2)
6771
6772 waitSubsCleanup(t, e2SubsId1, 10)
6773 waitSubsCleanup(t, e2SubsId2, 10)
6774
6775 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006776 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006777}
6778
Anssi Mannila27385172021-12-22 09:41:54 +02006779//-----------------------------------------------------------------------------
6780// TestRESTSubReqReportSameActionDiffActionListLen
6781//
6782// stub stub stub
6783// +-------+ +-------+ +---------+ +---------+
6784// | xapp2 | | xapp1 | | submgr | | e2term |
6785// +-------+ +-------+ +---------+ +---------+
6786// | | | |
6787// | | RESTSubReq1 | |
6788// | |------------->| |
6789// | | RESTSubResp1 | |
6790// | |<-------------| |
6791// | | | |
6792// | | | SubReq1 |
6793// | | |------------->|
6794// | | | |
6795// | RESTSubReq2 | |
6796// |------------------------>| |
6797// | RESTSubResp2 | |
6798// |<------------------------| |
6799// | | | |
6800// | | | SubReq2 |
6801// | | |------------->|
6802// | | | |
6803// | | | SubResp1 |
6804// | | |<-------------|
6805// | | RESTNotif1 | |
6806// | |<-------------| |
6807// | | | |
6808// | | | SubResp2 |
6809// | | |<-------------|
6810// | RESTNotif2 | |
6811// |<------------------------| |
6812// | | | |
6813// | | [SUBS 1 DELETE] |
6814// | | | |
6815// | | [SUBS 2 DELETE] |
6816// | | | |
6817//
6818//-----------------------------------------------------------------------------
6819
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006820func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006821
6822 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006823 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006824 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006825 Counter{cSubReqToE2, 2},
6826 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006827 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006828 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006829 Counter{cSubDelReqToE2, 2},
6830 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006831 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006832 })
6833
6834 // Req1
6835 var params *teststube2ap.RESTSubsReqParams = nil
6836
6837 //Subs Create
6838 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006839 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006840
6841 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6842
6843 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006844 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006845 params.SetMeid("RAN_NAME_1")
6846
6847 actionId := int64(1)
6848 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006849 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006850 subsequestActionType := "continue"
6851 timeToWait := "w10ms"
6852 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6853
6854 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006855 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006856 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6857 xappConn2.ExpectRESTNotification(t, restSubId2)
6858 e2termConn1.SendSubsResp(t, crereq, cremsg)
6859 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6860
6861 deleteXapp1Subscription(t, &restSubId1)
6862 deleteXapp2Subscription(t, &restSubId2)
6863
6864 waitSubsCleanup(t, e2SubsId1, 10)
6865 waitSubsCleanup(t, e2SubsId2, 10)
6866
6867 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006868 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006869}
6870
Anssi Mannila27385172021-12-22 09:41:54 +02006871//-----------------------------------------------------------------------------
6872// TestRESTSubReqReportSameActionDiffActionID
6873//
6874// stub stub stub
6875// +-------+ +-------+ +---------+ +---------+
6876// | xapp2 | | xapp1 | | submgr | | e2term |
6877// +-------+ +-------+ +---------+ +---------+
6878// | | | |
6879// | | RESTSubReq1 | |
6880// | |------------->| |
6881// | | RESTSubResp1 | |
6882// | |<-------------| |
6883// | | | |
6884// | | | SubReq1 |
6885// | | |------------->|
6886// | | | |
6887// | RESTSubReq2 | |
6888// |------------------------>| |
6889// | RESTSubResp2 | |
6890// |<------------------------| |
6891// | | | |
6892// | | | SubReq2 |
6893// | | |------------->|
6894// | | | |
6895// | | | SubResp1 |
6896// | | |<-------------|
6897// | | RESTNotif1 | |
6898// | |<-------------| |
6899// | | | |
6900// | | | SubResp2 |
6901// | | |<-------------|
6902// | RESTNotif2 | |
6903// |<------------------------| |
6904// | | | |
6905// | | [SUBS 1 DELETE] |
6906// | | | |
6907// | | [SUBS 2 DELETE] |
6908// | | | |
6909//
6910//-----------------------------------------------------------------------------
6911
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006912func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006913
6914 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006915 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006916 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006917 Counter{cSubReqToE2, 2},
6918 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006919 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006920 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006921 Counter{cSubDelReqToE2, 2},
6922 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006923 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006924 })
6925
6926 // Req1
6927 var params *teststube2ap.RESTSubsReqParams = nil
6928
6929 //Subs Create
6930 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006931 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006932
6933 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6934
6935 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006936 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006937 params.SetMeid("RAN_NAME_1")
6938 params.SetSubActionIDs(int64(2))
6939
6940 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006941 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006942 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6943 xappConn2.ExpectRESTNotification(t, restSubId2)
6944 e2termConn1.SendSubsResp(t, crereq, cremsg)
6945 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6946
6947 deleteXapp1Subscription(t, &restSubId1)
6948 deleteXapp2Subscription(t, &restSubId2)
6949
6950 waitSubsCleanup(t, e2SubsId1, 10)
6951 waitSubsCleanup(t, e2SubsId2, 10)
6952
6953 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006954 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006955}
6956
Anssi Mannila27385172021-12-22 09:41:54 +02006957//-----------------------------------------------------------------------------
6958// TestRESTSubReqDiffActionType
6959//
6960// stub stub stub
6961// +-------+ +-------+ +---------+ +---------+
6962// | xapp2 | | xapp1 | | submgr | | e2term |
6963// +-------+ +-------+ +---------+ +---------+
6964// | | | |
6965// | | RESTSubReq1 | |
6966// | |------------->| |
6967// | | RESTSubResp1 | |
6968// | |<-------------| |
6969// | | | |
6970// | | | SubReq1 |
6971// | | |------------->|
6972// | | | |
6973// | RESTSubReq2 | |
6974// |------------------------>| |
6975// | RESTSubResp2 | |
6976// |<------------------------| |
6977// | | | |
6978// | | | SubReq2 |
6979// | | |------------->|
6980// | | | |
6981// | | | SubResp1 |
6982// | | |<-------------|
6983// | | RESTNotif1 | |
6984// | |<-------------| |
6985// | | | |
6986// | | | SubResp2 |
6987// | | |<-------------|
6988// | RESTNotif2 | |
6989// |<------------------------| |
6990// | | | |
6991// | | [SUBS 1 DELETE] |
6992// | | | |
6993// | | [SUBS 2 DELETE] |
6994// | | | |
6995//
6996//-----------------------------------------------------------------------------
6997
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006998func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006999
7000 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007001 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007002 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007003 Counter{cSubReqToE2, 2},
7004 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007005 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007006 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007007 Counter{cSubDelReqToE2, 2},
7008 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007009 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007010 })
7011
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007012 const e2Timeout int64 = 2
7013 const e2RetryCount int64 = 2
7014 const routingNeeded bool = true
7015
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007016 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007017 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007018 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007019
7020 //Subs Create
7021 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007022 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007023
7024 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7025
7026 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007027 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007028 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007029 params.SetMeid("RAN_NAME_1")
7030
7031 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007032 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007033 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7034 xappConn2.ExpectRESTNotification(t, restSubId2)
7035 e2termConn1.SendSubsResp(t, crereq, cremsg)
7036 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7037
7038 deleteXapp1Subscription(t, &restSubId1)
7039 deleteXapp2Subscription(t, &restSubId2)
7040
7041 waitSubsCleanup(t, e2SubsId1, 10)
7042 waitSubsCleanup(t, e2SubsId2, 10)
7043
7044 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007045 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007046}
7047
Anssi Mannila27385172021-12-22 09:41:54 +02007048//-----------------------------------------------------------------------------
7049// TestRESTSubReqPolicyAndSubDelOkSameAction
7050//
7051// stub stub stub
7052// +-------+ +-------+ +---------+ +---------+
7053// | xapp2 | | xapp1 | | submgr | | e2term |
7054// +-------+ +-------+ +---------+ +---------+
7055// | | | |
7056// | | RESTSubReq1 | |
7057// | |------------->| |
7058// | | RESTSubResp1 | |
7059// | |<-------------| |
7060// | | | |
7061// | | | SubReq1 |
7062// | | |------------->|
7063// | | | |
7064// | RESTSubReq2 | |
7065// |------------------------>| |
7066// | RESTSubResp2 | |
7067// |<------------------------| |
7068// | | | |
7069// | | | SubReq2 |
7070// | | |------------->|
7071// | | | |
7072// | | | SubResp1 |
7073// | | |<-------------|
7074// | | RESTNotif1 | |
7075// | |<-------------| |
7076// | | | |
7077// | | | SubResp2 |
7078// | | |<-------------|
7079// | RESTNotif2 | |
7080// |<------------------------| |
7081// | | | |
7082// | | [SUBS 1 DELETE] |
7083// | | | |
7084// | | [SUBS 2 DELETE] |
7085// | | | |
7086//
7087//-----------------------------------------------------------------------------
7088
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007089func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007090
7091 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007092 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007093 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007094 Counter{cSubReqToE2, 2},
7095 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007096 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007097 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007098 Counter{cSubDelReqToE2, 2},
7099 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007100 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007101 })
7102
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007103 const e2Timeout int64 = 2
7104 const e2RetryCount int64 = 2
7105 const routingNeeded bool = true
7106
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007107 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007108 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007109 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007110
7111 //Subs Create
7112 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007113 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007114
7115 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7116
7117 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007118 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007119 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007120 params.SetMeid("RAN_NAME_1")
7121
7122 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007123 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007124 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7125 xappConn2.ExpectRESTNotification(t, restSubId2)
7126 e2termConn1.SendSubsResp(t, crereq, cremsg)
7127 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7128
7129 deleteXapp1Subscription(t, &restSubId1)
7130 deleteXapp2Subscription(t, &restSubId2)
7131
7132 waitSubsCleanup(t, e2SubsId1, 10)
7133 waitSubsCleanup(t, e2SubsId2, 10)
7134
7135 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007136 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007137}
7138
Anssi Mannila27385172021-12-22 09:41:54 +02007139//-----------------------------------------------------------------------------
7140// TestRESTSubReqReportSameActionDiffActionDefinitionLen
7141//
7142// stub stub stub
7143// +-------+ +-------+ +---------+ +---------+
7144// | xapp2 | | xapp1 | | submgr | | e2term |
7145// +-------+ +-------+ +---------+ +---------+
7146// | | | |
7147// | | RESTSubReq1 | |
7148// | |------------->| |
7149// | | RESTSubResp1 | |
7150// | |<-------------| |
7151// | | | |
7152// | | | SubReq1 |
7153// | | |------------->|
7154// | | | |
7155// | RESTSubReq2 | |
7156// |------------------------>| |
7157// | RESTSubResp2 | |
7158// |<------------------------| |
7159// | | | |
7160// | | | SubReq2 |
7161// | | |------------->|
7162// | | | |
7163// | | | SubResp1 |
7164// | | |<-------------|
7165// | | RESTNotif1 | |
7166// | |<-------------| |
7167// | | | |
7168// | | | SubResp2 |
7169// | | |<-------------|
7170// | RESTNotif2 | |
7171// |<------------------------| |
7172// | | | |
7173// | | [SUBS 1 DELETE] |
7174// | | | |
7175// | | [SUBS 2 DELETE] |
7176// | | | |
7177//
7178//-----------------------------------------------------------------------------
7179
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007180func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007181
7182 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007183 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007184 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007185 Counter{cSubReqToE2, 2},
7186 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007187 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007188 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007189 Counter{cSubDelReqToE2, 2},
7190 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007191 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007192 })
7193
7194 // Req1
7195 var params *teststube2ap.RESTSubsReqParams = nil
7196
7197 //Subs Create
7198 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007199 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007200
7201 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7202
7203 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007204 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007205 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007206 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007207 params.SetSubActionDefinition(actionDefinition)
7208
7209 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007210 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007211 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7212 xappConn2.ExpectRESTNotification(t, restSubId2)
7213 e2termConn1.SendSubsResp(t, crereq, cremsg)
7214 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7215
7216 deleteXapp1Subscription(t, &restSubId1)
7217 deleteXapp2Subscription(t, &restSubId2)
7218
7219 waitSubsCleanup(t, e2SubsId1, 10)
7220 waitSubsCleanup(t, e2SubsId2, 10)
7221
7222 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007223 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007224}
7225
Anssi Mannila27385172021-12-22 09:41:54 +02007226//-----------------------------------------------------------------------------
7227// TestRESTSubReqReportSameActionDiffActionDefinitionContents
7228//
7229// stub stub stub
7230// +-------+ +-------+ +---------+ +---------+
7231// | xapp2 | | xapp1 | | submgr | | e2term |
7232// +-------+ +-------+ +---------+ +---------+
7233// | | | |
7234// | | RESTSubReq1 | |
7235// | |------------->| |
7236// | | RESTSubResp1 | |
7237// | |<-------------| |
7238// | | | |
7239// | | | SubReq1 |
7240// | | |------------->|
7241// | | | |
7242// | RESTSubReq2 | |
7243// |------------------------>| |
7244// | RESTSubResp2 | |
7245// |<------------------------| |
7246// | | | |
7247// | | | SubReq2 |
7248// | | |------------->|
7249// | | | |
7250// | | | SubResp1 |
7251// | | |<-------------|
7252// | | RESTNotif1 | |
7253// | |<-------------| |
7254// | | | |
7255// | | | SubResp2 |
7256// | | |<-------------|
7257// | RESTNotif2 | |
7258// |<------------------------| |
7259// | | | |
7260// | | [SUBS 1 DELETE] |
7261// | | | |
7262// | | [SUBS 2 DELETE] |
7263// | | | |
7264//
7265//-----------------------------------------------------------------------------
7266
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007267func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007268
7269 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007270 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007271 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007272 Counter{cSubReqToE2, 2},
7273 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007274 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007275 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007276 Counter{cSubDelReqToE2, 2},
7277 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007278 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007279 })
7280
7281 // Req1
7282 var params *teststube2ap.RESTSubsReqParams = nil
7283
7284 //Subs Create
7285 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007286 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007287
7288 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7289
7290 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007291 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007292 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007293 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007294 params.SetSubActionDefinition(actionDefinition)
7295
7296 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007297 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007298 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7299 xappConn2.ExpectRESTNotification(t, restSubId2)
7300 e2termConn1.SendSubsResp(t, crereq, cremsg)
7301 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7302
7303 deleteXapp1Subscription(t, &restSubId1)
7304 deleteXapp2Subscription(t, &restSubId2)
7305
7306 waitSubsCleanup(t, e2SubsId1, 10)
7307 waitSubsCleanup(t, e2SubsId2, 10)
7308
7309 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007310 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007311}
7312
Anssi Mannila27385172021-12-22 09:41:54 +02007313//-----------------------------------------------------------------------------
7314// TestRESTSubReqReportSameActionDiffSubsAction
7315//
7316// stub stub stub
7317// +-------+ +-------+ +---------+ +---------+
7318// | xapp2 | | xapp1 | | submgr | | e2term |
7319// +-------+ +-------+ +---------+ +---------+
7320// | | | |
7321// | | RESTSubReq1 | |
7322// | |------------->| |
7323// | | RESTSubResp1 | |
7324// | |<-------------| |
7325// | | | |
7326// | | | SubReq1 |
7327// | | |------------->|
7328// | | | |
7329// | RESTSubReq2 | |
7330// |------------------------>| |
7331// | RESTSubResp2 | |
7332// |<------------------------| |
7333// | | | |
7334// | | | SubReq2 |
7335// | | |------------->|
7336// | | | |
7337// | | | SubResp1 |
7338// | | |<-------------|
7339// | | RESTNotif1 | |
7340// | |<-------------| |
7341// | | | |
7342// | | | SubResp2 |
7343// | | |<-------------|
7344// | RESTNotif2 | |
7345// |<------------------------| |
7346// | | | |
7347// | | [SUBS 1 DELETE] |
7348// | | | |
7349// | | [SUBS 2 DELETE] |
7350// | | | |
7351//
7352//-----------------------------------------------------------------------------
7353
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007354func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007355
7356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007357 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007358 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007359 Counter{cSubReqToE2, 2},
7360 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007361 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007362 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007363 Counter{cSubDelReqToE2, 2},
7364 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007365 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007366 })
7367
7368 // Req1
7369 var params *teststube2ap.RESTSubsReqParams = nil
7370
7371 //Subs Create
7372 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007373 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007374
7375 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7376
7377 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007378 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007379 params.SetMeid("RAN_NAME_1")
7380 params.SetTimeToWait("w200ms")
7381 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007382 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007383 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7384 xappConn2.ExpectRESTNotification(t, restSubId2)
7385 e2termConn1.SendSubsResp(t, crereq, cremsg)
7386 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7387
7388 deleteXapp1Subscription(t, &restSubId1)
7389 deleteXapp2Subscription(t, &restSubId2)
7390
7391 waitSubsCleanup(t, e2SubsId1, 10)
7392 waitSubsCleanup(t, e2SubsId2, 10)
7393
7394 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007395 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007396}
7397
Anssi Mannila51122392021-05-25 11:51:31 +03007398//-----------------------------------------------------------------------------
7399// TestRESTUnpackSubscriptionResponseDecodeFail
7400//
7401// stub stub
7402// +-------+ +---------+ +---------+
7403// | xapp | | submgr | | e2term |
7404// +-------+ +---------+ +---------+
7405// | | |
7406// | RestSubReq | |
7407// |---------------->| |
7408// | | |
7409// | RESTSubResp | |
7410// |<----------------| |
7411// | | |
7412// | | SubReq |
7413// | |------------->|
7414// | | |
7415// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007416// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007417// | | |
7418// | | SubReq |
7419// | |------------->|
7420// | | |
7421// | | SubFail | Duplicated action
7422// | |<-------------|
7423// | RESTNotif (fail)| |
7424// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007425// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007426// | [SUBS DELETE] |
7427// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007428//
7429//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007430
Anssi Mannila51122392021-05-25 11:51:31 +03007431func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007432
7433 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7434 Counter{cRestSubReqFromXapp, 1},
7435 Counter{cRestSubRespToXapp, 1},
7436 Counter{cSubReqToE2, 1},
7437 Counter{cSubReqTimerExpiry, 1},
7438 Counter{cSubReReqToE2, 1},
7439 Counter{cSubRespFromE2, 1},
7440 Counter{cSubFailFromE2, 1},
7441 Counter{cRestSubFailNotifToXapp, 1},
7442 Counter{cRestSubDelReqFromXapp, 1},
7443 Counter{cRestSubDelRespToXapp, 1},
7444 })
7445
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007446 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007447
7448 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007449 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007450 restSubId := xappConn1.SendRESTSubsReq(t, params)
7451
7452 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7453 // Decode of this response fails which will result resending original request
7454 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7455
7456 _, cremsg = e2termConn1.RecvSubsReq(t)
7457
Markku Virtanen55d2a282021-06-04 14:46:56 +03007458 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007459
7460 // Subscription already created in E2 Node.
7461 fparams := &teststube2ap.E2StubSubsFailParams{}
7462 fparams.Set(crereq)
7463 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7464 e2termConn1.SendSubsFail(t, fparams, cremsg)
7465
Anssi Mannila51122392021-05-25 11:51:31 +03007466 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007467 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007468
Anssi Mannilab43397e2021-11-16 12:06:16 +02007469 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7470
Anssi Mannila51122392021-05-25 11:51:31 +03007471 // Wait that subs is cleaned
7472 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7473
7474 xappConn1.TestMsgChanEmpty(t)
7475 e2termConn1.TestMsgChanEmpty(t)
7476 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007477 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007478 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007479}
7480
7481//-----------------------------------------------------------------------------
7482// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7483//
7484// stub stub
7485// +-------+ +---------+ +---------+
7486// | xapp | | submgr | | e2term |
7487// +-------+ +---------+ +---------+
7488// | | |
7489// | RestSubReq | |
7490// |---------------->| |
7491// | | |
7492// | RESTSubResp | |
7493// |<----------------| |
7494// | | |
7495// | | SubReq |
7496// | |------------->|
7497// | | |
7498// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007499// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007500// | | |
7501// | | SubReq |
7502// | |------------->|
7503// | | |
7504// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007505// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007506// | RESTNotif (fail)| |
7507// |<----------------| |
7508// | | SubDelReq |
7509// | |------------->|
7510// | | |
7511// | | SubDelResp |
7512// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007513// | | |
7514// | [SUBS DELETE] |
7515// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007516//
7517//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007518
Anssi Mannila51122392021-05-25 11:51:31 +03007519func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007520
7521 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7522 Counter{cRestSubReqFromXapp, 1},
7523 Counter{cRestSubRespToXapp, 1},
7524 Counter{cSubReqToE2, 1},
7525 Counter{cSubReqTimerExpiry, 2},
7526 Counter{cSubReReqToE2, 1},
7527 Counter{cSubRespFromE2, 1},
7528 Counter{cSubFailFromE2, 1},
7529 Counter{cRestSubFailNotifToXapp, 1},
7530 Counter{cRestSubDelReqFromXapp, 1},
7531 Counter{cRestSubDelRespToXapp, 1},
7532 Counter{cSubDelReqToE2, 1},
7533 Counter{cSubDelRespFromE2, 1},
7534 })
7535
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007536 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007537
7538 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007539 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007540 restSubId := xappConn1.SendRESTSubsReq(t, params)
7541
7542 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7543
Anssi Mannila21782182021-12-10 10:56:02 +02007544 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007545 orgInstanceId := crereq.RequestId.InstanceId
7546 crereq.RequestId.InstanceId = 0
7547 e2termConn1.SendSubsResp(t, crereq, cremsg)
7548
7549 _, cremsg = e2termConn1.RecvSubsReq(t)
7550
Markku Virtanen55d2a282021-06-04 14:46:56 +03007551 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007552
Anssi Mannila21782182021-12-10 10:56:02 +02007553 // 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 +03007554 fparams := &teststube2ap.E2StubSubsFailParams{}
7555 fparams.Set(crereq)
7556 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7557 e2termConn1.SendSubsFail(t, fparams, cremsg)
7558
7559 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7561
7562 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007563 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007564
Anssi Mannilab43397e2021-11-16 12:06:16 +02007565 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7566
Anssi Mannila51122392021-05-25 11:51:31 +03007567 // Wait that subs is cleaned
7568 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7569
7570 xappConn1.TestMsgChanEmpty(t)
7571 e2termConn1.TestMsgChanEmpty(t)
7572 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007573 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007574 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007575}
7576
7577//-----------------------------------------------------------------------------
7578// TestRESTUnpackSubscriptionResponseNoTransaction
7579//
7580// stub stub
7581// +-------+ +---------+ +---------+
7582// | xapp | | submgr | | e2term |
7583// +-------+ +---------+ +---------+
7584// | | |
7585// | RestSubReq | |
7586// |---------------->| |
7587// | | |
7588// | RESTSubResp | |
7589// |<----------------| |
7590// | | |
7591// | | SubReq |
7592// | |------------->|
7593// | | |
7594// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007595// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007596// | | |
7597// | | SubReq |
7598// | |------------->|
7599// | | |
7600// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007601// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007602// | RESTNotif (fail)| |
7603// |<----------------| |
7604// | | SubDelReq |
7605// | |------------->|
7606// | | |
7607// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007608// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007609// | | |
7610// | | SubDelReq |
7611// | |------------->|
7612// | | |
7613// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007614// | |<-------------| Ongoing transaction not found.
7615// | | |
7616// | [SUBS DELETE] |
7617// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007618//
7619//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007620
Anssi Mannila51122392021-05-25 11:51:31 +03007621func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007622
7623 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7624 Counter{cRestSubReqFromXapp, 1},
7625 Counter{cRestSubRespToXapp, 1},
7626 Counter{cSubReqToE2, 1},
7627 Counter{cSubReqTimerExpiry, 2},
7628 Counter{cSubReReqToE2, 1},
7629 Counter{cSubRespFromE2, 1},
7630 Counter{cSubFailFromE2, 1},
7631 Counter{cRestSubFailNotifToXapp, 1},
7632 Counter{cRestSubDelReqFromXapp, 1},
7633 Counter{cRestSubDelRespToXapp, 1},
7634 Counter{cSubDelReqToE2, 1},
7635 Counter{cSubDelReqTimerExpiry, 2},
7636 Counter{cSubDelReReqToE2, 1},
7637 Counter{cSubDelRespFromE2, 2},
7638 })
7639
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007640 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007641
7642 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007643 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007644 restSubId := xappConn1.SendRESTSubsReq(t, params)
7645
7646 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7647
7648 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7649 // No transaction exist for this response which will result resending original request
7650 e2termConn1.SendSubsResp(t, crereq, cremsg)
7651
7652 _, cremsg = e2termConn1.RecvSubsReq(t)
7653
Markku Virtanen55d2a282021-06-04 14:46:56 +03007654 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007655
7656 // Subscription already created in E2 Node.
7657 fparams := &teststube2ap.E2StubSubsFailParams{}
7658 fparams.Set(crereq)
7659 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7660 e2termConn1.SendSubsFail(t, fparams, cremsg)
7661
7662 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7663 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7664
7665 // Resending happens because there no transaction
7666 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7667 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7668
7669 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007670 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007671
Anssi Mannilab43397e2021-11-16 12:06:16 +02007672 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7673
Anssi Mannila51122392021-05-25 11:51:31 +03007674 // Wait that subs is cleaned
7675 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7676
7677 xappConn1.TestMsgChanEmpty(t)
7678 e2termConn1.TestMsgChanEmpty(t)
7679 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007680 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007681 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007682}
7683
7684//-----------------------------------------------------------------------------
7685// TestRESTUnpackSubscriptionFailureDecodeFail
7686//
7687// stub stub
7688// +-------+ +---------+ +---------+
7689// | xapp | | submgr | | e2term |
7690// +-------+ +---------+ +---------+
7691// | | |
7692// | RestSubReq | |
7693// |---------------->| |
7694// | | |
7695// | RESTSubResp | |
7696// |<----------------| |
7697// | | |
7698// | | SubReq |
7699// | |------------->|
7700// | | |
7701// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007702// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007703// | | |
7704// | | SubReq |
7705// | |------------->|
7706// | | |
7707// | | SubFail | Duplicated action
7708// | |<-------------|
7709// | RESTNotif (fail)| |
7710// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007711// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007712// | [SUBS DELETE] |
7713// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007714//
7715//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007716
Anssi Mannila51122392021-05-25 11:51:31 +03007717func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007718
7719 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7720 Counter{cRestSubReqFromXapp, 1},
7721 Counter{cRestSubRespToXapp, 1},
7722 Counter{cSubReqToE2, 1},
7723 Counter{cSubReqTimerExpiry, 1},
7724 Counter{cSubReReqToE2, 1},
7725 Counter{cSubFailFromE2, 2},
7726 Counter{cRestSubFailNotifToXapp, 1},
7727 Counter{cRestSubDelReqFromXapp, 1},
7728 Counter{cRestSubDelRespToXapp, 1},
7729 })
7730
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007731 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007732
7733 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007734 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007735 restSubId := xappConn1.SendRESTSubsReq(t, params)
7736
7737 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7738
7739 // Decode of this response fails which will result resending original request
7740 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7741
7742 _, cremsg = e2termConn1.RecvSubsReq(t)
7743
Markku Virtanen55d2a282021-06-04 14:46:56 +03007744 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007745
7746 // Subscription already created in E2 Node.
7747 fparams := &teststube2ap.E2StubSubsFailParams{}
7748 fparams.Set(crereq)
7749 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7750 e2termConn1.SendSubsFail(t, fparams, cremsg)
7751
Anssi Mannila51122392021-05-25 11:51:31 +03007752 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007753 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007754
Anssi Mannilab43397e2021-11-16 12:06:16 +02007755 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7756
Anssi Mannila51122392021-05-25 11:51:31 +03007757 // Wait that subs is cleaned
7758 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7759
7760 xappConn1.TestMsgChanEmpty(t)
7761 e2termConn1.TestMsgChanEmpty(t)
7762 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007763 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007764 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007765}
7766
7767//-----------------------------------------------------------------------------
7768// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7769//
7770// stub stub
7771// +-------+ +---------+ +---------+
7772// | xapp | | submgr | | e2term |
7773// +-------+ +---------+ +---------+
7774// | | |
7775// | RestSubReq | |
7776// |---------------->| |
7777// | | |
7778// | RESTSubResp | |
7779// |<----------------| |
7780// | | |
7781// | | SubReq |
7782// | |------------->|
7783// | | |
7784// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007785// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007786// | | |
7787// | | SubReq |
7788// | |------------->|
7789// | | |
7790// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007791// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007792// | RESTNotif (fail)| |
7793// |<----------------| |
7794// | | SubDelReq |
7795// | |------------->|
7796// | | |
7797// | | SubDelResp |
7798// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007799// | | |
7800// | [SUBS DELETE] |
7801// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007802//
7803//-----------------------------------------------------------------------------
7804func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007805
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007806 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007807
Anssi Mannila21782182021-12-10 10:56:02 +02007808 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7809 Counter{cRestSubReqFromXapp, 1},
7810 Counter{cRestSubRespToXapp, 1},
7811 Counter{cSubReqToE2, 1},
7812 Counter{cSubReqTimerExpiry, 2},
7813 Counter{cSubReReqToE2, 1},
7814 Counter{cSubFailFromE2, 2},
7815 Counter{cRestSubFailNotifToXapp, 1},
7816 Counter{cRestSubDelReqFromXapp, 1},
7817 Counter{cRestSubDelRespToXapp, 1},
7818 Counter{cSubDelReqToE2, 1},
7819 Counter{cSubDelRespFromE2, 1},
7820 })
7821
Anssi Mannila51122392021-05-25 11:51:31 +03007822 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007823 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007824 restSubId := xappConn1.SendRESTSubsReq(t, params)
7825
7826 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7827
Anssi Mannila21782182021-12-10 10:56:02 +02007828 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007829 fparams := &teststube2ap.E2StubSubsFailParams{}
7830 fparams.Set(crereq)
7831 fparams.Fail.RequestId.InstanceId = 0
7832 e2termConn1.SendSubsFail(t, fparams, cremsg)
7833
7834 _, cremsg = e2termConn1.RecvSubsReq(t)
7835
Markku Virtanen55d2a282021-06-04 14:46:56 +03007836 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007837
Anssi Mannila21782182021-12-10 10:56:02 +02007838 // 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 +03007839 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7840 e2termConn1.SendSubsFail(t, fparams, cremsg)
7841
7842 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7843 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7844
7845 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007846 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007847
Anssi Mannilab43397e2021-11-16 12:06:16 +02007848 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7849
Anssi Mannila51122392021-05-25 11:51:31 +03007850 // Wait that subs is cleaned
7851 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7852
7853 xappConn1.TestMsgChanEmpty(t)
7854 e2termConn1.TestMsgChanEmpty(t)
7855 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007856 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007857 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007858}
7859
7860//-----------------------------------------------------------------------------
7861// TestRESTUnpackSubscriptionFailureNoTransaction
7862//
7863// stub stub
7864// +-------+ +---------+ +---------+
7865// | xapp | | submgr | | e2term |
7866// +-------+ +---------+ +---------+
7867// | | |
7868// | RestSubReq | |
7869// |---------------->| |
7870// | | |
7871// | RESTSubResp | |
7872// |<----------------| |
7873// | | |
7874// | | SubReq |
7875// | |------------->|
7876// | | |
7877// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007878// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007879// | | |
7880// | | SubReq |
7881// | |------------->|
7882// | | |
7883// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007884// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007885// | RESTNotif (fail)| |
7886// |<----------------| |
7887// | | SubDelReq |
7888// | |------------->|
7889// | | |
7890// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007891// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7892// | | |
7893// | | SubDelReq |
7894// | |------------->|
7895// | | |
7896// | | SubDelResp |
7897// | |<-------------| Ongoing transaction not found.
7898// | | |
7899// | [SUBS DELETE] |
7900// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007901//
7902//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007903
Anssi Mannila51122392021-05-25 11:51:31 +03007904func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007905
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007906 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007907
Anssi Mannila21782182021-12-10 10:56:02 +02007908 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7909 Counter{cRestSubReqFromXapp, 1},
7910 Counter{cRestSubRespToXapp, 1},
7911 Counter{cSubReqToE2, 1},
7912 Counter{cSubReqTimerExpiry, 2},
7913 Counter{cSubReReqToE2, 1},
7914 Counter{cSubFailFromE2, 2},
7915 Counter{cRestSubFailNotifToXapp, 1},
7916 Counter{cRestSubDelReqFromXapp, 1},
7917 Counter{cRestSubDelRespToXapp, 1},
7918 Counter{cSubDelReqToE2, 1},
7919 Counter{cSubDelReqTimerExpiry, 2},
7920 Counter{cSubDelReReqToE2, 1},
7921 Counter{cSubDelRespFromE2, 2},
7922 })
7923
Anssi Mannila51122392021-05-25 11:51:31 +03007924 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007925 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007926 restSubId := xappConn1.SendRESTSubsReq(t, params)
7927
7928 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7929
7930 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7931
7932 // No transaction exist for this response which will result resending original request
7933 fparams := &teststube2ap.E2StubSubsFailParams{}
7934 fparams.Set(crereq)
7935 e2termConn1.SendSubsFail(t, fparams, cremsg)
7936
7937 _, cremsg = e2termConn1.RecvSubsReq(t)
7938
Markku Virtanen55d2a282021-06-04 14:46:56 +03007939 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007940
7941 // Subscription already created in E2 Node.
7942 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7943 e2termConn1.SendSubsFail(t, fparams, cremsg)
7944
7945 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7946 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7947
7948 // Resending happens because there no transaction
7949 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7950 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7951
7952 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007953 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007954
Anssi Mannilab43397e2021-11-16 12:06:16 +02007955 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7956
Anssi Mannila51122392021-05-25 11:51:31 +03007957 // Wait that subs is cleaned
7958 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7959
7960 xappConn1.TestMsgChanEmpty(t)
7961 e2termConn1.TestMsgChanEmpty(t)
7962 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007963 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007964 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007965}
7966
7967//-----------------------------------------------------------------------------
7968// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7969//
7970// stub stub
7971// +-------+ +---------+ +---------+
7972// | xapp | | submgr | | e2term |
7973// +-------+ +---------+ +---------+
7974// | | |
7975// | [SUBS CREATE] |
7976// | | |
7977// | | |
7978// | RESTSubDelReq | |
7979// |---------------->| |
7980// | | |
7981// | RESTSubDelResp | |
7982// |<----------------| |
7983// | | |
7984// | | SubDelReq |
7985// | |------------->|
7986// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007987// | | SubDelResp | ASN.1 decode fails.
7988// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007989// | | |
7990// | | SubDelReq |
7991// | |------------->|
7992// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007993// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007994// | |<-------------|
7995// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007996// | [SUBS DELETE] |
7997// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007998//
7999//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008000
Anssi Mannila51122392021-05-25 11:51:31 +03008001func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008002
Anssi Mannila21782182021-12-10 10:56:02 +02008003 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8004 Counter{cRestSubReqFromXapp, 1},
8005 Counter{cRestSubRespToXapp, 1},
8006 Counter{cSubReqToE2, 1},
8007 Counter{cSubRespFromE2, 1},
8008 Counter{cRestSubNotifToXapp, 1},
8009 Counter{cRestSubDelReqFromXapp, 1},
8010 Counter{cRestSubDelRespToXapp, 1},
8011 Counter{cSubDelReqToE2, 1},
8012 Counter{cSubDelReqTimerExpiry, 1},
8013 Counter{cSubDelReReqToE2, 1},
8014 Counter{cSubDelFailFromE2, 1},
8015 Counter{cSubDelRespFromE2, 1},
8016 })
8017
Anssi Mannila51122392021-05-25 11:51:31 +03008018 // Req
8019 var params *teststube2ap.RESTSubsReqParams = nil
8020 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8021
8022 // Del
8023 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8024
8025 // E2t: Receive 1st SubsDelReq
8026 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8027
8028 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02008029 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03008030
8031 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8032 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8033
8034 // Subscription does not exist in in E2 Node.
8035 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8036
8037 // Wait that subs is cleaned
8038 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8039
8040 xappConn1.TestMsgChanEmpty(t)
8041 e2termConn1.TestMsgChanEmpty(t)
8042 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008043 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008044 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008045}
8046
8047//-----------------------------------------------------------------------------
8048// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
8049//
8050// stub stub
8051// +-------+ +---------+ +---------+
8052// | xapp | | submgr | | e2term |
8053// +-------+ +---------+ +---------+
8054// | | |
8055// | [SUBS CREATE] |
8056// | | |
8057// | | |
8058// | RESTSubDelReq | |
8059// |---------------->| |
8060// | | |
8061// | RESTSubDelResp | |
8062// |<----------------| |
8063// | | |
8064// | | SubDelReq |
8065// | |------------->|
8066// | | |
8067// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008068// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008069// | | |
8070// | | SubDelReq |
8071// | |------------->|
8072// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008073// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008074// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008075// | | |
8076// | [SUBS DELETE] |
8077// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008078//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008079
Anssi Mannila51122392021-05-25 11:51:31 +03008080func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008081
Anssi Mannila21782182021-12-10 10:56:02 +02008082 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8083 Counter{cRestSubReqFromXapp, 1},
8084 Counter{cRestSubRespToXapp, 1},
8085 Counter{cSubReqToE2, 1},
8086 Counter{cSubRespFromE2, 1},
8087 Counter{cRestSubNotifToXapp, 1},
8088 Counter{cRestSubDelReqFromXapp, 1},
8089 Counter{cRestSubDelRespToXapp, 1},
8090 Counter{cSubDelReqToE2, 1},
8091 Counter{cSubDelReqTimerExpiry, 1},
8092 Counter{cSubDelReReqToE2, 1},
8093 Counter{cSubDelRespFromE2, 1},
8094 Counter{cSubDelFailFromE2, 1},
8095 })
8096
Anssi Mannila51122392021-05-25 11:51:31 +03008097 // Req
8098 var params *teststube2ap.RESTSubsReqParams = nil
8099 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8100
8101 // Del
8102 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8103
8104 // E2t: Receive 1st SubsDelReq
8105 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8106
8107 // Unknown instanceId in this response which will result resending original request
8108 delreq.RequestId.InstanceId = 0
8109 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8110
8111 // E2t: Receive 2nd SubsDelReq
8112 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8113
8114 // Subscription does not exist in in E2 Node.
8115 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8116
8117 // Wait that subs is cleaned
8118 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8119
8120 xappConn1.TestMsgChanEmpty(t)
8121 e2termConn1.TestMsgChanEmpty(t)
8122 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008123 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008124 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008125}
8126
8127//-----------------------------------------------------------------------------
8128// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
8129//
8130// stub stub
8131// +-------+ +---------+ +---------+
8132// | xapp | | submgr | | e2term |
8133// +-------+ +---------+ +---------+
8134// | | |
8135// | [SUBS CREATE] |
8136// | | |
8137// | | |
8138// | RESTSubDelReq | |
8139// |---------------->| |
8140// | | |
8141// | RESTSubDelResp | |
8142// |<----------------| |
8143// | | |
8144// | | SubDelReq |
8145// | |------------->|
8146// | | |
8147// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008148// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008149// | | |
8150// | | SubDelReq |
8151// | |------------->|
8152// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008153// | | SubDelFail | Subscription does exist any more in E2 node
8154// | |<-------------| Ongoing transaction not found. This will result timer expiry
8155// | | |
8156// | [SUBS DELETE] |
8157// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008158//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008159
Anssi Mannila51122392021-05-25 11:51:31 +03008160func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008161
Anssi Mannila21782182021-12-10 10:56:02 +02008162 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8163 Counter{cRestSubReqFromXapp, 1},
8164 Counter{cRestSubRespToXapp, 1},
8165 Counter{cSubReqToE2, 1},
8166 Counter{cSubRespFromE2, 1},
8167 Counter{cRestSubNotifToXapp, 1},
8168 Counter{cRestSubDelReqFromXapp, 1},
8169 Counter{cRestSubDelRespToXapp, 1},
8170 Counter{cSubDelReqToE2, 1},
8171 Counter{cSubDelReqTimerExpiry, 2},
8172 Counter{cSubDelReReqToE2, 1},
8173 Counter{cSubDelRespFromE2, 1},
8174 Counter{cSubDelFailFromE2, 1},
8175 })
8176
Anssi Mannila51122392021-05-25 11:51:31 +03008177 // Req
8178 var params *teststube2ap.RESTSubsReqParams = nil
8179 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8180
8181 // Del
8182 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8183
8184 // E2t: Receive 1st SubsDelReq
8185 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8186
8187 mainCtrl.MakeTransactionNil(t, e2SubsId)
8188
8189 // No transaction exist for this response which will result resending original request
8190 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8191
8192 // E2t: Receive 2nd SubsDelReq
8193 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8194
8195 // Subscription does not exist in in E2 Node.
8196 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8197
8198 // Wait that subs is cleaned
8199 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8200
8201 xappConn1.TestMsgChanEmpty(t)
8202 e2termConn1.TestMsgChanEmpty(t)
8203 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008204 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008205 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008206}
8207
8208//-----------------------------------------------------------------------------
8209// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
8210//
8211// stub stub
8212// +-------+ +---------+ +---------+
8213// | xapp | | submgr | | e2term |
8214// +-------+ +---------+ +---------+
8215// | | |
8216// | [SUBS CREATE] |
8217// | | |
8218// | | |
8219// | RESTSubDelReq | |
8220// |---------------->| |
8221// | | |
8222// | RESTSubDelResp | |
8223// |<----------------| |
8224// | | |
8225// | | SubDelReq |
8226// | |------------->|
8227// | | |
8228// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02008229// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008230// | | |
8231// | | SubDelReq |
8232// | |------------->|
8233// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008234// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03008235// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02008236// | | |
8237// | [SUBS DELETE] |
8238// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008239//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008240
Anssi Mannila51122392021-05-25 11:51:31 +03008241func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008242
Anssi Mannila21782182021-12-10 10:56:02 +02008243 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8244 Counter{cRestSubReqFromXapp, 1},
8245 Counter{cRestSubRespToXapp, 1},
8246 Counter{cSubReqToE2, 1},
8247 Counter{cSubRespFromE2, 1},
8248 Counter{cRestSubNotifToXapp, 1},
8249 Counter{cRestSubDelReqFromXapp, 1},
8250 Counter{cRestSubDelRespToXapp, 1},
8251 Counter{cSubDelReqToE2, 1},
8252 Counter{cSubDelReqTimerExpiry, 1},
8253 Counter{cSubDelReReqToE2, 1},
8254 Counter{cSubDelFailFromE2, 2},
8255 })
8256
Anssi Mannila51122392021-05-25 11:51:31 +03008257 // Req
8258 var params *teststube2ap.RESTSubsReqParams = nil
8259 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8260
8261 // Del
8262 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8263
8264 // E2t: Receive 1st SubsDelReq
8265 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8266
8267 // Decode of this response fails which will result resending original request
8268 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
8269
8270 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
8271 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8272
8273 // Subscription does not exist in in E2 Node.
8274 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8275
8276 // Wait that subs is cleaned
8277 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8278
8279 xappConn1.TestMsgChanEmpty(t)
8280 e2termConn1.TestMsgChanEmpty(t)
8281 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008282 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008283 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008284}
8285
8286//-----------------------------------------------------------------------------
8287// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8288//
8289// stub stub
8290// +-------+ +---------+ +---------+
8291// | xapp | | submgr | | e2term |
8292// +-------+ +---------+ +---------+
8293// | | |
8294// | [SUBS CREATE] |
8295// | | |
8296// | | |
8297// | RESTSubDelReq | |
8298// |---------------->| |
8299// | | |
8300// | RESTSubDelResp | |
8301// |<----------------| |
8302// | | |
8303// | | SubDelReq |
8304// | |------------->|
8305// | | |
8306// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008307// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008308// | | |
8309// | | SubDelReq |
8310// | |------------->|
8311// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008312// | | SubDelFail | Subscription does exist any more in E2 node
8313// | |<-------------| No valid subscription found with subIds [0].
8314// | | |
8315// | [SUBS DELETE] |
8316// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008317//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008318
Anssi Mannila51122392021-05-25 11:51:31 +03008319func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008320
Anssi Mannila21782182021-12-10 10:56:02 +02008321 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8322 Counter{cRestSubReqFromXapp, 1},
8323 Counter{cRestSubRespToXapp, 1},
8324 Counter{cSubReqToE2, 1},
8325 Counter{cSubRespFromE2, 1},
8326 Counter{cRestSubNotifToXapp, 1},
8327 Counter{cRestSubDelReqFromXapp, 1},
8328 Counter{cRestSubDelRespToXapp, 1},
8329 Counter{cSubDelReqToE2, 1},
8330 Counter{cSubDelReqTimerExpiry, 1},
8331 Counter{cSubDelReReqToE2, 1},
8332 Counter{cSubDelFailFromE2, 2},
8333 })
8334
Anssi Mannila51122392021-05-25 11:51:31 +03008335 // Req
8336 var params *teststube2ap.RESTSubsReqParams = nil
8337 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8338
8339 // Del
8340 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8341
8342 // E2t: Receive 1st SubsDelReq
8343 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8344
Anssi Mannila21782182021-12-10 10:56:02 +02008345 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008346 delreq.RequestId.InstanceId = 0
8347 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8348
8349 // E2t: Receive 2nd SubsDelReq
8350 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8351
Anssi Mannila21782182021-12-10 10:56:02 +02008352 // 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 +03008353 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8354
8355 // Wait that subs is cleaned
8356 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8357
8358 xappConn1.TestMsgChanEmpty(t)
8359 e2termConn1.TestMsgChanEmpty(t)
8360 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008361 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008362 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008363}
8364
8365//-----------------------------------------------------------------------------
8366// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8367//
8368// stub stub
8369// +-------+ +---------+ +---------+
8370// | xapp | | submgr | | e2term |
8371// +-------+ +---------+ +---------+
8372// | | |
8373// | [SUBS CREATE] |
8374// | | |
8375// | | |
8376// | RESTSubDelReq | |
8377// |---------------->| |
8378// | | |
8379// | RESTSubDelResp | |
8380// |<----------------| |
8381// | | |
8382// | | SubDelReq |
8383// | |------------->|
8384// | | |
8385// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008386// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008387// | | |
8388// | | SubDelReq |
8389// | |------------->|
8390// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008391// | | SubDelFail | Subscription does exist any more in E2 node
8392// | |<-------------| Ongoing transaction not found. This will result timer expiry
8393// | | |
8394// | [SUBS DELETE] |
8395// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008396//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008397
Anssi Mannila51122392021-05-25 11:51:31 +03008398func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008399
Anssi Mannila21782182021-12-10 10:56:02 +02008400 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8401 Counter{cRestSubReqFromXapp, 1},
8402 Counter{cRestSubRespToXapp, 1},
8403 Counter{cSubReqToE2, 1},
8404 Counter{cSubRespFromE2, 1},
8405 Counter{cRestSubNotifToXapp, 1},
8406 Counter{cRestSubDelReqFromXapp, 1},
8407 Counter{cRestSubDelRespToXapp, 1},
8408 Counter{cSubDelReqToE2, 1},
8409 Counter{cSubDelReqTimerExpiry, 2},
8410 Counter{cSubDelReReqToE2, 1},
8411 Counter{cSubDelFailFromE2, 2},
8412 })
8413
Anssi Mannila51122392021-05-25 11:51:31 +03008414 // Req
8415 var params *teststube2ap.RESTSubsReqParams = nil
8416 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8417
8418 // Del
8419 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8420
8421 // E2t: Receive 1st SubsDelReq
8422 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8423
8424 mainCtrl.MakeTransactionNil(t, e2SubsId)
8425
8426 // No transaction exist for this response which will result resending original request
8427 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8428
8429 // E2t: Receive 2nd SubsDelReq
8430 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8431
8432 // Subscription does not exist in in E2 Node.
8433 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8434
8435 // Wait that subs is cleaned
8436 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8437
8438 xappConn1.TestMsgChanEmpty(t)
8439 e2termConn1.TestMsgChanEmpty(t)
8440 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008441 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008442 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008443}
8444
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008445//-----------------------------------------------------------------------------
8446// TestRESTSubReqFailAsn1PackSubReqError
8447//
8448// stub stub
8449// +-------+ +---------+ +---------+
8450// | xapp | | submgr | | e2term |
8451// +-------+ +---------+ +---------+
8452// | | |
8453// | RESTSubReq | |
8454// |---------------->| |
8455// | | |
8456// | RESTSubResp | |
8457// |<----------------| |
8458// | | |
8459// | ASN.1 encode fails |
8460// | | |
8461// | | SubDelReq |
8462// | |------------->|
8463// | | |
8464// | | SubDelFail |
8465// | |<-------------|
8466// | | |
8467// | RESTNotif | |
8468// | unsuccess | |
8469// |<----------------| |
8470// | | |
8471// | [SUBS DELETE] |
8472// | | |
8473//
8474//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008475
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008476func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8477
8478 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008479 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008480 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008481 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008482 Counter{cRestSubDelReqFromXapp, 1},
8483 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008484 })
8485
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008486 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008487
8488 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008489 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008490 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8491
8492 // Req
8493 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008494 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008495
8496 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008497 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008498
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008499 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008500 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008501
8502 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008503
8504 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8505
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008506 // Wait that subs is cleaned
8507 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008508 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008509 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008510}
8511
Anssi Mannila27385172021-12-22 09:41:54 +02008512//-----------------------------------------------------------------------------
8513// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8514//
8515// stub stub
8516// +-------+ +---------+ +---------+
8517// | xapp | | submgr | | e2term |
8518// +-------+ +---------+ +---------+
8519// | | |
8520// | RESTSubReq | |
8521// |---------------->| |
8522// | | |
8523// | RESTSubResp | |
8524// |<----------------| |
8525// | | SubReq |
8526// | |------------->|
8527// | | |
8528// | | SubResp |
8529// | |<-------------|
8530// | | |
8531// | RESTNotif | |
8532// |<----------------| |
8533// | | |
8534// | RESTSubReq | | Policy modification
8535// |---------------->| |
8536// | | |
8537// | RESTSubResp | |
8538// |<----------------| |
8539// | | SubReq |
8540// | |------------->|
8541// | | |
8542// | | |
8543// | RESTNotif(Unsuccessful) | E2 timeout
8544// |<----------------| |
8545// | | |
8546// | RESTSubDelReq | |
8547// |---------------->| |
8548// | | |
8549// | | SubDelReq |
8550// | |------------->|
8551// | | |
8552// | | SubDelResp |
8553// | |<-------------|
8554// | | |
8555// | RESTSubDelResp | |
8556// |<----------------| |
8557//
8558//-----------------------------------------------------------------------------
8559
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008560func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008561
8562 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8563 Counter{cRestSubReqFromXapp, 2},
8564 Counter{cRestSubRespToXapp, 2},
8565 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008566 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008567 Counter{cSubRespFromE2, 1},
8568 Counter{cRestSubNotifToXapp, 1},
8569 Counter{cRestSubFailNotifToXapp, 1},
8570 Counter{cRestSubDelReqFromXapp, 1},
8571 Counter{cSubDelReqToE2, 1},
8572 Counter{cSubDelRespFromE2, 1},
8573 Counter{cRestSubDelRespToXapp, 1},
8574 })
8575
8576 const e2Timeout int64 = 1
8577 const e2RetryCount int64 = 0
8578 const routingNeeded bool = false
8579
8580 // Req1
8581 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8582 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8583
8584 // Subs Create
8585 restSubId := xappConn1.SendRESTSubsReq(t, params)
8586 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8587
8588 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8589 xappConn1.ExpectRESTNotification(t, restSubId)
8590 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8591 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8592 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8593
8594 // Policy change
8595 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8596 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8597 params.SetSubscriptionID(&restSubId)
8598 params.SetTimeToWait("w200ms")
8599 restSubId = xappConn1.SendRESTSubsReq(t, params)
8600 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8601
8602 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8603 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008604 // SubsResp is missing, e2SubsId will be 0
8605 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8606 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008607
8608 // Del
8609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8610 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8611 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8612
8613 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008614 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008615 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008616}
8617
8618//-----------------------------------------------------------------------------
8619// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8620//
8621// stub stub
8622// +-------+ +---------+ +---------+
8623// | xapp | | submgr | | e2term |
8624// +-------+ +---------+ +---------+
8625// | | |
8626// | RESTSubReq | |
8627// |---------------->| |
8628// | | |
8629// | RESTSubResp | |
8630// |<----------------| |
8631// | | SubReq |
8632// | |------------->|
8633// | | |
8634// | | SubResp |
8635// | |<-------------|
8636// | | |
8637// | RESTNotif | |
8638// |<----------------| |
8639// | | |
8640// | RESTSubReq | |
8641// |---------------->| |
8642// | | |
8643// | RESTSubResp | |
8644// |<----------------| |
8645// | | SubReq |
8646// | |------------->|
8647// | |
8648// | Submgr restart |
8649// | | |
8650// | RESTSubDelReq | |
8651// |---------------->| |
8652// | | |
8653// | | SubDelReq |
8654// | |------------->|
8655// | | |
8656// | | SubDelResp |
8657// | |<-------------|
8658// | | |
8659// | RESTSubDelResp | |
8660// |<----------------| |
8661//
8662//-----------------------------------------------------------------------------
8663
8664func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008665
8666 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8667 Counter{cRestSubReqFromXapp, 2},
8668 Counter{cRestSubRespToXapp, 2},
8669 Counter{cSubReqToE2, 2},
8670 Counter{cSubRespFromE2, 1},
8671 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008672 Counter{cRestSubDelReqFromXapp, 1},
8673 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008674 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008675 Counter{cRestSubDelRespToXapp, 1},
8676 })
8677
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008678 const e2Timeout int64 = 1
8679 const e2RetryCount int64 = 0
8680 const routingNeeded bool = false
8681
8682 // Req1
8683 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8684 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8685 // Create subscription
8686 restSubId := xappConn1.SendRESTSubsReq(t, params)
8687 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8688
8689 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8690 xappConn1.ExpectRESTNotification(t, restSubId)
8691 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8692 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8693 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8694
8695 // Check subscription
8696 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8697
8698 // Policy change
8699 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8700 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8701 params.SetSubscriptionID(&restSubId)
8702 params.SetTimeToWait("w200ms")
8703 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8704 restSubId = xappConn1.SendRESTSubsReq(t, params)
8705 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8706
8707 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8708 mainCtrl.SetResetTestFlag(t, false)
8709
8710 // SubsResp is missing due to submgr restart
8711
8712 mainCtrl.SimulateRestart(t)
8713 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8714
Anssi Mannila54838ed2021-11-19 11:25:01 +02008715 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8716 // That needs to be completed before successful subscription query is possible
8717 <-time.After(time.Second * 1)
8718
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008719 // Check subscription
8720 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8721
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008722 // Delete subscription
8723 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8724 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8725 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8726
8727 //Wait that subs is cleaned
8728 waitSubsCleanup(t, e2SubsId, 10)
8729
8730 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008731 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008732}
8733
archaggeafbf95f2021-04-14 08:54:05 +03008734////////////////////////////////////////////////////////////////////////////////////
8735// Services for UT cases
8736////////////////////////////////////////////////////////////////////////////////////
8737const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008738const host string = "localhost"
8739
8740func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8741 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008742 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008743 }
8744 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008745 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008746
8747 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8748 fromXappConn.ExpectRESTNotification(t, restSubId)
8749 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8750 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008751 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008752
8753 return restSubId, e2SubsId
8754}
8755
8756func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8757
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008758 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008759 if meid != "" {
8760 params.SetMeid(meid)
8761 }
8762 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8763 restSubId := xappConn2.SendRESTSubsReq(t, params)
8764 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008765 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008766 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008767 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008768
8769 return restSubId, e2SubsId
8770}
8771
8772func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008773
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008774 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008775 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008776 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008777
8778 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8779 xappConn1.ExpectRESTNotification(t, restSubId)
8780 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8781 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008782 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008783
8784 return restSubId, e2SubsId
8785}
8786
8787func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008788 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008789 restSubId := xappConn1.SendRESTSubsReq(t, params)
8790
8791 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8792 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8793 fparams1.Set(crereq1)
8794 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8795
8796 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8797 xappConn1.ExpectRESTNotification(t, restSubId)
8798 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8799 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008800 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008801
8802 return restSubId, e2SubsId
8803}
8804
8805func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8806 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8807 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8808 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8809}
8810
8811func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8812 xappConn1.SendRESTSubsDelReq(t, restSubId)
8813 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8814 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8815}
8816
8817func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8818 xappConn2.SendRESTSubsDelReq(t, restSubId)
8819 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8820 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8821}
8822
8823func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8824 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008825 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8826 assert.Equal(t, meid, resp[0].Meid)
8827 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008828}
8829
8830func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8831 //Wait that subs is cleaned
8832 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8833
8834 xappConn1.TestMsgChanEmpty(t)
8835 xappConn2.TestMsgChanEmpty(t)
8836 e2termConn1.TestMsgChanEmpty(t)
8837 mainCtrl.wait_registry_empty(t, timeout)
8838}
8839
8840func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8841
8842 var e2SubsId []uint32
8843
8844 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008845 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008846 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8847 fromXappConn.ExpectRESTNotification(t, restSubId)
8848 toE2termConn.SendSubsResp(t, crereq, cremsg)
8849 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8850 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008851 xapp.Logger.Debug("TEST: %v", e2SubsId)
8852 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008853 <-time.After(100 * time.Millisecond)
8854 }
8855 return e2SubsId
8856}
8857
8858func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8859
8860 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008861 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008862 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8863 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8864 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008865 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008866 <-time.After(100 * time.Millisecond)
8867 }
8868
8869 // Wait that subs is cleaned
8870 for i := 0; i < len(e2SubsIds); i++ {
8871 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8872 }
8873
8874}