blob: 23a12a9d6bac9dbd0905f186c018a4c3c2ef5776 [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030023 //"os"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000024 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020025 "testing"
26 "time"
27
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030030 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020031 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020032 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020034)
35
Markku Virtanenac8bde42021-05-25 09:54:42 +000036func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030037 // The effect of this call shall endure though the UT suite!
38 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000039 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000040 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
41
Anssi Mannila3d80b722021-11-12 13:17:15 +020042 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000043 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030044 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000045
Markku Virtanenac8bde42021-05-25 09:54:42 +000046}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030047func TestRanStatusChangeViaSDLNotification(t *testing.T) {
48
49 // Current UT test cases use these ran names
50 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
51 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
52 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
53
54 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
55 mainCtrl.c.e2IfState.SubscribeChannels()
56
57 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
58 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
59 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
60}
61
62//-----------------------------------------------------------------------------
63// TestRESTSubReqAfterE2ConnBreak
64//
65// stub stub
66// +-------+ +---------+ +---------+
67// | xapp | | submgr | | e2term |
68// +-------+ +---------+ +---------+
69// | | |
70// | [E2 Conn. DOWN] |
71// | | |
72// | RESTSubReq | |
73// |---------------->| |
74// | RESTSubFail | |
75// |<----------------| |
76// | | |
77//
78//-----------------------------------------------------------------------------
79
80func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
81 CaseBegin("TestRESTSubReqAfterE2ConnBreak")
82
83 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
84 Counter{cRestSubReqFromXapp, 1},
85 Counter{cRestReqRejDueE2Down, 1},
86 })
87
88 // E2 disconnect after E2term has received response
89 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
90 // Req
91 const subReqCount int = 1
92 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
93 xappConn1.SendRESTSubsReq(t, params)
94
95 // Restore E2 connection for following test cases
96 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
97
98 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +020099 mainCtrl.VerifyAllClean(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +0200100 //os.Exit(0)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300101}
102
103//-----------------------------------------------------------------------------
104// TestRESTSubReqE2ConnBreak
105//
106// stub stub
107// +-------+ +---------+ +---------+
108// | xapp | | submgr | | e2term |
109// +-------+ +---------+ +---------+
110// | | |
111// | RESTSubReq | |
112// |---------------->| |
113// | RESTSubResp | |
114// |<----------------| |
115// | | SubReq |
116// | |------------->|
117// | | SubResp |
118// | |<-------------|
119// | | |
120// | [E2 Conn. DOWN] |
121// | [Int. SUBS DELETE] |
122// | | |
123// | RESTNotif(unsuccessful) |
124// |<----------------| |
125// | | |
126// | | |
127//
128//-----------------------------------------------------------------------------
129func TestRESTSubReqE2ConnBreak(t *testing.T) {
130 CaseBegin("TestRESTSubReqE2ConnBreak")
131
132 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
133 Counter{cRestSubReqFromXapp, 1},
134 Counter{cRestSubRespToXapp, 1},
135 Counter{cSubReqToE2, 1},
136 Counter{cSubRespFromE2, 1},
137 Counter{cRestSubFailNotifToXapp, 1},
138 })
139
140 // Req
141 const subReqCount int = 1
142 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
143 restSubId := xappConn1.SendRESTSubsReq(t, params)
144
145 crereq, cremsg := e2termConn1.RecvSubsReq(t)
146 xappConn1.ExpectRESTNotification(t, restSubId)
147
148 // E2 disconnect after E2term has received response
149 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
150
151 e2termConn1.SendSubsResp(t, crereq, cremsg)
152 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
153
154 <-time.After(time.Second * 1)
155 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
156 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
157
158 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
159 if err != nil {
160 xapp.Logger.Error("%v", err)
161 } else {
162 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
163 assert.Equal(t, 0, len(register))
164 }
165
166 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
167 if err != nil {
168 xapp.Logger.Error("%v", err)
169 } else {
170 assert.Equal(t, 0, len(restSubscriptions))
171 }
172
173 // Restore E2 connection for following test cases
174 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
175
176 // Wait that subs is cleaned
177 waitSubsCleanup(t, e2SubsId, 10)
178 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200179 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300180}
181
182//-----------------------------------------------------------------------------
183// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
184//
185// stub stub
186// +-------+ +---------+ +---------+
187// | xapp | | submgr | | e2term |
188// +-------+ +---------+ +---------+
189// | | |
190// | [SUBS CREATE] |
191// | | |
192// | [E2 Conn. DOWN] |
193// | | |
194// | RESTSubDelReq | |
195// |---------------->| |
196// | | |
197// | RESTSubDelResp | |
198// |<----------------| |
199// | | |
200// | [No valid subscription found] |
201// | | |
202//
203//-----------------------------------------------------------------------------
204func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
205 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
206
207 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
208 Counter{cRestSubReqFromXapp, 1},
209 Counter{cRestSubRespToXapp, 1},
210 Counter{cSubReqToE2, 1},
211 Counter{cSubRespFromE2, 1},
212 Counter{cRestSubNotifToXapp, 1},
213 Counter{cRestSubDelReqFromXapp, 1},
214 Counter{cRestSubDelRespToXapp, 1},
215 })
216
217 // Req
218 var params *teststube2ap.RESTSubsReqParams = nil
219 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
220
221 // E2 disconnect after E2term has received response
222 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
223
224 // Del
225 xappConn1.SendRESTSubsDelReq(t, &restSubId)
226
227 <-time.After(time.Second * 1)
228 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
229 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
230
231 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
232 if err != nil {
233 xapp.Logger.Error("%v", err)
234 } else {
235 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
236 assert.Equal(t, 0, len(register))
237 }
238
239 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
240 if err != nil {
241 xapp.Logger.Error("%v", err)
242 } else {
243 assert.Equal(t, 0, len(restSubscriptions))
244 }
245
246 // Restore E2 connection for following test cases
247 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
248
249 // Wait that subs is cleaned
250 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
251
252 xappConn1.TestMsgChanEmpty(t)
253 e2termConn1.TestMsgChanEmpty(t)
254 mainCtrl.wait_registry_empty(t, 10)
255 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200256 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300257}
258
259//-----------------------------------------------------------------------------
260// TestRESTOtherE2ConnectionChanges
261//
262
263// stub stub
264// +-------+ +---------+ +---------+
265// | xapp | | submgr | | e2term |
266// +-------+ +---------+ +---------+
267// | | |
268// | [SUBS CREATE] |
269// | | |
270// | [E2 CONNECTED_SETUP_FAILED] |
271// | [E2 CONNECTING] |
272// | [E2 SHUTTING_DOWN] |
273// | [E2 SHUT_DOWN] |
274// | | |
275// | [SUBS DELETE] |
276// | | |
277//
278//-----------------------------------------------------------------------------
279func TestRESTOtherE2ConnectionChanges(t *testing.T) {
280 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
281
282 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
283 Counter{cRestSubReqFromXapp, 1},
284 Counter{cRestSubRespToXapp, 1},
285 Counter{cSubReqToE2, 1},
286 Counter{cSubRespFromE2, 1},
287 Counter{cRestSubNotifToXapp, 1},
288 Counter{cRestSubDelReqFromXapp, 1},
289 Counter{cSubDelReqToE2, 1},
290 Counter{cSubDelRespFromE2, 1},
291 Counter{cRestSubDelRespToXapp, 1},
292 })
293
294 // Req
295 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
296 restSubId := xappConn1.SendRESTSubsReq(t, params)
297
298 crereq, cremsg := e2termConn1.RecvSubsReq(t)
299 xappConn1.ExpectRESTNotification(t, restSubId)
300 e2termConn1.SendSubsResp(t, crereq, cremsg)
301 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
302
303 // Submgr should not react any other connection state changes than CONNECTED and DISCONNECTED
304 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
305 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
306 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
307 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
308
309 // Del
310 xappConn1.SendRESTSubsDelReq(t, &restSubId)
311 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
312 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
313
314 // Restore E2 connection for following test cases
315 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
316
317 // Wait that subs is cleaned
318 waitSubsCleanup(t, e2SubsId, 10)
319 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200320 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300321}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000322
323//-----------------------------------------------------------------------------
324// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
325//
326// stub stub stub
327// +-------+ +---------+ +---------+ +---------+
328// | xapp | | submgr | | e2term | | rtmgr |
329// +-------+ +---------+ +---------+ +---------+
330// | | | |
331// | RESTSubReq | | |
332// |---------------->| | |
333// | | RouteCreate | |
334// | |--------------------------->| // The order of these events may vary
335// | | | |
336// | RESTSubResp | | | // The order of these events may vary
337// |<----------------| | |
338// | | RouteResponse| |
339// | |<---------------------------| // The order of these events may vary
340// | | | |
341// | | SubReq | |
342// | |------------->| | // The order of these events may vary
343// | | | |
344// | | SubResp | |
345// | |<-------------| |
346// | RESTNotif1 | | |
347// |<----------------| | |
348// | | | |
349// | RESTSubDelReq | | |
350// |---------------->| | |
351// | | SubDelReq | |
352// | |------------->| |
353// | | | |
354// | RESTSubDelResp| | |
355// |<----------------| | |
356// | | | |
357// | | SubDelResp | |
358// | |<-------------| |
359// | | | |
360// | | | |
361//
362//-----------------------------------------------------------------------------
363func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000364
365 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
366
367 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
368
369 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200370 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000371}
372
Juha Hyttinenfa015662020-01-24 10:05:18 +0200373//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000374// TestRESTSubReqAndE1apDeleteReqPackingError
375//
376// stub stub stub
377// +-------+ +---------+ +---------+ +---------+
378// | xapp | | submgr | | e2term | | rtmgr |
379// +-------+ +---------+ +---------+ +---------+
380// | | | |
381// | RESTSubReq | | |
382// |---------------->| | |
383// | | RouteCreate | |
384// | |--------------------------->| // The order of these events may vary
385// | | | |
386// | RESTSubResp | | | // The order of these events may vary
387// |<----------------| | |
388// | | RouteResponse| |
389// | |<---------------------------| // The order of these events may vary
390// | | | |
391// | | SubReq | |
392// | |------------->| | // The order of these events may vary
393// | | | |
394// | | SubResp | |
395// | |<-------------| |
396// | RESTNotif1 | | |
397// |<----------------| | |
398// | | | |
399// | RESTSubDelReq | | |
400// |---------------->| | |
401// | | | |
402// | RESTSubDelResp| | |
403// |<----------------| | |
404// | | | |
405// | | | |
406//
407//-----------------------------------------------------------------------------
408func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
409
410 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
411
412 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
413 xappConn1.SendRESTSubsDelReq(t, &restSubId)
414 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
415
416 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200417 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000418}
419
420//-----------------------------------------------------------------------------
421// TestRESTSubReqAndE1apDeleteRespUnpackingError
422//
423// stub stub stub
424// +-------+ +---------+ +---------+ +---------+
425// | xapp | | submgr | | e2term | | rtmgr |
426// +-------+ +---------+ +---------+ +---------+
427// | | | |
428// | RESTSubReq | | |
429// |---------------->| | |
430// | | RouteCreate | |
431// | |--------------------------->| // The order of these events may vary
432// | | | |
433// | RESTSubResp | | | // The order of these events may vary
434// |<----------------| | |
435// | | RouteResponse| |
436// | |<---------------------------| // The order of these events may vary
437// | | | |
438// | | SubReq | |
439// | |------------->| | // The order of these events may vary
440// | | | |
441// | | SubResp | |
442// | |<-------------| |
443// | RESTNotif1 | | |
444// |<----------------| | |
445// | | | |
446// | RESTSubDelReq | | |
447// |---------------->| | |
448// | | SubDelReq | |
449// | |------------->| |
450// | | | |
451// | RESTSubDelResp| | |
452// |<----------------| | | // The order of these events may vary
453// | | | |
454// | | SubDelResp | |
455// | |<-------------| | // 1.st NOK
456// | | | |
457// | | SubDelReq | |
458// | |------------->| |
459// | | | |
460// | | SubDelResp | |
461// | |<-------------| | // 2.nd NOK
462//
463//-----------------------------------------------------------------------------
464
465func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
466
467 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
468
469 xappConn1.SendRESTSubsDelReq(t, &restSubId)
470 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
471 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
472 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
473
474 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
475 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
476
477 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
478
479 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200480 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000481}
482
483//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200484// TestSubReqAndRouteNok
485//
486// stub stub
487// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200488// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200489// +-------+ +---------+ +---------+
490// | | |
491// | SubReq | |
492// |------------->| |
493// | | |
494// | | RouteCreate |
495// | |------------->|
496// | | |
497// | | RouteCreate |
498// | | status:400 |
499// | |<-------------|
500// | | |
501// | [SUBS INT DELETE] |
502// | | |
503//
504//-----------------------------------------------------------------------------
505
506func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200507 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200508
Anssi Mannila4abf1802021-01-28 13:06:46 +0200509 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200510 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
511 Counter{cSubReqFromXapp, 1},
512 Counter{cRouteCreateFail, 1},
513 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200514
Juha Hyttinenfa015662020-01-24 10:05:18 +0200515 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300516 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200517 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200518 waiter.WaitResult(t)
519
520 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200521 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200522
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200523 xappConn1.TestMsgChanEmpty(t)
524 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200525 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200526 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200527
528 <-time.After(1 * time.Second)
529 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200530}
531
532//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200533// TestSubReqAndRouteUpdateNok
534
535// stub stub
536// +-------+ +-------+ +---------+ +---------+
537// | xapp2 | | xapp1 | | submgr | | rtmgr |
538// +-------+ +-------+ +---------+ +---------+
539// | | | |
540// | [SUBS CREATE] | |
541// | | | |
542// | | | |
543// | | | |
544// | SubReq (mergeable) | |
545// |--------------------------->| | |
546// | | | |
547// | | | RouteUpdate |
548// | | |------------->|
549// | | | |
550// | | | RouteUpdate |
551// | | | status:400 |
552// | | |<-------------|
553// | | | |
554// | [SUBS INT DELETE] | |
555// | | | |
556// | | | |
557// | [SUBS DELETE] | |
558// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300559
Anssi Mannila4abf1802021-01-28 13:06:46 +0200560func TestSubReqAndRouteUpdateNok(t *testing.T) {
561 CaseBegin("TestSubReqAndRouteUpdateNok")
562
563 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200564 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
565 Counter{cSubReqFromXapp, 2},
566 Counter{cSubReqToE2, 1},
567 Counter{cSubRespFromE2, 1},
568 Counter{cSubRespToXapp, 1},
569 Counter{cRouteCreateUpdateFail, 1},
570 Counter{cSubDelReqFromXapp, 1},
571 Counter{cSubDelReqToE2, 1},
572 Counter{cSubDelRespFromE2, 1},
573 Counter{cSubDelRespToXapp, 1},
574 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200575
576 cretrans := xappConn1.SendSubsReq(t, nil, nil)
577 crereq, cremsg := e2termConn1.RecvSubsReq(t)
578 e2termConn1.SendSubsResp(t, crereq, cremsg)
579 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
580
581 resp, _ := xapp.Subscription.QuerySubscriptions()
582 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
583 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300584 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200585
586 waiter := rtmgrHttp.AllocNextEvent(false)
587 newSubsId := mainCtrl.get_registry_next_subid(t)
588 xappConn2.SendSubsReq(t, nil, nil)
589 waiter.WaitResult(t)
590
591 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
592 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
593
594 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
595 xappConn1.RecvSubsDelResp(t, deltrans)
596
597 //Wait that subs is cleaned
598 mainCtrl.wait_subs_clean(t, newSubsId, 10)
599 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
600
601 xappConn1.TestMsgChanEmpty(t)
602 xappConn2.TestMsgChanEmpty(t)
603 e2termConn1.TestMsgChanEmpty(t)
604 mainCtrl.wait_registry_empty(t, 10)
605
606 mainCtrl.VerifyCounterValues(t)
607}
608
609//-----------------------------------------------------------------------------
610// TestSubDelReqAndRouteDeleteNok
611//
612// stub stub
613// +-------+ +---------+ +---------+ +---------+
614// | xapp | | submgr | | e2term | | rtmgr |
615// +-------+ +---------+ +---------+ +---------+
616// | | | |
617// | [SUBS CREATE] | |
618// | | | |
619// | | | |
620// | | | |
621// | SubDelReq | | |
622// |------------->| | |
623// | | SubDelReq | |
624// | |------------->| |
625// | | SubDelRsp | |
626// | |<-------------| |
627// | SubDelRsp | | |
628// |<-------------| | |
629// | | RouteDelete | |
630// | |---------------------------->|
631// | | | |
632// | | RouteDelete | |
633// | | status:400 | |
634// | |<----------------------------|
635// | | | |
636func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
637 CaseBegin("TestSubDelReqAndRouteDeleteNok")
638
639 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200640 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
641 Counter{cSubReqFromXapp, 1},
642 Counter{cSubReqToE2, 1},
643 Counter{cSubRespFromE2, 1},
644 Counter{cSubRespToXapp, 1},
645 Counter{cSubDelReqFromXapp, 1},
646 Counter{cRouteDeleteFail, 1},
647 Counter{cSubDelReqToE2, 1},
648 Counter{cSubDelRespFromE2, 1},
649 Counter{cSubDelRespToXapp, 1},
650 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200651
652 cretrans := xappConn1.SendSubsReq(t, nil, nil)
653 crereq, cremsg := e2termConn1.RecvSubsReq(t)
654 e2termConn1.SendSubsResp(t, crereq, cremsg)
655 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
656
657 resp, _ := xapp.Subscription.QuerySubscriptions()
658 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
659 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300660 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200661
662 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
663 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
664
665 waiter := rtmgrHttp.AllocNextEvent(false)
666 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
667 waiter.WaitResult(t)
668
669 xappConn1.RecvSubsDelResp(t, deltrans)
670
671 //Wait that subs is cleaned
672 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
673
674 xappConn1.TestMsgChanEmpty(t)
675 xappConn2.TestMsgChanEmpty(t)
676 e2termConn1.TestMsgChanEmpty(t)
677 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200678 mainCtrl.VerifyCounterValues(t)
679}
680
681//-----------------------------------------------------------------------------
682// TestSubMergeDelAndRouteUpdateNok
683// stub stub
684// +-------+ +-------+ +---------+ +---------+
685// | xapp2 | | xapp1 | | submgr | | e2term |
686// +-------+ +-------+ +---------+ +---------+
687// | | | |
688// | | | |
689// | | | |
690// | | SubReq1 | |
691// | |------------->| |
692// | | | |
693// | | | SubReq1 |
694// | | |------------->|
695// | | | SubResp1 |
696// | | |<-------------|
697// | | SubResp1 | |
698// | |<-------------| |
699// | | | |
700// | SubReq2 | |
701// |--------------------------->| |
702// | | | |
703// | SubResp2 | |
704// |<---------------------------| |
705// | | | |
706// | | SubDelReq 1 | |
707// | |------------->| |
708// | | | RouteUpdate |
709// | | |-----> rtmgr |
710// | | | |
711// | | | RouteUpdate |
712// | | | status:400 |
713// | | |<----- rtmgr |
714// | | | |
715// | | SubDelResp 1 | |
716// | |<-------------| |
717// | | | |
718// | SubDelReq 2 | |
719// |--------------------------->| |
720// | | | |
721// | | | SubDelReq 2 |
722// | | |------------->|
723// | | | |
724// | | | SubDelReq 2 |
725// | | |------------->|
726// | | | |
727// | SubDelResp 2 | |
728// |<---------------------------| |
729//
730//-----------------------------------------------------------------------------
731func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
732 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
733
734 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200735 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
736 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200737 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200738 Counter{cSubReqToE2, 1},
739 Counter{cSubRespFromE2, 1},
740 Counter{cSubRespToXapp, 2},
741 Counter{cSubDelReqFromXapp, 2},
742 Counter{cRouteDeleteUpdateFail, 1},
743 Counter{cSubDelReqToE2, 1},
744 Counter{cSubDelRespFromE2, 1},
745 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200746 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200747 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200748
749 //Req1
750 rparams1 := &teststube2ap.E2StubSubsReqParams{}
751 rparams1.Init()
752 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
753 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
754 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
755 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
756
757 //Req2
758 rparams2 := &teststube2ap.E2StubSubsReqParams{}
759 rparams2.Init()
760 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
761 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
762
763 resp, _ := xapp.Subscription.QuerySubscriptions()
764 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
765 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300766 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200767
768 //Del1
769 waiter := rtmgrHttp.AllocNextEvent(false)
770 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
771 waiter.WaitResult(t)
772
773 xappConn1.RecvSubsDelResp(t, deltrans1)
774
775 //Del2
776 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
777 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
778 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
779 xappConn2.RecvSubsDelResp(t, deltrans2)
780 //Wait that subs is cleaned
781 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
782
783 xappConn1.TestMsgChanEmpty(t)
784 xappConn2.TestMsgChanEmpty(t)
785 e2termConn1.TestMsgChanEmpty(t)
786 mainCtrl.wait_registry_empty(t, 10)
787
788 mainCtrl.VerifyCounterValues(t)
789}
790
791//-----------------------------------------------------------------------------
792
793//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200794// TestSubReqAndSubDelOk
795//
796// stub stub
797// +-------+ +---------+ +---------+
798// | xapp | | submgr | | e2term |
799// +-------+ +---------+ +---------+
800// | | |
801// | SubReq | |
802// |------------->| |
803// | | |
804// | | SubReq |
805// | |------------->|
806// | | |
807// | | SubResp |
808// | |<-------------|
809// | | |
810// | SubResp | |
811// |<-------------| |
812// | | |
813// | | |
814// | SubDelReq | |
815// |------------->| |
816// | | |
817// | | SubDelReq |
818// | |------------->|
819// | | |
820// | | SubDelResp |
821// | |<-------------|
822// | | |
823// | SubDelResp | |
824// |<-------------| |
825//
826//-----------------------------------------------------------------------------
827func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200828 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200829
Anssi Mannila4abf1802021-01-28 13:06:46 +0200830 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200831 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
832 Counter{cSubReqFromXapp, 1},
833 Counter{cSubReqToE2, 1},
834 Counter{cSubRespFromE2, 1},
835 Counter{cSubRespToXapp, 1},
836 Counter{cSubDelReqFromXapp, 1},
837 Counter{cSubDelReqToE2, 1},
838 Counter{cSubDelRespFromE2, 1},
839 Counter{cSubDelRespToXapp, 1},
840 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200841
842 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200843 crereq, cremsg := e2termConn1.RecvSubsReq(t)
844 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200845 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200846
847 resp, _ := xapp.Subscription.QuerySubscriptions()
848 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
849 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300850 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200851
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200852 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200853 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200854
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200855 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200856 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200857
858 //Wait that subs is cleaned
859 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
860
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200861 xappConn1.TestMsgChanEmpty(t)
862 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200863 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200864 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200865
866 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200867}
868
869//-----------------------------------------------------------------------------
870// TestSubReqRetransmission
871//
872// stub stub
873// +-------+ +---------+ +---------+
874// | xapp | | submgr | | e2term |
875// +-------+ +---------+ +---------+
876// | | |
877// | SubReq | |
878// |------------->| |
879// | | |
880// | | SubReq |
881// | |------------->|
882// | | |
883// | SubReq | |
884// | (retrans) | |
885// |------------->| |
886// | | |
887// | | SubResp |
888// | |<-------------|
889// | | |
890// | SubResp | |
891// |<-------------| |
892// | | |
893// | [SUBS DELETE] |
894// | | |
895//
896//-----------------------------------------------------------------------------
897func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200898 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200899
900 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200901 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200902 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200903
904 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200905 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200906 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
907
Juha Hyttinen1683f912020-04-17 10:39:57 +0300908 // hack as there is no real way to see has message be handled.
909 // Previuos counter check just tells that is has been received by submgr
910 // --> artificial delay
911 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200912 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200913 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200917 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
918 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920
921 //Wait that subs is cleaned
922 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
923
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200924 xappConn1.TestMsgChanEmpty(t)
925 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200926 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200927 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200928}
929
930//-----------------------------------------------------------------------------
931// TestSubDelReqRetransmission
932//
933// stub stub
934// +-------+ +---------+ +---------+
935// | xapp | | submgr | | e2term |
936// +-------+ +---------+ +---------+
937// | | |
938// | [SUBS CREATE] |
939// | | |
940// | | |
941// | SubDelReq | |
942// |------------->| |
943// | | |
944// | | SubDelReq |
945// | |------------->|
946// | | |
947// | SubDelReq | |
948// | (same sub) | |
949// | (same xid) | |
950// |------------->| |
951// | | |
952// | | SubDelResp |
953// | |<-------------|
954// | | |
955// | SubDelResp | |
956// |<-------------| |
957//
958//-----------------------------------------------------------------------------
959func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200960 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200961
962 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200963 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200964 crereq, cremsg := e2termConn1.RecvSubsReq(t)
965 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200966 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200967
968 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200969 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200970 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200971
972 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200973 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200974 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
975
Juha Hyttinen1683f912020-04-17 10:39:57 +0300976 // hack as there is no real way to see has message be handled.
977 // Previuos counter check just tells that is has been received by submgr
978 // --> artificial delay
979 <-time.After(1 * time.Second)
980
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200981 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200983
984 //Wait that subs is cleaned
985 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
986
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200987 xappConn1.TestMsgChanEmpty(t)
988 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200989 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200990 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200991}
992
993//-----------------------------------------------------------------------------
994// TestSubDelReqCollision
995//
996// stub stub
997// +-------+ +---------+ +---------+
998// | xapp | | submgr | | e2term |
999// +-------+ +---------+ +---------+
1000// | | |
1001// | [SUBS CREATE] |
1002// | | |
1003// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001004// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005// |------------->| |
1006// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001007// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001008// | |------------->|
1009// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001010// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001011// | (same sub) | |
1012// | (diff xid) | |
1013// |------------->| |
1014// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001015// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001016// | |<-------------|
1017// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001018// | SubDelResp 1 | |
1019// |<-------------| |
1020// | | |
1021// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001022// |<-------------| |
1023//
1024//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001025
Juha Hyttinenfa015662020-01-24 10:05:18 +02001026func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001027 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028
1029 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001030 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001031 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1032 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001033 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001034
1035 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001036 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001037 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001038
Juha Hyttinen3944a222020-01-24 11:51:46 +02001039 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001040 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001041 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1042 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001043 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1044
Juha Hyttinen1683f912020-04-17 10:39:57 +03001045 // hack as there is no real way to see has message be handled.
1046 // Previuos counter check just tells that is has been received by submgr
1047 // --> artificial delay
1048 <-time.After(1 * time.Second)
1049
Juha Hyttinen3944a222020-01-24 11:51:46 +02001050 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001051 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001052
1053 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001054 xappConn1.RecvSubsDelResp(t, nil)
1055 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001056
1057 //Wait that subs is cleaned
1058 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1059
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001060 xappConn1.TestMsgChanEmpty(t)
1061 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001062 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001063 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001064}
1065
1066//-----------------------------------------------------------------------------
1067// TestSubReqAndSubDelOkTwoParallel
1068//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001069// stub stub stub
1070// +-------+ +-------+ +---------+ +---------+
1071// | xapp | | xapp | | submgr | | e2term |
1072// +-------+ +-------+ +---------+ +---------+
1073// | | | |
1074// | | | |
1075// | | | |
1076// | | SubReq1 | |
1077// | |------------->| |
1078// | | | |
1079// | | | SubReq1 |
1080// | | |------------->|
1081// | | | |
1082// | SubReq2 | |
1083// |------------------------>| |
1084// | | | |
1085// | | | SubReq2 |
1086// | | |------------->|
1087// | | | |
1088// | | | SubResp1 |
1089// | | |<-------------|
1090// | | SubResp1 | |
1091// | |<-------------| |
1092// | | | |
1093// | | | SubResp2 |
1094// | | |<-------------|
1095// | SubResp2 | |
1096// |<------------------------| |
1097// | | | |
1098// | | [SUBS 1 DELETE] |
1099// | | | |
1100// | | [SUBS 2 DELETE] |
1101// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001102//
1103//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001104
Juha Hyttinenfa015662020-01-24 10:05:18 +02001105func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001106 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001107
1108 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001109 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001110 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001111 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001112 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001113
1114 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001115 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001116 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001117
1118 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1119 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1120 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1121
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001122 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001123 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001124
1125 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001126 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001127 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001128
1129 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001130 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001131 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001132
1133 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001134 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001135 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1136 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001137 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001138 //Wait that subs is cleaned
1139 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1140
1141 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001142 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001143 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1144 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146 //Wait that subs is cleaned
1147 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1148
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001149 xappConn1.TestMsgChanEmpty(t)
1150 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001151 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001152 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001153}
1154
1155//-----------------------------------------------------------------------------
1156// TestSameSubsDiffRan
1157// Same subscription to different RANs
1158//
1159// stub stub
1160// +-------+ +---------+ +---------+
1161// | xapp | | submgr | | e2term |
1162// +-------+ +---------+ +---------+
1163// | | |
1164// | | |
1165// | | |
1166// | SubReq(r1) | |
1167// |------------->| |
1168// | | |
1169// | | SubReq(r1) |
1170// | |------------->|
1171// | | |
1172// | | SubResp(r1) |
1173// | |<-------------|
1174// | | |
1175// | SubResp(r1) | |
1176// |<-------------| |
1177// | | |
1178// | SubReq(r2) | |
1179// |------------->| |
1180// | | |
1181// | | SubReq(r2) |
1182// | |------------->|
1183// | | |
1184// | | SubResp(r2) |
1185// | |<-------------|
1186// | | |
1187// | SubResp(r2) | |
1188// |<-------------| |
1189// | | |
1190// | [SUBS r1 DELETE] |
1191// | | |
1192// | [SUBS r2 DELETE] |
1193// | | |
1194//
1195//-----------------------------------------------------------------------------
1196func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001197 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001198
1199 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001200 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1201 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001202 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1203 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001204 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001205
1206 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001207 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1208 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001209 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1210 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212
1213 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001214 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1215 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001216 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1217 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001219 //Wait that subs is cleaned
1220 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1221
1222 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001223 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1224 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001225 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1226 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001227 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001228 //Wait that subs is cleaned
1229 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1230
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001231 xappConn1.TestMsgChanEmpty(t)
1232 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001233 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001234 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001235}
1236
1237//-----------------------------------------------------------------------------
1238// TestSubReqRetryInSubmgr
1239//
1240// stub stub
1241// +-------+ +---------+ +---------+
1242// | xapp | | submgr | | e2term |
1243// +-------+ +---------+ +---------+
1244// | | |
1245// | SubReq | |
1246// |------------->| |
1247// | | |
1248// | | SubReq |
1249// | |------------->|
1250// | | |
1251// | | |
1252// | | SubReq |
1253// | |------------->|
1254// | | |
1255// | | SubResp |
1256// | |<-------------|
1257// | | |
1258// | SubResp | |
1259// |<-------------| |
1260// | | |
1261// | [SUBS DELETE] |
1262// | | |
1263//
1264//-----------------------------------------------------------------------------
1265
1266func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001267 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001268
1269 // Init counter check
1270 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1271 Counter{cSubReqFromXapp, 1},
1272 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001273 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001274 Counter{cSubReReqToE2, 1},
1275 Counter{cSubRespFromE2, 1},
1276 Counter{cSubRespToXapp, 1},
1277 Counter{cSubDelReqFromXapp, 1},
1278 Counter{cSubDelReqToE2, 1},
1279 Counter{cSubDelRespFromE2, 1},
1280 Counter{cSubDelRespToXapp, 1},
1281 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001282
1283 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001284 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001285
1286 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001287 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001288
1289 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001290 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1291 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001292
1293 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001294 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001295
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001296 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001297 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1298 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001299 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001300
1301 // Wait that subs is cleaned
1302 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1303
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001304 xappConn1.TestMsgChanEmpty(t)
1305 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001306 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001307 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001308
1309 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001310}
1311
1312//-----------------------------------------------------------------------------
1313// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1314//
1315// stub stub
1316// +-------+ +---------+ +---------+
1317// | xapp | | submgr | | e2term |
1318// +-------+ +---------+ +---------+
1319// | | |
1320// | SubReq | |
1321// |------------->| |
1322// | | |
1323// | | SubReq |
1324// | |------------->|
1325// | | |
1326// | | |
1327// | | SubReq |
1328// | |------------->|
1329// | | |
1330// | | SubDelReq |
1331// | |------------->|
1332// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001333// | | SubDelResp |
1334// | |<-------------|
1335// | | |
1336//
1337//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001338func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001339 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001340
1341 // Init counter check
1342 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1343 Counter{cSubReqFromXapp, 1},
1344 Counter{cSubReqToE2, 1},
1345 Counter{cSubReReqToE2, 1},
1346 Counter{cSubReqTimerExpiry, 2},
1347 Counter{cSubDelReqToE2, 1},
1348 Counter{cSubDelRespFromE2, 1},
1349 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001350
1351 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001352 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001353
1354 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001355 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001356
1357 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001358 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001359
1360 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001361 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1362 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001363
1364 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001365 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001366
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001367 xappConn1.TestMsgChanEmpty(t)
1368 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001369 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001370 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001371
1372 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001373}
1374
1375//-----------------------------------------------------------------------------
1376// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1377//
1378// stub stub
1379// +-------+ +---------+ +---------+
1380// | xapp | | submgr | | e2term |
1381// +-------+ +---------+ +---------+
1382// | | |
1383// | SubReq | |
1384// |------------->| |
1385// | | |
1386// | | SubReq |
1387// | |------------->|
1388// | | |
1389// | | |
1390// | | SubReq |
1391// | |------------->|
1392// | | |
1393// | | SubDelReq |
1394// | |------------->|
1395// | | |
1396// | | |
1397// | | SubDelReq |
1398// | |------------->|
1399// | | |
1400// | | |
1401//
1402//-----------------------------------------------------------------------------
1403
1404func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001405 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001406
1407 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1408 Counter{cSubReqFromXapp, 1},
1409 Counter{cSubReqToE2, 1},
1410 Counter{cSubReReqToE2, 1},
1411 Counter{cSubReqTimerExpiry, 2},
1412 Counter{cSubDelReqToE2, 1},
1413 Counter{cSubDelReReqToE2, 1},
1414 Counter{cSubDelReqTimerExpiry, 2},
1415 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001416
1417 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001418 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001419
1420 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001421 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001422
1423 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001424 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001425
1426 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001427 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001428
1429 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001430 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001431
1432 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001433 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001434
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001435 xappConn1.TestMsgChanEmpty(t)
1436 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001437 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001438 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001439
1440 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001441}
1442
1443//-----------------------------------------------------------------------------
1444// TestSubReqSubFailRespInSubmgr
1445//
1446// stub stub
1447// +-------+ +---------+ +---------+
1448// | xapp | | submgr | | e2term |
1449// +-------+ +---------+ +---------+
1450// | | |
1451// | SubReq | |
1452// |------------->| |
1453// | | |
1454// | | SubReq |
1455// | |------------->|
1456// | | |
1457// | | SubFail |
1458// | |<-------------|
1459// | | |
1460// | SubFail | |
1461// |<-------------| |
1462// | | |
1463//
1464//-----------------------------------------------------------------------------
1465
1466func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001467 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001468
1469 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1470 Counter{cSubReqFromXapp, 1},
1471 Counter{cSubReqToE2, 1},
1472 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001473 Counter{cSubFailToXapp, 1},
1474 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001475
1476 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001477 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001478
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001479 // E2t: Receive SubsReq and send SubsFail (first)
1480 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1481 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1482 fparams1.Set(crereq1)
1483 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1484
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001485 // Xapp: Receive SubsFail
1486 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1487
1488 // Wait that subs is cleaned
1489 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1490
1491 xappConn1.TestMsgChanEmpty(t)
1492 xappConn2.TestMsgChanEmpty(t)
1493 e2termConn1.TestMsgChanEmpty(t)
1494 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001495
1496 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001497}
1498
1499//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001500// TestSubDelReqRetryInSubmgr
1501//
1502// stub stub
1503// +-------+ +---------+ +---------+
1504// | xapp | | submgr | | e2term |
1505// +-------+ +---------+ +---------+
1506// | | |
1507// | [SUBS CREATE] |
1508// | | |
1509// | | |
1510// | SubDelReq | |
1511// |------------->| |
1512// | | |
1513// | | SubDelReq |
1514// | |------------->|
1515// | | |
1516// | | SubDelReq |
1517// | |------------->|
1518// | | |
1519// | | SubDelResp |
1520// | |<-------------|
1521// | | |
1522// | SubDelResp | |
1523// |<-------------| |
1524//
1525//-----------------------------------------------------------------------------
1526
1527func TestSubDelReqRetryInSubmgr(t *testing.T) {
1528
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001529 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001530
1531 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001532 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001533 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1534 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001535 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001536
1537 // Subs Delete
1538 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001539 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001540
1541 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001542 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001543
1544 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001545 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1546 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001547
1548 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001549 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001550
1551 // Wait that subs is cleaned
1552 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1553
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001554 xappConn1.TestMsgChanEmpty(t)
1555 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001556 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001557 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001558}
1559
1560//-----------------------------------------------------------------------------
1561// TestSubDelReqTwoRetriesNoRespInSubmgr
1562//
1563// stub stub
1564// +-------+ +---------+ +---------+
1565// | xapp | | submgr | | e2term |
1566// +-------+ +---------+ +---------+
1567// | | |
1568// | [SUBS CREATE] |
1569// | | |
1570// | | |
1571// | SubDelReq | |
1572// |------------->| |
1573// | | |
1574// | | SubDelReq |
1575// | |------------->|
1576// | | |
1577// | | SubDelReq |
1578// | |------------->|
1579// | | |
1580// | | |
1581// | SubDelResp | |
1582// |<-------------| |
1583//
1584//-----------------------------------------------------------------------------
1585
1586func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1587
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001588 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001589
1590 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001591 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001592 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1593 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001594 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001595
1596 // Subs Delete
1597 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001598 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001599
1600 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001601 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001602
1603 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001604 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001605
1606 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001607 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001608
1609 // Wait that subs is cleaned
1610 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1611
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001612 xappConn1.TestMsgChanEmpty(t)
1613 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001614 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001615 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001616}
1617
1618//-----------------------------------------------------------------------------
1619// TestSubDelReqSubDelFailRespInSubmgr
1620//
1621// stub stub
1622// +-------+ +---------+ +---------+
1623// | xapp | | submgr | | e2term |
1624// +-------+ +---------+ +---------+
1625// | | |
1626// | [SUBS CREATE] |
1627// | | |
1628// | | |
1629// | SubDelReq | |
1630// |------------->| |
1631// | | |
1632// | | SubDelReq |
1633// | |------------->|
1634// | | |
1635// | | SubDelFail |
1636// | |<-------------|
1637// | | |
1638// | SubDelResp | |
1639// |<-------------| |
1640// | | |
1641//
1642//-----------------------------------------------------------------------------
1643
1644func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001645 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001646
1647 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1648 Counter{cSubReqFromXapp, 1},
1649 Counter{cSubReqToE2, 1},
1650 Counter{cSubRespFromE2, 1},
1651 Counter{cSubRespToXapp, 1},
1652 Counter{cSubDelReqFromXapp, 1},
1653 Counter{cSubDelReqToE2, 1},
1654 Counter{cSubDelFailFromE2, 1},
1655 Counter{cSubDelRespToXapp, 1},
1656 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001657
1658 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001659 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001660 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1661 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001662 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001663
1664 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001665 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001666
1667 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001668 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1669 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001670
1671 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001672 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001673
1674 // Wait that subs is cleaned
1675 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1676
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001677 xappConn1.TestMsgChanEmpty(t)
1678 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001679 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001680 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001681
1682 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001683}
1684
1685//-----------------------------------------------------------------------------
1686// TestSubReqAndSubDelOkSameAction
1687//
1688// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001689// +-------+ +-------+ +---------+ +---------+
1690// | xapp2 | | xapp1 | | submgr | | e2term |
1691// +-------+ +-------+ +---------+ +---------+
1692// | | | |
1693// | | | |
1694// | | | |
1695// | | SubReq1 | |
1696// | |------------->| |
1697// | | | |
1698// | | | SubReq1 |
1699// | | |------------->|
1700// | | | SubResp1 |
1701// | | |<-------------|
1702// | | SubResp1 | |
1703// | |<-------------| |
1704// | | | |
1705// | SubReq2 | |
1706// |--------------------------->| |
1707// | | | |
1708// | SubResp2 | |
1709// |<---------------------------| |
1710// | | | |
1711// | | SubDelReq 1 | |
1712// | |------------->| |
1713// | | | |
1714// | | SubDelResp 1 | |
1715// | |<-------------| |
1716// | | | |
1717// | SubDelReq 2 | |
1718// |--------------------------->| |
1719// | | | |
1720// | | | SubDelReq 2 |
1721// | | |------------->|
1722// | | | |
1723// | | | SubDelReq 2 |
1724// | | |------------->|
1725// | | | |
1726// | SubDelResp 2 | |
1727// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001728//
1729//-----------------------------------------------------------------------------
1730func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001731 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001732
Anssi Mannila4abf1802021-01-28 13:06:46 +02001733 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001734 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1735 Counter{cSubReqFromXapp, 2},
1736 Counter{cSubReqToE2, 1},
1737 Counter{cSubRespFromE2, 1},
1738 Counter{cSubRespToXapp, 2},
1739 Counter{cMergedSubscriptions, 1},
1740 Counter{cUnmergedSubscriptions, 1},
1741 Counter{cSubDelReqFromXapp, 2},
1742 Counter{cSubDelReqToE2, 1},
1743 Counter{cSubDelRespFromE2, 1},
1744 Counter{cSubDelRespToXapp, 2},
1745 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001746
Juha Hyttinen3944a222020-01-24 11:51:46 +02001747 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001748 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001749 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001750 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001751 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1752 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001753 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001754
1755 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001756 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001757 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001758 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001759 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001760
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001761 resp, _ := xapp.Subscription.QuerySubscriptions()
1762 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1763 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001764 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001765
Juha Hyttinen3944a222020-01-24 11:51:46 +02001766 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001767 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001769
1770 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001771 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001772 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1773 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001774 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001775 //Wait that subs is cleaned
1776 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1777
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001778 xappConn1.TestMsgChanEmpty(t)
1779 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001780 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001781 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001782
1783 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001784}
1785
1786//-----------------------------------------------------------------------------
1787// TestSubReqAndSubDelOkSameActionParallel
1788//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001789// stub stub stub
1790// +-------+ +-------+ +---------+ +---------+
1791// | xapp2 | | xapp1 | | submgr | | e2term |
1792// +-------+ +-------+ +---------+ +---------+
1793// | | | |
1794// | | | |
1795// | | | |
1796// | | SubReq1 | |
1797// | |------------->| |
1798// | | | |
1799// | | | SubReq1 |
1800// | | |------------->|
1801// | SubReq2 | |
1802// |--------------------------->| |
1803// | | | SubResp1 |
1804// | | |<-------------|
1805// | | SubResp1 | |
1806// | |<-------------| |
1807// | | | |
1808// | SubResp2 | |
1809// |<---------------------------| |
1810// | | | |
1811// | | SubDelReq 1 | |
1812// | |------------->| |
1813// | | | |
1814// | | SubDelResp 1 | |
1815// | |<-------------| |
1816// | | | |
1817// | SubDelReq 2 | |
1818// |--------------------------->| |
1819// | | | |
1820// | | | SubDelReq 2 |
1821// | | |------------->|
1822// | | | |
1823// | | | SubDelReq 2 |
1824// | | |------------->|
1825// | | | |
1826// | SubDelResp 2 | |
1827// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001828//
1829//-----------------------------------------------------------------------------
1830func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001831 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001832
1833 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001834 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001835 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001836 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001837 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001838
1839 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001840 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001841 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001842 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001843
1844 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001845 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001846 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001847
1848 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001849 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001850
1851 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001852 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1853 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001854
1855 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001856 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001857 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1858 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001859 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001860
1861 //Wait that subs is cleaned
1862 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1863
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001864 xappConn1.TestMsgChanEmpty(t)
1865 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001866 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001867 mainCtrl.wait_registry_empty(t, 10)
1868}
1869
1870//-----------------------------------------------------------------------------
1871// TestSubReqAndSubDelNokSameActionParallel
1872//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001873// stub stub stub
1874// +-------+ +-------+ +---------+ +---------+
1875// | xapp2 | | xapp1 | | submgr | | e2term |
1876// +-------+ +-------+ +---------+ +---------+
1877// | | | |
1878// | | | |
1879// | | | |
1880// | | SubReq1 | |
1881// | |------------->| |
1882// | | | |
1883// | | | SubReq1 |
1884// | | |------------->|
1885// | SubReq2 | |
1886// |--------------------------->| |
1887// | | | SubFail1 |
1888// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001889// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001890// | | SubFail1 | |
1891// | |<-------------| |
1892// | | | |
1893// | SubFail2 | |
1894// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001895//
1896//-----------------------------------------------------------------------------
1897func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001898 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001899
1900 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001901 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001902 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001903 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001904
1905 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001906 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001907
1908 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001909 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001910 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001911 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001912 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001913 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001914
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001915 // E2t: send SubsFail (first)
1916 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1917 fparams1.Set(crereq1)
1918 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1919
Juha Hyttinen3944a222020-01-24 11:51:46 +02001920 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001921 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001922 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001923 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001924
1925 //Wait that subs is cleaned
1926 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1927
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001928 xappConn1.TestMsgChanEmpty(t)
1929 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001930 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001931 mainCtrl.wait_registry_empty(t, 10)
1932}
1933
1934//-----------------------------------------------------------------------------
1935// TestSubReqAndSubDelNoAnswerSameActionParallel
1936//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001937// stub stub stub
1938// +-------+ +-------+ +---------+ +---------+
1939// | xapp2 | | xapp1 | | submgr | | e2term |
1940// +-------+ +-------+ +---------+ +---------+
1941// | | | |
1942// | | | |
1943// | | | |
1944// | | SubReq1 | |
1945// | |------------->| |
1946// | | | |
1947// | | | SubReq1 |
1948// | | |------------->|
1949// | | SubReq2 | |
1950// |--------------------------->| |
1951// | | | |
1952// | | | SubReq1 |
1953// | | |------------->|
1954// | | | |
1955// | | | |
1956// | | | SubDelReq |
1957// | | |------------->|
1958// | | | |
1959// | | | SubDelResp |
1960// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001961//
1962//-----------------------------------------------------------------------------
1963func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001964 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001965
1966 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001967 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001968 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001969 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001970
Juha Hyttinen1683f912020-04-17 10:39:57 +03001971 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001972
1973 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001974 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001975 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001976 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001977 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001978 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001979
1980 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001981 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001982
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001983 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1984 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001985
1986 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001987 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001988
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001989 xappConn1.TestMsgChanEmpty(t)
1990 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001991 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001992 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001993}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001994
1995//----------------------------- Policy cases ---------------------------------
1996//-----------------------------------------------------------------------------
1997// TestSubReqPolicyAndSubDelOk
1998//
1999// stub stub
2000// +-------+ +---------+ +---------+
2001// | xapp | | submgr | | e2term |
2002// +-------+ +---------+ +---------+
2003// | | |
2004// | SubReq | |
2005// |------------->| |
2006// | | |
2007// | | SubReq |
2008// | |------------->|
2009// | | |
2010// | | SubResp |
2011// | |<-------------|
2012// | | |
2013// | SubResp | |
2014// |<-------------| |
2015// | | |
2016// | | |
2017// | SubDelReq | |
2018// |------------->| |
2019// | | |
2020// | | SubDelReq |
2021// | |------------->|
2022// | | |
2023// | | SubDelResp |
2024// | |<-------------|
2025// | | |
2026// | SubDelResp | |
2027// |<-------------| |
2028//
2029//-----------------------------------------------------------------------------
2030func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2031 CaseBegin("TestSubReqAndSubDelOk")
2032
2033 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2034 rparams1.Init()
2035 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2036 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2037
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002038 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2039 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002040 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2041 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002042 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002043
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002044 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002045 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002046
2047 //Wait that subs is cleaned
2048 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2049
2050 xappConn1.TestMsgChanEmpty(t)
2051 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002052 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002053 mainCtrl.wait_registry_empty(t, 10)
2054}
2055
2056//-----------------------------------------------------------------------------
2057// TestSubReqPolicyChangeAndSubDelOk
2058//
2059// stub stub
2060// +-------+ +---------+ +---------+
2061// | xapp | | submgr | | e2term |
2062// +-------+ +---------+ +---------+
2063// | | |
2064// | SubReq | |
2065// |------------->| |
2066// | | |
2067// | | SubReq |
2068// | |------------->|
2069// | | |
2070// | | SubResp |
2071// | |<-------------|
2072// | | |
2073// | SubResp | |
2074// |<-------------| |
2075// | | |
2076// | SubReq | |
2077// |------------->| |
2078// | | |
2079// | | SubReq |
2080// | |------------->|
2081// | | |
2082// | | SubResp |
2083// | |<-------------|
2084// | | |
2085// | SubResp | |
2086// |<-------------| |
2087// | | |
2088// | SubDelReq | |
2089// |------------->| |
2090// | | |
2091// | | SubDelReq |
2092// | |------------->|
2093// | | |
2094// | | SubDelResp |
2095// | |<-------------|
2096// | | |
2097// | SubDelResp | |
2098// |<-------------| |
2099//
2100//-----------------------------------------------------------------------------
2101
2102func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2103 CaseBegin("TestSubReqAndSubDelOk")
2104
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002105 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2106 rparams1.Init()
2107 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2108 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002109
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002110 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2111 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002112 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2113
2114 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002115 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002116 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2117 xappConn1.SendSubsReq(t, rparams1, cretrans)
2118
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002119 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2120 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002121 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2122 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002123 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002124
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002125 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002126 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002127
2128 //Wait that subs is cleaned
2129 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2130
2131 xappConn1.TestMsgChanEmpty(t)
2132 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002133 e2termConn1.TestMsgChanEmpty(t)
2134 mainCtrl.wait_registry_empty(t, 10)
2135}
2136
2137//-----------------------------------------------------------------------------
2138// TestSubReqAndSubDelOkTwoE2termParallel
2139//
2140// stub stub stub
2141// +-------+ +---------+ +---------+ +---------+
2142// | xapp | | submgr | | e2term1 | | e2term2 |
2143// +-------+ +---------+ +---------+ +---------+
2144// | | | |
2145// | | | |
2146// | | | |
2147// | SubReq1 | | |
2148// |------------->| | |
2149// | | | |
2150// | | SubReq1 | |
2151// | |------------->| |
2152// | | | |
2153// | SubReq2 | | |
2154// |------------->| | |
2155// | | | |
2156// | | SubReq2 | |
2157// | |---------------------------->|
2158// | | | |
2159// | | SubResp1 | |
2160// | |<-------------| |
2161// | SubResp1 | | |
2162// |<-------------| | |
2163// | | SubResp2 | |
2164// | |<----------------------------|
2165// | SubResp2 | | |
2166// |<-------------| | |
2167// | | | |
2168// | [SUBS 1 DELETE] | |
2169// | | | |
2170// | [SUBS 2 DELETE] | |
2171// | | | |
2172//
2173//-----------------------------------------------------------------------------
2174func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2175 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2176
2177 //Req1
2178 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2179 xappConn1.SendSubsReq(t, nil, cretrans1)
2180 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2181
2182 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2183 xappConn1.SendSubsReq(t, nil, cretrans2)
2184 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2185
2186 //Resp1
2187 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2188 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2189
2190 //Resp2
2191 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2192 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2193
2194 //Del1
2195 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2196 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2197 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2198 xappConn1.RecvSubsDelResp(t, deltrans1)
2199 //Wait that subs is cleaned
2200 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2201
2202 //Del2
2203 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2204 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2205 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2206 xappConn1.RecvSubsDelResp(t, deltrans2)
2207 //Wait that subs is cleaned
2208 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2209
2210 xappConn1.TestMsgChanEmpty(t)
2211 xappConn2.TestMsgChanEmpty(t)
2212 e2termConn1.TestMsgChanEmpty(t)
2213 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002214 mainCtrl.wait_registry_empty(t, 10)
2215}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002216
2217//-----------------------------------------------------------------------------
2218// TestSubReqInsertAndSubDelOk
2219//
2220// stub stub
2221// +-------+ +---------+ +---------+
2222// | xapp | | submgr | | e2term |
2223// +-------+ +---------+ +---------+
2224// | | |
2225// | SubReq | |
2226// |------------->| |
2227// | | |
2228// | | SubReq |
2229// | |------------->|
2230// | | |
2231// | | SubResp |
2232// | |<-------------|
2233// | | |
2234// | SubResp | |
2235// |<-------------| |
2236// | | |
2237// | | |
2238// | SubDelReq | |
2239// |------------->| |
2240// | | |
2241// | | SubDelReq |
2242// | |------------->|
2243// | | |
2244// | | SubDelResp |
2245// | |<-------------|
2246// | | |
2247// | SubDelResp | |
2248// |<-------------| |
2249//
2250//-----------------------------------------------------------------------------
2251func TestSubReqInsertAndSubDelOk(t *testing.T) {
2252 CaseBegin("TestInsertSubReqAndSubDelOk")
2253
2254 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2255 rparams1.Init()
2256 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2257 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2258
2259 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2260 e2termConn1.SendSubsResp(t, crereq, cremsg)
2261 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2262 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2263 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2264
2265 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2266 xappConn1.RecvSubsDelResp(t, deltrans)
2267
2268 //Wait that subs is cleaned
2269 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2270
2271 xappConn1.TestMsgChanEmpty(t)
2272 xappConn2.TestMsgChanEmpty(t)
2273 e2termConn1.TestMsgChanEmpty(t)
2274 mainCtrl.wait_registry_empty(t, 10)
2275}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002276
2277//-----------------------------------------------------------------------------
2278// TestSubReqRetransmissionWithSameSubIdDiffXid
2279//
2280// This case simulates case where xApp restarts and starts sending same
2281// subscription requests which have already subscribed successfully
2282
2283// stub stub
2284// +-------+ +---------+ +---------+
2285// | xapp | | submgr | | e2term |
2286// +-------+ +---------+ +---------+
2287// | | |
2288// | SubReq | |
2289// |------------->| |
2290// | | |
2291// | | SubReq |
2292// | |------------->|
2293// | | |
2294// | | SubResp |
2295// | |<-------------|
2296// | | |
2297// | SubResp | |
2298// |<-------------| |
2299// | | |
2300// | xApp restart | |
2301// | | |
2302// | SubReq | |
2303// | (retrans with same xApp generated subid but diff xid)
2304// |------------->| |
2305// | | |
2306// | SubResp | |
2307// |<-------------| |
2308// | | |
2309// | [SUBS DELETE] |
2310// | | |
2311//
2312//-----------------------------------------------------------------------------
2313func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2314 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2315
2316 //Subs Create
2317 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2318 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2319 e2termConn1.SendSubsResp(t, crereq, cremsg)
2320 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2321
2322 // xApp restart here
2323 // --> artificial delay
2324 <-time.After(1 * time.Second)
2325
2326 //Subs Create
2327 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2328 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2329
2330 //Subs Delete
2331 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2332 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2333 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2334 xappConn1.RecvSubsDelResp(t, deltrans)
2335
2336 //Wait that subs is cleaned
2337 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2338
2339 xappConn1.TestMsgChanEmpty(t)
2340 xappConn2.TestMsgChanEmpty(t)
2341 e2termConn1.TestMsgChanEmpty(t)
2342 mainCtrl.wait_registry_empty(t, 10)
2343}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002344
2345//-----------------------------------------------------------------------------
2346// TestSubReqNokAndSubDelOkWithRestartInMiddle
2347//
2348// stub stub
2349// +-------+ +---------+ +---------+
2350// | xapp | | submgr | | e2term |
2351// +-------+ +---------+ +---------+
2352// | | |
2353// | SubReq | |
2354// |------------->| |
2355// | | |
2356// | | SubReq |
2357// | |------------->|
2358// | | |
2359// | | SubResp |
2360// | <----|
2361// | |
2362// | Submgr restart |
2363// | |
2364// | | |
2365// | | SubDelReq |
2366// | |------------->|
2367// | | |
2368// | | SubDelResp |
2369// | |<-------------|
2370// | | |
2371//
2372//-----------------------------------------------------------------------------
2373
2374func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2375 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2376
Anssi Mannilac92b4212020-12-07 14:59:34 +02002377 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2378 xappConn1.SendSubsReq(t, nil, nil)
2379 e2termConn1.RecvSubsReq(t)
2380 mainCtrl.SetResetTestFlag(t, false)
2381
2382 resp, _ := xapp.Subscription.QuerySubscriptions()
2383 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002384 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002385 e2SubsId := uint32(resp[0].SubscriptionID)
2386 t.Logf("e2SubsId = %v", e2SubsId)
2387
archaggeafbf95f2021-04-14 08:54:05 +03002388 mainCtrl.SimulateRestart(t)
2389 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002390
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002391 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002392 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2393 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2394
2395 // Wait that subs is cleaned
2396 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2397
2398 xappConn1.TestMsgChanEmpty(t)
2399 xappConn2.TestMsgChanEmpty(t)
2400 e2termConn1.TestMsgChanEmpty(t)
2401 mainCtrl.wait_registry_empty(t, 10)
2402}
2403
2404//-----------------------------------------------------------------------------
2405// TestSubReqAndSubDelOkWithRestartInMiddle
2406//
2407// stub stub
2408// +-------+ +---------+ +---------+
2409// | xapp | | submgr | | e2term |
2410// +-------+ +---------+ +---------+
2411// | | |
2412// | SubReq | |
2413// |------------->| |
2414// | | |
2415// | | SubReq |
2416// | |------------->|
2417// | | |
2418// | | SubResp |
2419// | |<-------------|
2420// | | |
2421// | SubResp | |
2422// |<-------------| |
2423// | | |
2424// | |
2425// | Submgr restart |
2426// | |
2427// | SubDelReq | |
2428// |------------->| |
2429// | | |
2430// | | SubDelReq |
2431// | |------------->|
2432// | | |
2433// | | SubDelResp |
2434// | |<-------------|
2435// | | |
2436// | SubDelResp | |
2437// |<-------------| |
2438//
2439//-----------------------------------------------------------------------------
2440
2441func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2442 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2443
2444 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2445 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2446 e2termConn1.SendSubsResp(t, crereq, cremsg)
2447 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2448
2449 // Check subscription
2450 resp, _ := xapp.Subscription.QuerySubscriptions()
2451 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2452 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002453 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002454
2455 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002456 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002457
Anssi Mannila54838ed2021-11-19 11:25:01 +02002458 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2459 // That needs to be completed before successful subscription query is possible
2460 <-time.After(time.Second * 1)
2461
Anssi Mannilac92b4212020-12-07 14:59:34 +02002462 // Check that subscription is restored correctly after restart
2463 resp, _ = xapp.Subscription.QuerySubscriptions()
2464 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2465 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002466 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002467
2468 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2469 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2470 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2471 xappConn1.RecvSubsDelResp(t, deltrans)
2472
2473 //Wait that subs is cleaned
2474 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2475
2476 xappConn1.TestMsgChanEmpty(t)
2477 xappConn2.TestMsgChanEmpty(t)
2478 e2termConn1.TestMsgChanEmpty(t)
2479 mainCtrl.wait_registry_empty(t, 10)
2480}
2481
2482//-----------------------------------------------------------------------------
2483// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2484//
2485// stub stub
2486// +-------+ +-------+ +---------+ +---------+
2487// | xapp2 | | xapp1 | | submgr | | e2term |
2488// +-------+ +-------+ +---------+ +---------+
2489// | | | |
2490// | | | |
2491// | | | |
2492// | | SubReq1 | |
2493// | |------------->| |
2494// | | | |
2495// | | | SubReq1 |
2496// | | |------------->|
2497// | | | SubResp1 |
2498// | | |<-------------|
2499// | | SubResp1 | |
2500// | |<-------------| |
2501// | | | |
2502// | |
2503// | submgr restart |
2504// | |
2505// | | | |
2506// | | | |
2507// | SubReq2 | |
2508// |--------------------------->| |
2509// | | | |
2510// | SubResp2 | |
2511// |<---------------------------| |
2512// | | | |
2513// | | SubDelReq 1 | |
2514// | |------------->| |
2515// | | | |
2516// | | SubDelResp 1 | |
2517// | |<-------------| |
2518// | | | |
2519// | | | |
2520// | |
2521// | submgr restart |
2522// | |
2523// | | | |
2524// | SubDelReq 2 | |
2525// |--------------------------->| |
2526// | | | |
2527// | | | SubDelReq 2 |
2528// | | |------------->|
2529// | | | |
2530// | | | SubDelReq 2 |
2531// | | |------------->|
2532// | | | |
2533// | SubDelResp 2 | |
2534// |<---------------------------| |
2535//
2536//-----------------------------------------------------------------------------
2537
2538func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2539 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2540
2541 //Req1
2542 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2543 rparams1.Init()
2544 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2545 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2546 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2547 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2548
2549 //Req2
2550 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2551 rparams2.Init()
2552 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2553 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2554
2555 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002556 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002557 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2558 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002559 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002560
2561 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002562 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002563
Anssi Mannila54838ed2021-11-19 11:25:01 +02002564 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2565 // That needs to be completed before successful subscription query is possible
2566 <-time.After(time.Second * 1)
2567
Anssi Mannilac92b4212020-12-07 14:59:34 +02002568 // Check that subscription is restored correctly after restart
2569 resp, _ = xapp.Subscription.QuerySubscriptions()
2570 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2571 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002572 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002573
2574 //Del1
2575 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2576 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2577 xappConn1.RecvSubsDelResp(t, deltrans1)
2578 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2579
2580 mainCtrl.SimulateRestart(t)
2581 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2582
Anssi Mannila54838ed2021-11-19 11:25:01 +02002583 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2584 // Submgr need be ready before successful subscription deletion is possible
2585 <-time.After(time.Second * 1)
2586
Anssi Mannilac92b4212020-12-07 14:59:34 +02002587 //Del2
2588 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2589 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2590
2591 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2592 xappConn2.RecvSubsDelResp(t, deltrans2)
2593
2594 //Wait that subs is cleaned
2595 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2596
2597 xappConn1.TestMsgChanEmpty(t)
2598 xappConn2.TestMsgChanEmpty(t)
2599 e2termConn1.TestMsgChanEmpty(t)
2600 mainCtrl.wait_registry_empty(t, 10)
2601}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002602
archaggeafbf95f2021-04-14 08:54:05 +03002603//*****************************************************************************
2604// REST interface test cases
2605//*****************************************************************************
2606
Anssi Mannila47518ae2021-04-16 09:27:07 +03002607//-----------------------------------------------------------------------------
2608// Test debug GET and POST requests
2609//
2610// curl
2611// +-------+ +---------+
2612// | user | | submgr |
2613// +-------+ +---------+
2614// | |
2615// | GET/POST Req |
2616// |------------->|
2617// | Resp |
2618// |<-------------|
2619// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002620func TestGetSubscriptions(t *testing.T) {
2621
2622 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2623}
2624
2625func TestGetSymptomData(t *testing.T) {
2626
2627 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2628}
2629
2630func TestPostdeleteSubId(t *testing.T) {
2631
2632 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2633}
2634
2635func TestPostEmptyDb(t *testing.T) {
2636
2637 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2638}
archaggeafbf95f2021-04-14 08:54:05 +03002639
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002640func TestGetRestSubscriptions(t *testing.T) {
2641
2642 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2643}
2644
archaggeafbf95f2021-04-14 08:54:05 +03002645//-----------------------------------------------------------------------------
2646// TestRESTSubReqAndRouteNok
2647//
2648// stub stub
2649// +-------+ +---------+ +---------+
2650// | xapp | | submgr | | rtmgr |
2651// +-------+ +---------+ +---------+
2652// | | |
2653// | RESTSubReq | |
2654// |---------------->| |
2655// | | |
2656// | RESTSubResp | |
2657// |<----------------| |
2658// | | RouteCreate |
2659// | |------------->|
2660// | | |
2661// | | RouteCreate |
2662// | | status:400 |
2663// | |(Bad request) |
2664// | |<-------------|
2665// | RESTNotif | |
2666// |<----------------| |
2667// | | |
2668// | [SUBS INT DELETE] |
2669// | | |
2670// | RESTSubDelReq | |
2671// |---------------->| |
2672// | RESTSubDelResp | |
2673// |<----------------| |
2674//
2675//-----------------------------------------------------------------------------
2676func TestRESTSubReqAndRouteNok(t *testing.T) {
2677 CaseBegin("TestRESTSubReqAndRouteNok")
2678
2679 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002680 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002681 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002682 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002683 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002684 Counter{cRestSubDelReqFromXapp, 1},
2685 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002686 })
2687
2688 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002689
Markku Virtanenda34eec2021-05-20 08:22:04 +00002690 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2691 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002692 newSubsId := mainCtrl.get_registry_next_subid(t)
2693
2694 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002695 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002696 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002697 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002698 waiter.WaitResult(t)
2699
archaggeafbf95f2021-04-14 08:54:05 +03002700 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002701 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002702
2703 // Del
2704 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2705
2706 // Wait that subs is cleaned
2707 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2708 waitSubsCleanup(t, e2SubsId, 10)
2709 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002710 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002711}
2712
2713func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2714 CaseBegin("TestSubReqAndRouteUpdateNok")
2715
2716 //Init counter check
2717 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002718 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002719 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002720 Counter{cSubReqToE2, 1},
2721 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002722 Counter{cRestSubNotifToXapp, 1},
2723 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002724 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002725 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002726 Counter{cSubDelReqToE2, 1},
2727 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002728 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002729 })
2730
2731 var params *teststube2ap.RESTSubsReqParams = nil
2732
2733 //Subs Create
2734 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2735
2736 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2737
2738 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2739 waiter := rtmgrHttp.AllocNextEvent(false)
2740 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002741 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002742 params.SetMeid("RAN_NAME_1")
2743 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002744 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002745 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002746 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03002747 xappConn2.WaitRESTNotification(t, restSubId2)
2748
2749 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2750
2751 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002752 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03002753
2754 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2755 //Wait that subs is cleaned
2756 waitSubsCleanup(t, e2SubsId, 10)
2757
2758 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002759 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002760}
2761
2762func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2763 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2764
2765 // Init counter check
2766 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002767 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002768 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002769 Counter{cSubReqToE2, 1},
2770 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002771 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002772 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002773 Counter{cRouteDeleteFail, 1},
2774 Counter{cSubDelReqToE2, 1},
2775 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002776 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002777 })
2778
2779 var params *teststube2ap.RESTSubsReqParams = nil
2780
2781 //Subs Create
2782 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2783
2784 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2785
2786 waiter := rtmgrHttp.AllocNextEvent(false)
2787 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2788 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2789 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2790 waiter.WaitResult(t)
2791
2792 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002793 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002794 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002795}
2796
2797func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2798 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2799
2800 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002801 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002802 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002803 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002804 Counter{cSubReqToE2, 1},
2805 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002806 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002807 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002808 Counter{cRouteDeleteUpdateFail, 1},
2809 Counter{cSubDelReqToE2, 1},
2810 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002811 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002812 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002813 })
2814
2815 var params *teststube2ap.RESTSubsReqParams = nil
2816
2817 //Subs Create
2818 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2819
2820 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2821 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2822
2823 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2824
2825 //Del1, this shall fail on rtmgr side
2826 waiter := rtmgrHttp.AllocNextEvent(false)
2827 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2828 waiter.WaitResult(t)
2829
2830 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2831
2832 //Del2
2833 deleteXapp2Subscription(t, &restSubId2)
2834
2835 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002836 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002837 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002838}
2839
2840//-----------------------------------------------------------------------------
2841// TestRESTSubReqRetransmission
2842//
2843// stub stub
2844// +-------+ +---------+ +---------+
2845// | xapp | | submgr | | e2term |
2846// +-------+ +---------+ +---------+
2847// | | |
2848// | RESTSubReq1 | |
2849// |---------------->| |
2850// | | |
2851// | RESTSubResp | |
2852// |<----------------| |
2853// | | SubReq1 |
2854// | |------------->|
2855// | | |
2856// | RESTSubReq2 | |
2857// | (retrans) | |
2858// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002859// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002860// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002861// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002862// | | SubResp1 |
2863// | |<-------------|
2864// | RESTNotif1 | |
2865// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002866// | | |
2867// | [SUBS DELETE] |
2868// | | |
2869//
2870//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002871
archaggeafbf95f2021-04-14 08:54:05 +03002872func TestRESTSubReqRetransmission(t *testing.T) {
2873 CaseBegin("TestRESTSubReqRetransmission")
2874
2875 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002876 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002877 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002878 Counter{cSubReqToE2, 1},
2879 Counter{cSubRespFromE2, 1},
2880 Counter{cRestSubNotifToXapp, 1},
2881 Counter{cRestSubDelReqFromXapp, 1},
2882 Counter{cSubDelReqToE2, 1},
2883 Counter{cSubDelRespFromE2, 1},
2884 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002885 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002886 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002887 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2888 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2889
2890 // Subs Create
2891 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002892
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002893 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002894 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002895
Anssi Mannilab43397e2021-11-16 12:06:16 +02002896 xappConn1.SendRESTSubsReq(t, params)
2897 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03002898
Anssi Mannilab43397e2021-11-16 12:06:16 +02002899 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03002900
2901 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02002902 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03002903 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2904 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002905
Anssi Mannilab43397e2021-11-16 12:06:16 +02002906 e2SubsId := <-xappConn1.ListedRESTNotifications
2907
2908 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002909
2910 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02002911 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002912 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2913 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2914
Anssi Mannilab43397e2021-11-16 12:06:16 +02002915 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002916
2917 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002918 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002919}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002920
Markku Virtanen42723e22021-06-15 10:09:23 +03002921//-----------------------------------------------------------------------------
2922// stub stub stub
2923// +-------+ +---------+ +---------+ +---------+
2924// | xapp | | submgr | | e2term | | rtmgr |
2925// +-------+ +---------+ +---------+ +---------+
2926// | | | |
2927// | RESTSubReq | | |
2928// |---------------->| | |
2929// | RESTSubResp | | |
2930// |<----------------| | |
2931// | | RouteCreate | |
2932// | |--------------------------->|
2933// | | RouteResponse| |
2934// | |<---------------------------| // The order of these events may vary
2935// | | SubReq | |
2936// | |------------->| | // The order of these events may vary
2937// | | SubResp | |
2938// | |<-------------| |
2939// | RESTNotif1 | | |
2940// |<----------------| | |
2941// | RESTSubReq | | |
2942// | [RETRANS1] | | |
2943// |---------------->| | |
2944// | RESTNotif1 | | |
2945// |<----------------| | |
2946// | RESTSubReq | | |
2947// | [RETRANS2] | | |
2948// |---------------->| | |
2949// | RESTNotif1 | | |
2950// |<----------------| | |
2951// | RESTSubDelReq | | |
2952// |---------------->| | |
2953// | | SubDelReq | |
2954// | |------------->| |
2955// | RESTSubDelResp| | |
2956// |<----------------| | |
2957// | | SubDelResp | |
2958// | |<-------------| |
2959// | | | |
2960//
2961//-----------------------------------------------------------------------------
2962
2963func TestRESTSubReqRetransmissionV2(t *testing.T) {
2964 CaseBegin("TestRESTSubReqRetransmissionV2")
2965
2966 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2967 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002968 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03002969 Counter{cRestSubRespToXapp, 3},
2970 Counter{cSubReqToE2, 1},
2971 Counter{cSubRespFromE2, 1},
2972 Counter{cRestSubNotifToXapp, 3},
2973 Counter{cRestSubDelReqFromXapp, 1},
2974 Counter{cSubDelReqToE2, 1},
2975 Counter{cSubDelRespFromE2, 1},
2976 Counter{cRestSubDelRespToXapp, 1},
2977 })
2978
2979 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2980
2981 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2982
2983 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2984
2985 //1.st resend
2986 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2987
2988 assert.Equal(t, restSubId_resend, restSubId)
2989
2990 <-time.After(100 * time.Millisecond)
2991
2992 //2.nd resend
2993 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2994
2995 assert.Equal(t, restSubId_resend2, restSubId)
2996
2997 <-time.After(100 * time.Millisecond)
2998
2999 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3000
3001 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003002 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003003 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003004}
3005
3006//-----------------------------------------------------------------------------
3007// stub stub stub
3008// +-------+ +---------+ +---------+ +---------+
3009// | xapp | | submgr | | e2term | | rtmgr |
3010// +-------+ +---------+ +---------+ +---------+
3011// | | | |
3012// | RESTSubReq | | |
3013// |---------------->| | |
3014// | RESTSubResp | | |
3015// |<----------------| | |
3016// | | RouteCreate | |
3017// | |--------------------------->|
3018// | | RouteResponse| |
3019// | |<---------------------------| // The order of these events may vary
3020// | | SubReq | |
3021// | |------------->| | // The order of these events may vary
3022// | | SubResp | |
3023// | |<-------------| |
3024// | RESTNotif1 | | |
3025// |<----------------| | |
3026// | RESTSubReq | | |
3027// | [RETRANS, with RESTsubsId] | |
3028// |---------------->| | |
3029// | RESTNotif1 | | |
3030// |<----------------| | |
3031// | RESTSubReq | | |
3032// | [RETRANS, without RESTsubsId] | |
3033// |---------------->| | |
3034// | RESTNotif1 | | |
3035// |<----------------| | |
3036// | RESTSubDelReq | | |
3037// |---------------->| | |
3038// | | SubDelReq | |
3039// | |------------->| |
3040// | RESTSubDelResp| | |
3041// |<----------------| | |
3042// | | SubDelResp | |
3043// | |<-------------| |
3044// | | | |
3045//
3046//-----------------------------------------------------------------------------
3047func TestRESTSubReqRetransmissionV3(t *testing.T) {
3048 CaseBegin("TestRESTSubReqRetransmissionV3")
3049
3050 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3051 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003052 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003053 Counter{cRestSubRespToXapp, 3},
3054 Counter{cSubReqToE2, 1},
3055 Counter{cSubRespFromE2, 1},
3056 Counter{cRestSubNotifToXapp, 3},
3057 Counter{cRestSubDelReqFromXapp, 1},
3058 Counter{cSubDelReqToE2, 1},
3059 Counter{cSubDelRespFromE2, 1},
3060 Counter{cRestSubDelRespToXapp, 1},
3061 })
3062
3063 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3064
3065 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3066
3067 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3068
3069 <-time.After(100 * time.Millisecond)
3070
3071 //1.st resend with subscription ID
3072 params.SetSubscriptionID(&restSubId)
3073 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3074
3075 assert.Equal(t, restSubId_resend, restSubId)
3076
3077 <-time.After(100 * time.Millisecond)
3078
3079 //2.nd resend without subscription ID (faking app restart)
3080 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3081 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3082
3083 assert.Equal(t, restSubId_resend2, restSubId)
3084
3085 <-time.After(100 * time.Millisecond)
3086
3087 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3088
3089 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003090 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003091 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003092}
3093
3094//-----------------------------------------------------------------------------
3095// stub stub stub
3096// +-------+ +---------+ +---------+ +---------+
3097// | xapp | | submgr | | e2term | | rtmgr |
3098// +-------+ +---------+ +---------+ +---------+
3099// | | | |
3100// | RESTSubReq | | |
3101// |---------------->| | |
3102// | RESTSubResp | | |
3103// |<----------------| | |
3104// | | RouteCreate | |
3105// | |--------------------------->|
3106// | | RouteResponse| |
3107// | |<---------------------------|
3108// | | SubReq | |
3109// | |------------->| |
3110// | | SubResp | |
3111// | |<-------------| |
3112// | RESTNotif1 | | |
3113// |<----------------| | |
3114// | RESTSubReq | | |
3115// | [with RestSUbsId + one additional e2 subDetail]
3116// |---------------->| | |
3117// | RESTNotif1 | | |
3118// | [for initial e2 subDetail] | |
3119// |<----------------| | |
3120// | | RouteCreate | |
3121// | |--------------------------->|
3122// | | RouteResponse| |
3123// | |<---------------------------|
3124// | | SubReq | |
3125// | |------------->| |
3126// | | SubResp | |
3127// | |<-------------| |
3128// | RESTNotif1 | | |
3129// |<----------------| | |
3130// | RESTSubReq | | |
3131// | [with RESTsubsId initial request] |
3132// |---------------->| | |
3133// | RESTNotif1 | | |
3134// |<----------------| | |
3135// | RESTSubDelReq | | |
3136// |---------------->| | |
3137// | RESTSubDelResp| | |
3138// |<----------------| | |
3139// | | SubDelReq | |
3140// | |------------->| |
3141// | | SubDelResp | |
3142// | |<-------------| |
3143// | | SubDelReq | |
3144// | |------------->| |
3145// | | SubDelResp | |
3146// | |<-------------| |
3147// | | | |
3148//
3149//-----------------------------------------------------------------------------
3150
3151func TestRESTSubReqRetransmissionV4(t *testing.T) {
3152 CaseBegin("TestRESTSubReqRetransmissionV4")
3153
3154 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3155 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003156 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003157 Counter{cRestSubRespToXapp, 3},
3158 Counter{cSubReqToE2, 2},
3159 Counter{cSubRespFromE2, 2},
3160 Counter{cRestSubNotifToXapp, 4},
3161 Counter{cRestSubDelReqFromXapp, 1},
3162 Counter{cSubDelReqToE2, 2},
3163 Counter{cSubDelRespFromE2, 2},
3164 Counter{cRestSubDelRespToXapp, 1},
3165 })
3166
3167 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3168
3169 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3170
3171 <-time.After(100 * time.Millisecond)
3172
3173 // Send modified requst, this time with e2 subscriptions.
3174 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3175 params2.SetSubscriptionID(&restSubId)
3176
3177 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003178 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003179 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3180 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003181 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3182 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003183
3184 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3185
Markku Virtanen2b512b62021-07-30 12:04:00 +00003186 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003187 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3188 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3189 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3190 assert.NotEqual(t, e2SubsId2, 0)
3191
3192 <-time.After(100 * time.Millisecond)
3193
3194 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3195 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3196 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003197 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003198 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3199 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3200 assert.Equal(t, restSubId_resend, restSubId_resend2)
3201
Markku Virtanen2b512b62021-07-30 12:04:00 +00003202 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3203 assert.Equal(t, e2SubsId, e2SubsId1)
3204
Markku Virtanen42723e22021-06-15 10:09:23 +03003205 // Delete both e2 subscriptions
3206 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3207 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3208 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3209
3210 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003211 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003212 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003213}
3214
3215//-----------------------------------------------------------------------------
3216// stub stub stub
3217// +-------+ +---------+ +---------+ +---------+
3218// | xapp | | submgr | | e2term | | rtmgr |
3219// +-------+ +---------+ +---------+ +---------+
3220// | | | |
3221// | RESTSubReq | | |
3222// |---------------->| | |
3223// | RESTSubResp | | |
3224// |<----------------| | |
3225// | | RouteCreate | |
3226// | |--------------------------->|
3227// | | RouteResponse| |
3228// | |<---------------------------|
3229// | | SubReq | |
3230// | |------------->| |
3231// | | SubResp | |
3232// | |<-------------| |
3233// | RESTNotif1 | | |
3234// |<----------------| | |
3235// | RESTSubReq | | |
3236// | [with RestSUbsId + one additional e2 subDetail]
3237// |---------------->| | |
3238// | RESTNotif1 | | |
3239// | [for initial e2 subDetail] | |
3240// |<----------------| | |
3241// | | RouteCreate | |
3242// | |--------------------------->|
3243// | | RouteResponse| |
3244// | |<---------------------------|
3245// | | SubReq | |
3246// | |------------->| |
3247// | | SubResp | |
3248// | |<-------------| |
3249// | RESTNotif1 | | |
3250// |<----------------| | |
3251// | RESTSubReq | | |
3252// | [without RESTsubsId initial request] |
3253// |---------------->| | |
3254// | RESTNotif1 | | |
3255// |<----------------| | |
3256// | RESTSubDelReq | | |
3257// |---------------->| | |
3258// | RESTSubDelResp| | |
3259// |<----------------| | |
3260// | | SubDelReq | |
3261// | |------------->| |
3262// | | SubDelResp | |
3263// | |<-------------| |
3264// | | SubDelReq | |
3265// | |------------->| |
3266// | | SubDelResp | |
3267// | |<-------------| |
3268// | | | |
3269//
3270//-----------------------------------------------------------------------------
3271
3272func TestRESTSubReqRetransmissionV5(t *testing.T) {
3273 CaseBegin("TestRESTSubReqRetransmissionV5")
3274
3275 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3276 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003277 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003278 Counter{cRestSubRespToXapp, 3},
3279 Counter{cSubReqToE2, 2},
3280 Counter{cSubRespFromE2, 2},
3281 Counter{cRestSubNotifToXapp, 4},
3282 Counter{cRestSubDelReqFromXapp, 1},
3283 Counter{cSubDelReqToE2, 2},
3284 Counter{cSubDelRespFromE2, 2},
3285 Counter{cRestSubDelRespToXapp, 1},
3286 })
3287
3288 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3289
3290 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3291
3292 <-time.After(100 * time.Millisecond)
3293
Anssi Mannila21782182021-12-10 10:56:02 +02003294 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003295 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3296 params2.SetSubscriptionID(&restSubId)
3297
3298 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003299 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003300 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3301 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3302
Markku Virtanen2b512b62021-07-30 12:04:00 +00003303 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3304 assert.Equal(t, e2SubsId, e2SubsId1)
3305 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3306 xappConn1.DecrementRequestCount()
3307
Markku Virtanen42723e22021-06-15 10:09:23 +03003308 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3309
3310 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3311 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3312 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3313 assert.NotEqual(t, e2SubsId2, 0)
3314
3315 <-time.After(100 * time.Millisecond)
3316
3317 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3318 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003319 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003320 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3321 // md5sum shall find the original request
3322 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3323 assert.Equal(t, restSubId_resend, restSubId_resend2)
3324
Markku Virtanen2b512b62021-07-30 12:04:00 +00003325 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3326 assert.Equal(t, e2SubsId, e2SubsId1)
3327
Markku Virtanen42723e22021-06-15 10:09:23 +03003328 // Delete both e2 subscriptions
3329 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3330 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3331 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3332
3333 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003334 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003335 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003336}
3337
3338//-----------------------------------------------------------------------------
3339// stub stub stub
3340// +-------+ +---------+ +---------+ +---------+
3341// | xapp | | submgr | | e2term | | rtmgr |
3342// +-------+ +---------+ +---------+ +---------+
3343// | | | |
3344// | RESTSubReq | | |
3345// |---------------->| | |
3346// | RESTSubResp | | |
3347// |<----------------| | |
3348// | | RouteCreate | |
3349// | |--------------------------->|
3350// | | RouteResponse| |
3351// | |<---------------------------|
3352// | | SubReq | |
3353// | |------------->| |
3354// | | SubResp | |
3355// | |<-------------| |
3356// | RESTNotif1 | | |
3357// |<----------------| | |
3358// | RESTSubReq | | |
3359// | [with RestSUbsId + one additional e2 subDetail]
3360// |---------------->| | |
3361// | RESTNotif1 | | |
3362// | [for initial e2 subDetail] | |
3363// |<----------------| | |
3364// | | RouteCreate | |
3365// | |--------------------------->|
3366// | | RouteResponse| |
3367// | |<---------------------------|
3368// | | SubReq | |
3369// | |------------->| |
3370// | | SubResp | |
3371// | |<-------------| |
3372// | RESTNotif1 | | |
3373// |<----------------| | |
3374// | RESTSubDelReq | | |
3375// |---------------->| | |
3376// | RESTSubDelResp| | |
3377// |<----------------| | |
3378// | | SubDelReq | |
3379// | |------------->| |
3380// | | SubDelResp | |
3381// | |<-------------| |
3382// | | SubDelReq | |
3383// | |------------->| |
3384// | | SubDelResp | |
3385// | |<-------------| |
3386// | RESTSubReq | | |
3387// | [with RESTsubsId initial request] |
3388// |---------------->| | |
3389// | RESTSubResp | | |
3390// |<----------------| | |
3391// | | RouteCreate | |
3392// | |--------------------------->|
3393// | | RouteResponse| |
3394// | |<---------------------------|
3395// | | SubReq | |
3396// | |------------->| |
3397// | | SubResp | |
3398// | |<-------------| |
3399// | RESTNotif1 | | |
3400// |<----------------| | |
3401// | | | |
3402//
3403//-----------------------------------------------------------------------------
3404func TestRESTSubReqRetransmissionV6(t *testing.T) {
3405 CaseBegin("TestRESTSubReqRetransmissionV6")
3406
3407 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3408 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003409 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003410 Counter{cRestSubRespToXapp, 3},
3411 Counter{cSubReqToE2, 3},
3412 Counter{cSubRespFromE2, 3},
3413 Counter{cRestSubNotifToXapp, 4},
3414 Counter{cRestSubDelReqFromXapp, 2},
3415 Counter{cSubDelReqToE2, 3},
3416 Counter{cSubDelRespFromE2, 3},
3417 Counter{cRestSubDelRespToXapp, 2},
3418 })
3419
3420 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3421
3422 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3423
3424 <-time.After(100 * time.Millisecond)
3425
3426 // Send modified requst, this time with e2 subscriptions.
3427 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3428 params2.SetSubscriptionID(&restSubId)
3429
3430 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003431 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003432 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3433 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3434
Markku Virtanen2b512b62021-07-30 12:04:00 +00003435 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3436 assert.Equal(t, e2SubsId, e2SubsId1)
3437
Markku Virtanen42723e22021-06-15 10:09:23 +03003438 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3439
3440 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3441 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3442 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3443 assert.NotEqual(t, e2SubsId2, 0)
3444
3445 <-time.After(100 * time.Millisecond)
3446
3447 // Delete both e2 subscriptions
3448 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3449 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3450 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3451
3452 waitSubsCleanup(t, e2SubsId, 10)
3453
3454 // Resend the original request, we shall find it's previous md5sum/restsubs
3455 // but the restsubscription has been already removed. This shall trigger a
3456 // fresh create.
3457 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3458
3459 <-time.After(100 * time.Millisecond)
3460
3461 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3462
3463 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003464 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003465 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003466}
3467
archaggeafbf95f2021-04-14 08:54:05 +03003468func TestRESTSubDelReqRetransmission(t *testing.T) {
3469 CaseBegin("TestRESTSubDelReqRetransmission")
3470
3471 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003472 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003473 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003474 Counter{cSubReqToE2, 1},
3475 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003476 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003477 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003478 Counter{cSubDelReqToE2, 1},
3479 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003480 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003481 })
3482
3483 var params *teststube2ap.RESTSubsReqParams = nil
3484
3485 //Subs Create
3486 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3487
3488 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3489
3490 //Subs Delete
3491 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3492 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3493
3494 seqBef := mainCtrl.get_msgcounter(t)
3495 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3496 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3497
3498 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3499
3500 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003501 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003502 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003503}
3504
3505//-----------------------------------------------------------------------------
3506// TestRESTSubReqDelReq
3507//
3508// stub stub
3509// +-------+ +---------+ +---------+
3510// | xapp | | submgr | | e2term |
3511// +-------+ +---------+ +---------+
3512// | | |
3513// | RESTSubReq | |
3514// |---------------->| |
3515// | | |
3516// | RESTSubResp | |
3517// |<----------------| |
3518// | | SubReq |
3519// | |------------->|
3520// | RESTSubDelReq | |
3521// |---------------->| |
3522// | RESTSubDelResp | |
3523// | unsuccess | |
3524// |<----------------| |
3525// | | SubResp |
3526// | |<-------------|
3527// | RESTNotif1 | |
3528// |<----------------| |
3529// | | |
3530// | [SUBS DELETE] |
3531// | | |
3532//
3533//-----------------------------------------------------------------------------
3534func TestRESTSubReqDelReq(t *testing.T) {
3535 CaseBegin("TestRESTSubReqDelReq")
3536
3537 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003538 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003539 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003540 Counter{cSubReqToE2, 1},
3541 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003542 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003543 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003544 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003545 Counter{cSubDelReqToE2, 1},
3546 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003547 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003548 })
3549
3550 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003551
3552 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003553 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003554 restSubId := xappConn1.SendRESTSubsReq(t, params)
3555
3556 // Del. This will fail as processing of the subscription
3557 // is still ongoing in submgr. Deletion is not allowed before
3558 // subscription creation has been completed.
3559 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3560 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3561 xappConn1.ExpectRESTNotification(t, restSubId)
3562 e2termConn1.SendSubsResp(t, crereq, cremsg)
3563 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3564
3565 // Retry del
3566 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3567
3568 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3569 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3570
3571 // Wait that subs is cleaned
3572 waitSubsCleanup(t, e2SubsId, 10)
3573 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003574 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003575}
3576
3577func TestRESTSubDelReqCollision(t *testing.T) {
3578 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3579}
3580
3581func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3582 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3583
3584 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003585 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003586 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003587 Counter{cSubReqToE2, 2},
3588 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003589 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003590 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003591 Counter{cSubDelReqToE2, 2},
3592 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003593 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003594 })
3595
3596 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003597 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003598 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003599 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003600
3601 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003602 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003603 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003604 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003605
3606 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3607 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3608
3609 //XappConn1 receives both of the responses
3610 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3611
3612 //Resp1
3613 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3614 //Resp2
3615 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3616
3617 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003618 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003619 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003620 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003621
3622 //Del1
3623 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3624 //Del2
3625 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3626
3627 //Wait that subs is cleaned
3628 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3629 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3630
3631 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003632 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003633}
3634
3635func TestRESTSameSubsDiffRan(t *testing.T) {
3636 CaseBegin("TestRESTSameSubsDiffRan")
3637
3638 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003639 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003640 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003641 Counter{cSubReqToE2, 2},
3642 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003643 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003644 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003645 Counter{cSubDelReqToE2, 2},
3646 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003647 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003648 })
3649
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003650 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003651 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003652 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003653
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003654 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003655 params.SetMeid("RAN_NAME_2")
3656 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003657 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003658
3659 //Del1
3660 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3661 //Del2
3662 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3663
3664 //Wait that subs is cleaned
3665 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3666 waitSubsCleanup(t, e2SubsId2, 10)
3667
3668 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003669 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003670}
3671
3672func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3673 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3674
3675 // Init counter check
3676 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003677 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003678 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003679 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003680 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003681 Counter{cSubReReqToE2, 1},
3682 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003683 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003684 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003685 Counter{cSubDelReqToE2, 1},
3686 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003687 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003688 })
3689
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003690 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003691 restSubId := xappConn1.SendRESTSubsReq(t, params)
3692
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003693 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003694
3695 // Catch the first message and ignore it
3696 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003697 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003698
3699 // The second request is being handled normally
3700 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3701 xappConn1.ExpectRESTNotification(t, restSubId)
3702 e2termConn1.SendSubsResp(t, crereq, cremsg)
3703 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3704
3705 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3706
3707 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3708
3709 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3710 //Wait that subs is cleaned
3711 waitSubsCleanup(t, e2SubsId, 10)
3712
3713 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003714 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003715}
3716
3717//-----------------------------------------------------------------------------
3718// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3719//
3720// stub stub
3721// +-------+ +---------+ +---------+
3722// | xapp | | submgr | | e2term |
3723// +-------+ +---------+ +---------+
3724// | | |
3725// | RESTSubReq | |
3726// |---------------->| |
3727// | | |
3728// | RESTSubResp | |
3729// |<----------------| |
3730// | | SubReq |
3731// | |------------->|
3732// | | |
3733// | | |
3734// | | SubReq |
3735// | |------------->|
3736// | | |
3737// | | SubDelReq |
3738// | |------------->|
3739// | | |
3740// | | |
3741// | | SubDelReq |
3742// | |------------->|
3743// | | |
3744// | | |
3745// | | SubDelResp |
3746// | |<-------------|
3747// | RESTNotif | |
3748// | unsuccess | |
3749// |<----------------| |
3750// | | |
3751// | [SUBS DELETE] |
3752// | | |
3753//
3754//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003755
archaggeafbf95f2021-04-14 08:54:05 +03003756func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3757 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3758
3759 // Init counter check
3760 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003761 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003762 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003763 Counter{cSubReqToE2, 1},
3764 Counter{cSubReReqToE2, 1},
3765 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003766 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003767 Counter{cSubDelReqToE2, 1},
3768 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003769 Counter{cRestSubDelReqFromXapp, 1},
3770 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003771 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003772
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003773 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003774 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003775 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003776
3777 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003778 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003779
3780 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003781 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003782
3783 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003784 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003785 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003786 xappConn1.WaitRESTNotification(t, restSubId)
3787
Anssi Mannilab43397e2021-11-16 12:06:16 +02003788 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3789
archaggeafbf95f2021-04-14 08:54:05 +03003790 // Wait that subs is cleaned
3791 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003792 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003793 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003794}
3795
3796func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3797 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3798
3799 // Init counter check
3800 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003801 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003802 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003803 Counter{cSubReqToE2, 1},
3804 Counter{cSubReReqToE2, 1},
3805 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003806 Counter{cSubDelReReqToE2, 1},
3807 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003808 Counter{cSubDelReqToE2, 1},
3809 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003810 Counter{cRestSubDelReqFromXapp, 1},
3811 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003812 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003813
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003814 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003815 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003816 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003817
3818 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003819 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003820
3821 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003822 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003823
3824 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003825 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003826
Markku Virtanen55d2a282021-06-04 14:46:56 +03003827 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003828 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003829 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003830
3831 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3832
Anssi Mannilab43397e2021-11-16 12:06:16 +02003833 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003834
Anssi Mannilab43397e2021-11-16 12:06:16 +02003835 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003836 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003837 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003838}
3839
3840//-----------------------------------------------------------------------------
3841// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3842//
3843// stub stub
3844// +-------+ +---------+ +---------+
3845// | xapp | | submgr | | e2term |
3846// +-------+ +---------+ +---------+
3847// | | |
3848// | RESTSubReq | |
3849// |---------------->| |
3850// | | |
3851// | RESTSubResp | |
3852// |<----------------| |
3853// | | SubReq |
3854// | |------------->|
3855// | | |
3856// | | |
3857// | | SubReq |
3858// | |------------->|
3859// | | |
3860// | | SubDelReq |
3861// | |------------->|
3862// | | |
3863// | | |
3864// | | SubDelReq |
3865// | |------------->|
3866// | | |
3867// | | |
3868// | | SubDelResp |
3869// | |<-------------|
3870// | RESTNotif | |
3871// | unsuccess | |
3872// |<----------------| |
3873// | | |
3874// | [SUBS DELETE] |
3875// | | |
3876//
3877//-----------------------------------------------------------------------------
3878func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3879 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3880
3881 // Init counter check
3882 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003883 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003884 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003885 Counter{cSubReqToE2, 1},
3886 Counter{cSubReReqToE2, 1},
3887 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003888 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003889 Counter{cSubDelReqToE2, 1},
3890 Counter{cSubDelReReqToE2, 1},
3891 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003892 Counter{cRestSubDelReqFromXapp, 1},
3893 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003894 })
3895
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003896 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003897 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003898 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003899
3900 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003901 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003902
3903 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003904 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003905
3906 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003907 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003908
Markku Virtanen55d2a282021-06-04 14:46:56 +03003909 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003910 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003911 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003912
3913 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3914
Anssi Mannilab43397e2021-11-16 12:06:16 +02003915 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003916
Anssi Mannilab43397e2021-11-16 12:06:16 +02003917 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003918 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003919 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003920}
3921
3922//-----------------------------------------------------------------------------
3923// TestRESTSubReqSubFailRespInSubmgr
3924//
3925// stub stub
3926// +-------+ +---------+ +---------+
3927// | xapp | | submgr | | e2term |
3928// +-------+ +---------+ +---------+
3929// | | |
3930// | RESTSubReq | |
3931// |---------------->| |
3932// | | |
3933// | RESTSubResp | |
3934// |<----------------| |
3935// | | SubReq |
3936// | |------------->|
3937// | | |
3938// | | SubFail |
3939// | |<-------------|
3940// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003941// | RESTNotif | |
3942// | unsuccess | |
3943// |<----------------| |
3944// | | |
3945// | [SUBS DELETE] |
3946// | | |
3947//
3948//-----------------------------------------------------------------------------
3949func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3950 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3951
3952 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003953 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003954 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003955 Counter{cSubReqToE2, 1},
3956 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003957 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003958 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003959 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003960 })
3961
3962 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003963 const e2Timeout int64 = 2
3964 const e2RetryCount int64 = 1
3965 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003966
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003967 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003968 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003969 restSubId := xappConn1.SendRESTSubsReq(t, params)
3970
3971 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3972 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3973 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003974 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003975 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3976
archaggeafbf95f2021-04-14 08:54:05 +03003977 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003978 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003979
3980 // REST subscription sill there to be deleted
3981 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3982
3983 // Wait that subs is cleaned
3984 waitSubsCleanup(t, e2SubsId, 10)
3985
3986 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003987 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003988}
3989
3990//-----------------------------------------------------------------------------
3991// TestRESTSubDelReqRetryInSubmgr
3992//
3993// stub stub
3994// +-------+ +---------+ +---------+
3995// | xapp | | submgr | | e2term |
3996// +-------+ +---------+ +---------+
3997// | | |
3998// | [SUBS CREATE] |
3999// | | |
4000// | | |
4001// | RESTSubDelReq | |
4002// |---------------->| |
4003// | | |
4004// | RESTSubDelResp | |
4005// |<----------------| |
4006// | | SubDelReq |
4007// | |------------->|
4008// | | |
4009// | | SubDelReq |
4010// | |------------->|
4011// | | |
4012// | | SubDelResp |
4013// | |<-------------|
4014// | | |
4015//
4016//-----------------------------------------------------------------------------
4017func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4018 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4019
4020 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004021 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004022 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004023 Counter{cSubReqToE2, 1},
4024 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004025 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004026 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004027 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004028 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004029 Counter{cSubDelReReqToE2, 1},
4030 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004031 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004032 })
4033 // Req
4034 var params *teststube2ap.RESTSubsReqParams = nil
4035 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4036
4037 // Del
4038 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4039
4040 // E2t: Receive 1st SubsDelReq
4041 e2termConn1.RecvSubsDelReq(t)
4042
4043 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4044 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4045 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4046
4047 //Wait that subs is cleaned
4048 waitSubsCleanup(t, e2SubsId, 10)
4049
4050 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004051 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004052}
4053
4054//-----------------------------------------------------------------------------
4055// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4056//
4057// stub stub
4058// +-------+ +---------+ +---------+
4059// | xapp | | submgr | | e2term |
4060// +-------+ +---------+ +---------+
4061// | | |
4062// | [SUBS CREATE] |
4063// | | |
4064// | | |
4065// | RESTSubDelReq | |
4066// |---------------->| |
4067// | | |
4068// | RESTSubDelResp | |
4069// |<----------------| |
4070// | | SubDelReq |
4071// | |------------->|
4072// | | |
4073// | | SubDelReq |
4074// | |------------->|
4075// | | |
4076// | | |
4077//
4078//-----------------------------------------------------------------------------
4079func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4080 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4081
4082 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004083 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004084 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004085 Counter{cSubReqToE2, 1},
4086 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004087 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004088 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004089 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004090 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004091 Counter{cSubDelReReqToE2, 1},
4092 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004093 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004094 })
4095
4096 // Req
4097 var params *teststube2ap.RESTSubsReqParams = nil
4098 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4099
4100 // Del
4101 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4102
4103 // E2t: Receive 1st SubsDelReq
4104 e2termConn1.RecvSubsDelReq(t)
4105
4106 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4107 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4108 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4109
4110 //Wait that subs is cleaned
4111 waitSubsCleanup(t, e2SubsId, 10)
4112
4113 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004114 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004115}
4116
4117//-----------------------------------------------------------------------------
4118// TestRESTSubDelReqSubDelFailRespInSubmgr
4119//
4120// stub stub
4121// +-------+ +---------+ +---------+
4122// | xapp | | submgr | | e2term |
4123// +-------+ +---------+ +---------+
4124// | | |
4125// | [SUBS CREATE] |
4126// | | |
4127// | | |
4128// | RESTSubDelReq | |
4129// |---------------->| |
4130// | | |
4131// | RESTSubDelResp | |
4132// |<----------------| |
4133// | | SubDelReq |
4134// | |------------->|
4135// | | |
4136// | | SubDelFail |
4137// | |<-------------|
4138// | | |
4139//
4140//-----------------------------------------------------------------------------
4141func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4142 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4143
4144 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004145 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004146 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004147 Counter{cSubReqToE2, 1},
4148 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004149 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004150 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004151 Counter{cSubDelReqToE2, 1},
4152 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004153 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004154 })
4155
4156 // Req
4157 var params *teststube2ap.RESTSubsReqParams = nil
4158 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4159
4160 // Del
4161 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4162
4163 // E2t: Send receive SubsDelReq and send SubsDelFail
4164 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4165 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4166
4167 //Wait that subs is cleaned
4168 waitSubsCleanup(t, e2SubsId, 10)
4169
4170 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004171 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004172}
4173
4174//-----------------------------------------------------------------------------
4175// TestRESTSubReqAndSubDelOkSameAction
4176//
4177// stub stub
4178// +-------+ +-------+ +---------+ +---------+
4179// | xapp2 | | xapp1 | | submgr | | e2term |
4180// +-------+ +-------+ +---------+ +---------+
4181// | | | |
4182// | | RESTSubReq1 | |
4183// | |---------------->| |
4184// | | | |
4185// | | RESTSubResp1 | |
4186// | |<----------------| |
4187// | | | |
4188// | | | SubReq1 |
4189// | | |------------->|
4190// | | | SubResp1 |
4191// | | |<-------------|
4192// | | RESTNotif1 | |
4193// | |<----------------| |
4194// | | | |
4195// | RESTSubReq2 | |
4196// |------------------------------>| |
4197// | | | |
4198// | RESTSubResp2 | |
4199// |<------------------------------| |
4200// | | | |
4201// | | RESTNotif2 | |
4202// |<------------------------------| |
4203// | | | |
4204// | | RESTSubDelReq1 | |
4205// | |---------------->| |
4206// | | | |
4207// | | RESTSubDelResp1 | |
4208// | |<----------------| |
4209// | | | |
4210// | RESTSubDelReq2 | |
4211// |------------------------------>| |
4212// | | | |
4213// | RESTSubDelResp2 | |
4214// |<------------------------------| |
4215// | | | |
4216// | | | SubDelReq2 |
4217// | | |------------->|
4218// | | | |
4219// | | | SubDelResp2 |
4220// | | |<-------------|
4221// | | | |
4222//
4223//-----------------------------------------------------------------------------
4224func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4225 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4226
4227 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004228 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004229 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004230 Counter{cSubReqToE2, 1},
4231 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004232 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004233 Counter{cMergedSubscriptions, 1},
4234 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004235 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004236 Counter{cSubDelReqToE2, 1},
4237 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004238 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004239 })
4240
4241 // Req1
4242 var params *teststube2ap.RESTSubsReqParams = nil
4243
4244 //Subs Create
4245 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4246 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4247
4248 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004249 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004250 params.SetMeid("RAN_NAME_1")
4251
4252 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004253 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004254 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004255 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004256 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004257 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004258 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004259 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004260
4261 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4262
4263 // Del1
4264 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4265
4266 // Del2
4267 deleteXapp2Subscription(t, &restSubId2)
4268
4269 //Wait that subs is cleaned
4270 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004271 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004272 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004273}
4274
4275//-----------------------------------------------------------------------------
4276// TestSubReqAndSubDelOkSameActionParallel
4277//
4278// stub stub stub
4279// +-------+ +-------+ +---------+ +---------+
4280// | xapp2 | | xapp1 | | submgr | | e2term |
4281// +-------+ +-------+ +---------+ +---------+
4282// | | | |
4283// | | | |
4284// | | | |
4285// | | SubReq1 | |
4286// | |------------->| |
4287// | | | |
4288// | | | SubReq1 |
4289// | | |------------->|
4290// | SubReq2 | |
4291// |--------------------------->| |
4292// | | | SubResp1 |
4293// | | |<-------------|
4294// | | SubResp1 | |
4295// | |<-------------| |
4296// | | | SubReq2 |
4297// | | |------------->|
4298// | | | |
4299// | | | SubResp2 |
4300// | | |<-------------|
4301// | SubResp2 | |
4302// |<---------------------------| |
4303// | | | |
4304// | | SubDelReq 1 | |
4305// | |------------->| |
4306// | | | |
4307// | | SubDelResp 1 | |
4308// | |<-------------| |
4309// | | | |
4310// | SubDelReq 2 | |
4311// |--------------------------->| |
4312// | | | |
4313// | | | SubDelReq 2 |
4314// | | |------------->|
4315// | | | |
4316// | | | SubDelReq 2 |
4317// | | |------------->|
4318// | | | |
4319// | SubDelResp 2 | |
4320// |<---------------------------| |
4321//
4322func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4323 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4324
4325 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004326 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004327 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004328 Counter{cSubReqToE2, 2},
4329 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004330 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004331 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004332 Counter{cSubDelReqToE2, 2},
4333 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004334 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004335 })
4336
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004337 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004338 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4339 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4340
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004341 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004342 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4343
4344 xappConn1.ExpectRESTNotification(t, restSubId1)
4345 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4346 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4347
4348 xappConn2.ExpectRESTNotification(t, restSubId2)
4349 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4350 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4351 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4352
4353 // Del1
4354 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4355 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4356 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4357 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4358
4359 // Del2
4360 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4361 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4362 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4363
4364 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004365 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004366 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004367}
4368
4369//-----------------------------------------------------------------------------
4370// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4371//
4372// stub stub stub
4373// +-------+ +-------+ +---------+ +---------+
4374// | xapp2 | | xapp1 | | submgr | | e2term |
4375// +-------+ +-------+ +---------+ +---------+
4376// | | | |
4377// | | | |
4378// | | | |
4379// | | RESTSubReq1 | |
4380// | |---------------->| |
4381// | | | |
4382// | | RESTSubResp1 | |
4383// | |<----------------| |
4384// | | | SubReq1 |
4385// | | |------------->|
4386// | RESTSubReq2 | |
4387// |------------------------------>| |
4388// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004389// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004390// |<------------------------------| |
4391// | | | SubReq1 |
4392// | | |------------->|
4393// | | | |
4394// | | | |
4395// | | | SubDelReq |
4396// | | |------------->|
4397// | | | |
4398// | | | SubDelResp |
4399// | | |<-------------|
4400// | | RESTNotif1 | |
4401// | | unsuccess | |
4402// | |<----------------| |
4403// | RESTNotif2 | |
4404// | | unsuccess | |
4405// |<------------------------------| |
4406// | | | |
4407// | | RESTSubDelReq1 | |
4408// | |---------------->| |
4409// | | | |
4410// | | RESTSubDelResp1 | |
4411// | |<----------------| |
4412// | | | |
4413// | RESTSubDelReq2 | |
4414// |------------------------------>| |
4415// | | | |
4416// | RESTSubDelResp2 | |
4417// |<------------------------------| |
4418//
4419//-----------------------------------------------------------------------------
4420func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4421 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4422
4423 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004424 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004425 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004426 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004427 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004428 Counter{cSubReqTimerExpiry, 2},
4429 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004430 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004431 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004432 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004433 Counter{cSubDelReqToE2, 1},
4434 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004435 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004436 })
archaggeafbf95f2021-04-14 08:54:05 +03004437 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004438
4439 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004440 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004441 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4442 crereq1, _ := e2termConn1.RecvSubsReq(t)
4443
4444 // Req2
4445 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004446 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004447 params2.SetMeid("RAN_NAME_1")
4448 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4449 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4450
4451 //Req1 (retransmitted)
4452 e2termConn1.RecvSubsReq(t)
4453
4454 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004455
4456 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004457 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4458
Markku Virtanenda34eec2021-05-20 08:22:04 +00004459 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004460 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004461 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004462 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004463
4464 // Del1
4465 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4466
4467 // Del2
4468 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4469
Markku Virtanenda34eec2021-05-20 08:22:04 +00004470 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4471
archaggeafbf95f2021-04-14 08:54:05 +03004472 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004473 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004474 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004475 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004476}
4477
4478//-----------------------------------------------------------------------------
4479// TestRESTSubReqAndSubDelNokSameActionParallel
4480//
4481// stub stub stub
4482// +-------+ +-------+ +---------+ +---------+
4483// | xapp2 | | xapp1 | | submgr | | e2term |
4484// +-------+ +-------+ +---------+ +---------+
4485// | | | |
4486// | | | |
4487// | | | |
4488// | | RESTSubReq1 | |
4489// | |---------------->| |
4490// | | | |
4491// | | RESTSubResp1 | |
4492// | |<----------------| |
4493// | | | SubReq1 |
4494// | | |------------->|
4495// | RESTSubReq2 | |
4496// |------------------------------>| |
4497// | | | |
4498// | RESTSubDelResp2 | |
4499// |<------------------------------| |
4500// | | | SubFail1 |
4501// | | |<-------------|
4502// | | | |
4503// | | RESTNotif1 | |
4504// | | unsuccess | |
4505// | |<----------------| |
4506// | RESTNotif2 | |
4507// | | unsuccess | |
4508// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004509// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004510// | | 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 +03004511// | |---------------->| |
4512// | | | |
4513// | | RESTSubDelResp1 | |
4514// | |<----------------| |
4515// | | | |
4516// | RESTSubDelReq2 | |
4517// |------------------------------>| |
4518// | | | |
4519// | RESTSubDelResp2 | |
4520// |<------------------------------| |
4521//
4522//-----------------------------------------------------------------------------
4523func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4524 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4525
4526 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004527 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004528 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004529 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004530 Counter{cSubReqToE2, 1},
4531 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004532 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004533 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004534 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004535 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004536 })
4537
4538 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004539
4540 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004541 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004542 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4543 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4544
4545 // Req2
4546 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004547 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004548 params2.SetMeid("RAN_NAME_1")
4549 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4550 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4551
4552 // E2t: send SubsFail (first)
4553 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4554 fparams1.Set(crereq1)
4555 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4556
archaggeafbf95f2021-04-14 08:54:05 +03004557 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004558 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004559 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004560 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004561 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004562
4563 // Del1
4564 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4565
4566 // Del2
4567 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4568
4569 //Wait that subs is cleaned
4570 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4571 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004572 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004573 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004574}
Anssi Mannila54838ed2021-11-19 11:25:01 +02004575
archaggeafbf95f2021-04-14 08:54:05 +03004576func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4577 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4578
4579 // Init counter check
4580 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004581 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004582 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004583 Counter{cSubReqToE2, 1},
4584 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004585 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004586 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004587 Counter{cSubDelReqToE2, 1},
4588 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004589 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004590 })
4591
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004592 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004593 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004594 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004595
4596 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4597 xappConn1.ExpectRESTNotification(t, restSubId)
4598 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4599 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004600 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004601
4602 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4603 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4604 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4605
4606 // Wait that subs is cleaned
4607 waitSubsCleanup(t, e2SubsId, 10)
4608 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004609 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004610}
4611
4612//-----------------------------------------------------------------------------
4613// TestRESTSubReqPolicyChangeAndSubDelOk
4614//
4615// stub stub
4616// +-------+ +---------+ +---------+
4617// | xapp | | submgr | | e2term |
4618// +-------+ +---------+ +---------+
4619// | | |
4620// | RESTSubReq | |
4621// |---------------->| |
4622// | | |
4623// | RESTSubResp | |
4624// |<----------------| |
4625// | | SubReq |
4626// | |------------->|
4627// | | |
4628// | | SubResp |
4629// | |<-------------|
4630// | | |
4631// | RESTNotif | |
4632// |<----------------| |
4633// | | |
4634// | RESTSubReq | |
4635// |---------------->| |
4636// | | |
4637// | RESTSubResp | |
4638// |<----------------| |
4639// | | SubReq |
4640// | |------------->|
4641// | | |
4642// | | SubResp |
4643// | |<-------------|
4644// | | |
4645// | RESTNotif | |
4646// |<----------------| |
4647// | | |
4648// | RESTSubDelReq | |
4649// |---------------->| |
4650// | | |
4651// | | SubDelReq |
4652// | |------------->|
4653// | | |
4654// | | SubDelResp |
4655// | |<-------------|
4656// | | |
4657// | RESTSubDelResp | |
4658// |<----------------| |
4659//
4660//-----------------------------------------------------------------------------
4661func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4662 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4663
4664 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004665 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004666 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004667 Counter{cSubReqToE2, 2},
4668 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004669 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004670 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004671 Counter{cSubDelReqToE2, 1},
4672 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004673 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004674 })
4675
4676 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004677 const e2Timeout int64 = 1
4678 const e2RetryCount int64 = 0
4679 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004680
4681 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004682 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004683 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004684 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4685
4686 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004687 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004688
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004689 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004690 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004691 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004692 params.SetTimeToWait("w200ms")
4693 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4694
4695 // Del
4696 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4697
4698 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4699 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4700
4701 // Wait that subs is cleaned
4702 waitSubsCleanup(t, e2SubsId, 10)
4703 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004704 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004705}
4706
4707//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004708// TestRESTSubReqPolicyChangeNOk
4709//
4710// stub stub
4711// +-------+ +---------+ +---------+
4712// | xapp | | submgr | | e2term |
4713// +-------+ +---------+ +---------+
4714// | | |
4715// | RESTSubReq | |
4716// |---------------->| |
4717// | | |
4718// | RESTSubResp | |
4719// |<----------------| |
4720// | | SubReq |
4721// | |------------->|
4722// | | |
4723// | | SubResp |
4724// | |<-------------|
4725// | | |
4726// | RESTNotif | |
4727// |<----------------| |
4728// | | |
4729// | RESTSubReq | |
4730// |---------------->| |
4731// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004732// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004733// | | |
4734// | RESTSubDelReq | |
4735// |---------------->| |
4736// | | |
4737// | | SubDelReq |
4738// | |------------->|
4739// | | |
4740// | | SubDelResp |
4741// | |<-------------|
4742// | | |
4743// | RESTSubDelResp | |
4744// |<----------------| |
4745//
4746//-----------------------------------------------------------------------------
4747func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4748 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4749
4750 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4751 Counter{cRestSubReqFromXapp, 2},
4752 Counter{cRestSubRespToXapp, 1},
4753 Counter{cSubReqToE2, 1},
4754 Counter{cSubRespFromE2, 1},
4755 Counter{cRestSubNotifToXapp, 1},
4756 Counter{cRestSubFailToXapp, 1},
4757 Counter{cRestSubDelReqFromXapp, 1},
4758 Counter{cSubDelReqToE2, 1},
4759 Counter{cSubDelRespFromE2, 1},
4760 Counter{cRestSubDelRespToXapp, 1},
4761 })
4762
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004763 // Req
4764 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4765 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4766
4767 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004768 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4769
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004770 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004771 params.SetSubscriptionID(&restSubIdUpd)
4772 params.SetTimeToWait("w200ms")
4773
4774 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4775 assert.Equal(t, restSubId2, "")
4776
4777 // Del
4778 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4779
4780 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4781 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4782
4783 // Wait that subs is cleaned
4784 waitSubsCleanup(t, e2SubsId, 10)
4785 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004786 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004787}
4788
4789//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004790// TestRESTSubReqAndSubDelOkTwoE2termParallel
4791//
4792// stub stub stub
4793// +-------+ +---------+ +---------+ +---------+
4794// | xapp | | submgr | | e2term1 | | e2term2 |
4795// +-------+ +---------+ +---------+ +---------+
4796// | | | |
4797// | | | |
4798// | | | |
4799// | RESTSubReq1 | | |
4800// |---------------->| | |
4801// | | | |
4802// | RESTSubResp1 | | |
4803// |<----------------| | |
4804// | | SubReq1 | |
4805// | |------------->| |
4806// | | | |
4807// | RESTSubReq2 | | |
4808// |---------------->| | |
4809// | | | |
4810// | RESTSubResp2 | | |
4811// |<----------------| | |
4812// | | SubReq2 | |
4813// | |---------------------------->|
4814// | | | |
4815// | | SubResp1 | |
4816// | |<-------------| |
4817// | RESTNotif1 | | |
4818// |<----------------| | |
4819// | | SubResp2 | |
4820// | |<----------------------------|
4821// | RESTNotif2 | | |
4822// |<----------------| | |
4823// | | | |
4824// | [SUBS 1 DELETE] | |
4825// | | | |
4826// | [SUBS 2 DELETE] | |
4827// | | | |
4828//
4829//-----------------------------------------------------------------------------
4830func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4831 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4832
4833 // Init counter check
4834 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004835 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004836 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004837 Counter{cSubReqToE2, 2},
4838 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004839 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004840 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004841 Counter{cSubDelReqToE2, 2},
4842 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004843 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004844 })
4845
4846 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004847
4848 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004849 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004850 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4851 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4852
4853 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004854 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004855 params.SetMeid("RAN_NAME_11")
4856 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4857 // would not work as notification would not be received
4858 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4859 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4860
4861 // Resp1
4862 xappConn1.ExpectRESTNotification(t, restSubId1)
4863 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4864 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004865 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004866
4867 // Resp2
4868 xappConn2.ExpectRESTNotification(t, restSubId2)
4869 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4870 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004871 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004872
4873 // Delete1
4874 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4875 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4876 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4877
4878 // Wait that subs is cleaned
4879 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4880
4881 // Delete2
4882 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4883 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4884 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4885
4886 // Wait that subs is cleaned
4887 waitSubsCleanup(t, e2SubsId2, 10)
4888
4889 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004890 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004891}
4892
4893//-----------------------------------------------------------------------------
4894// TestRESTSubReqAsn1EncodeFail
4895//
4896// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4897// stub stub
4898// +-------+ +---------+ +---------+
4899// | xapp | | submgr | | e2term |
4900// +-------+ +---------+ +---------+
4901// | | |
4902// | RESTSubReq | |
4903// |---------------->| |
4904// | | |
4905// | RESTSubResp | |
4906// |<----------------| |
4907// | RESTSubDelReq | |
4908// |---------------->| |
4909// | RESTSubDelResp | |
4910// | unsuccess | |
4911// |<----------------| |
4912// | | |
4913//
4914//-----------------------------------------------------------------------------
4915func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4916 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4917
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004918 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004919
4920}
4921
4922//-----------------------------------------------------------------------------
4923// TestRESTSubReqInsertAndSubDelOk
4924//
4925// stub stub
4926// +-------+ +---------+ +---------+
4927// | xapp | | submgr | | e2term |
4928// +-------+ +---------+ +---------+
4929// | | |
4930// | RestSubReq | |
4931// |---------------->| |
4932// | | |
4933// | RESTSubResp | |
4934// |<----------------| |
4935// | | |
4936// | | SubReq |
4937// | |------------->|
4938// | | |
4939// | | SubResp |
4940// | |<-------------|
4941// | RESTNotif | |
4942// |<----------------| |
4943// | ... | ... |
4944// | | |
4945// | RESTSubDelReq | |
4946// |---------------->| |
4947// | | |
4948// | | SubDelReq |
4949// | |------------->|
4950// | | |
4951// | | SubDelResp |
4952// | |<-------------|
4953// | | |
4954// | RESTSubDelResp| |
4955// |<----------------| |
4956//
4957//-----------------------------------------------------------------------------
4958func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4959 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4960
4961 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004962 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004963 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004964 Counter{cSubReqToE2, 1},
4965 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004966 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004967 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004968 Counter{cSubDelReqToE2, 1},
4969 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004970 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004971 })
4972
4973 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004974
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004975 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004976 params.SetSubActionTypes("insert")
4977
4978 // Req
4979 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4980
4981 // Del
4982 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4983
4984 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4985 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4986
4987 // Wait that subs is cleaned
4988 waitSubsCleanup(t, e2SubsId, 10)
4989 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004990 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004991}
4992
4993//-----------------------------------------------------------------------------
4994// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4995//
4996// stub stub
4997// +-------+ +---------+ +---------+
4998// | xapp | | submgr | | e2term |
4999// +-------+ +---------+ +---------+
5000// | | |
5001// | RESTSubReq | |
5002// |------------->| |
5003// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005004// | RESTSubResp | |
5005// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005006// | | SubReq |
5007// | |------------->|
5008// | | |
5009// | | SubResp |
5010// | <----|
5011// | |
5012// | Submgr restart |
5013// | |
5014// | | |
5015// | | SubDelReq |
5016// | |------------->|
5017// | | |
5018// | | SubDelResp |
5019// | |<-------------|
5020// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005021// | RESTNotif | |
5022// | unsuccess | |
5023// |<-------------| |
5024// | | |
5025// | RESTSubDelReq| |
5026// |------------->| |
5027// | | |
5028// |RESTSubDelResp| |
5029// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005030//
5031//-----------------------------------------------------------------------------
5032func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5033 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5034
5035 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005036 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005037 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005038 Counter{cSubReqToE2, 1},
5039 Counter{cSubDelReqFromXapp, 1},
5040 Counter{cSubDelReqToE2, 1},
5041 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005042 Counter{cRestSubDelReqFromXapp, 1},
5043 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005044 })
5045
5046 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005047
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005048 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005049
5050 //Req
5051 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5052 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005053 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005054
5055 e2termConn1.RecvSubsReq(t)
5056
5057 mainCtrl.SetResetTestFlag(t, false)
5058
5059 mainCtrl.SimulateRestart(t)
5060 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5061
Anssi Mannilab43397e2021-11-16 12:06:16 +02005062 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005063 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5064 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5065
Anssi Mannilab43397e2021-11-16 12:06:16 +02005066 //Del
5067 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5068
archaggeafbf95f2021-04-14 08:54:05 +03005069 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005070 e2termConn1.TestMsgChanEmpty(t)
5071 mainCtrl.wait_registry_empty(t, 10)
5072
5073 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005074 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005075}
5076
5077//-----------------------------------------------------------------------------
5078// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5079//
5080// stub stub
5081// +-------+ +---------+ +---------+
5082// | xapp | | submgr | | e2term |
5083// +-------+ +---------+ +---------+
5084// | | |
5085// | RESTSubReq | |
5086// |---------------->| |
5087// | | |
5088// | RESTSubResp | |
5089// |<----------------| |
5090// | | SubReq |
5091// | |------------->|
5092// | | |
5093// | | SubResp |
5094// | |<-------------|
5095// | | |
5096// | RESTNotif | |
5097// |<----------------| |
5098// | | |
5099// | |
5100// | Submgr restart |
5101// | | |
5102// | RESTSubDelReq | |
5103// |---------------->| |
5104// | | |
5105// | | SubDelReq |
5106// | |------------->|
5107// | | |
5108// | | SubDelResp |
5109// | |<-------------|
5110// | | |
5111// | RESTSubDelResp | |
5112// |<----------------| |
5113//
5114//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005115
archaggeafbf95f2021-04-14 08:54:05 +03005116func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5117 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5118
5119 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005120 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005121 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005122 Counter{cSubReqToE2, 1},
5123 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005124 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005125 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005126 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005127 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005128 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005129 })
archaggeafbf95f2021-04-14 08:54:05 +03005130
5131 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005132 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005133 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005134 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005135
5136 // Check subscription
5137 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5138
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005139 mainCtrl.SimulateRestart(t)
5140 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005141
Anssi Mannila54838ed2021-11-19 11:25:01 +02005142 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5143 // That needs to be completed before successful subscription query is possible
5144 <-time.After(time.Second * 1)
5145
archaggeafbf95f2021-04-14 08:54:05 +03005146 // Check subscription
5147 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5148
5149 // Delete subscription
5150 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5151
5152 //Wait that subs is cleaned
5153 waitSubsCleanup(t, e2SubsId, 10)
5154
5155 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005156 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005157}
5158
5159//-----------------------------------------------------------------------------
5160// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5161//
5162// stub stub
5163// +-------+ +-------+ +---------+ +---------+
5164// | xapp2 | | xapp1 | | submgr | | e2term |
5165// +-------+ +-------+ +---------+ +---------+
5166// | | | |
5167// | | RESTSubReq1 | |
5168// | |---------------->| |
5169// | | | |
5170// | | RESTSubResp1 | |
5171// | |<----------------| |
5172// | | | |
5173// | | | SubReq1 |
5174// | | |------------->|
5175// | | | SubResp1 |
5176// | | |<-------------|
5177// | | RESTNotif1 | |
5178// | |<----------------| |
5179// | | | |
5180// | RESTSubReq2 | |
5181// |------------------------------>| |
5182// | | | |
5183// | RESTSubResp2 | |
5184// |<------------------------------| |
5185// | | | |
5186// | | RESTNotif2 | |
5187// |<------------------------------| |
5188// | | | |
5189// | | Submgr restart |
5190// | | | |
5191// | | RESTSubDelReq1 | |
5192// | |---------------->| |
5193// | | | |
5194// | | RESTSubDelResp1 | |
5195// | |<----------------| |
5196// | | | |
5197// | | Submgr restart |
5198// | | | |
5199// | RESTSubDelReq2 | |
5200// |------------------------------>| |
5201// | | | |
5202// | RESTSubDelResp2 | |
5203// |<------------------------------| |
5204// | | | |
5205// | | | SubDelReq2 |
5206// | | |------------->|
5207// | | | |
5208// | | | SubDelResp2 |
5209// | | |<-------------|
5210// | | | |
5211//
5212//-----------------------------------------------------------------------------
5213func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5214 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5215
5216 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005217 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005218 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005219 Counter{cSubReqToE2, 1},
5220 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005221 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005222 Counter{cMergedSubscriptions, 1},
5223 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005224 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005225 Counter{cSubDelReqToE2, 1},
5226 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005227 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005228 })
5229
archaggeafbf95f2021-04-14 08:54:05 +03005230 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005231 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005232 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005233 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005234
5235 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005236 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005237 params.SetMeid("RAN_NAME_1")
5238 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005239 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005240 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005241 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005242 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005243 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005244
5245 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5246
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005247 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005248 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5249
5250 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5251 // That needs to be completed before successful subscription delete is possible
5252 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005253
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005254 // Delete subscription 1, and wait until it has removed the first endpoint
5255 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005256 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005257 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005258
Anssi Mannila54838ed2021-11-19 11:25:01 +02005259 // Above wait does not work correctly anymore as this delay makes this test case work
5260 //<-time.After(time.Second * 1)
5261
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005262 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005263 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5264
5265 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5266 // That needs to be completed before successful subscription query is possible
5267 <-time.After(time.Second * 1)
5268
archaggeafbf95f2021-04-14 08:54:05 +03005269 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5270
5271 // Delete subscription 2
5272 deleteXapp2Subscription(t, &restSubId2)
5273
5274 //Wait that subs is cleaned
5275 waitSubsCleanup(t, e2SubsId2, 10)
5276
5277 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005278 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005279}
5280
5281//-----------------------------------------------------------------------------
5282// TestRESTReportSubReqAndSubDelOk
5283//
5284// stub stub
5285// +-------+ +---------+ +---------+
5286// | xapp | | submgr | | e2term |
5287// +-------+ +---------+ +---------+
5288// | | |
5289// | RestSubReq | |
5290// |---------------->| |
5291// | | |
5292// | RESTSubResp | |
5293// |<----------------| |
5294// | | |
5295// | | SubReq |
5296// | |------------->|
5297// | | |
5298// | | SubResp |
5299// | |<-------------|
5300// | RESTNotif | |
5301// |<----------------| |
5302// | | SubReq |
5303// | |------------->|
5304// | | |
5305// | | SubResp |
5306// | |<-------------|
5307// | RESTNotif | |
5308// |<----------------| |
5309// | ... | ... |
5310// | | |
5311// | | |
5312// | RESTSubDelReq | |
5313// |---------------->| |
5314// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02005315// | RESTSubDelResp| |
5316// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005317// | | SubDelReq |
5318// | |------------->|
5319// | | |
5320// | | SubDelResp |
5321// | |<-------------|
5322// | | |
archaggeafbf95f2021-04-14 08:54:05 +03005323//
5324//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005325
archaggeafbf95f2021-04-14 08:54:05 +03005326func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5327 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005328 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005329 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005330 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005331}
5332
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005333func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005334 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005335
Anssi Mannila21782182021-12-10 10:56:02 +02005336 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5337 Counter{cRestSubReqFromXapp, 1},
5338 Counter{cRestSubRespToXapp, 1},
5339 Counter{cSubReqToE2, uint64(subReqCount)},
5340 Counter{cSubRespFromE2, uint64(subReqCount)},
5341 Counter{cRestSubNotifToXapp, 1},
5342 Counter{cRestSubDelReqFromXapp, 1},
5343 Counter{cRestSubDelRespToXapp, 1},
5344 Counter{cSubDelReqToE2, uint64(subReqCount)},
5345 Counter{cSubDelRespFromE2, uint64(subReqCount)},
5346 })
5347
archaggeafbf95f2021-04-14 08:54:05 +03005348 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005349 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005350 restSubId := xappConn1.SendRESTSubsReq(t, params)
5351
5352 var e2SubsId []uint32
5353 for i := 0; i < subReqCount; i++ {
5354 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5355 xappConn1.ExpectRESTNotification(t, restSubId)
5356
5357 e2termConn1.SendSubsResp(t, crereq, cremsg)
5358 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005359 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005360 e2SubsId = append(e2SubsId, instanceId)
5361 resp, _ := xapp.Subscription.QuerySubscriptions()
5362 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5363 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5364 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5365
5366 }
5367
5368 // Del
5369 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5370
5371 for i := 0; i < subReqCount; i++ {
5372 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5373 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5374 }
5375
5376 // Wait that subs is cleaned
5377 for i := 0; i < subReqCount; i++ {
5378 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5379 }
5380
5381 xappConn1.TestMsgChanEmpty(t)
5382 e2termConn1.TestMsgChanEmpty(t)
5383 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005384 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02005385 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03005386}
5387
5388/*
Anssi Mannila21782182021-12-10 10:56:02 +02005389func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { //Was in comments already. Next case is not run!
archaggeafbf95f2021-04-14 08:54:05 +03005390 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5391
5392 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005393 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005394 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005395
5396 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005397 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005398 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005399}
5400*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005401func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005402 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005403
Anssi Mannila21782182021-12-10 10:56:02 +02005404 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5405 Counter{cRestSubReqFromXapp, 1},
5406 Counter{cRestSubRespToXapp, 1},
5407 Counter{cSubReqToE2, uint64(subReqCount)},
5408 Counter{cSubRespFromE2, uint64(subReqCount)},
5409 Counter{cRestSubNotifToXapp, 1},
5410 Counter{cRestSubDelReqFromXapp, 1},
5411 Counter{cRestSubDelRespToXapp, 1},
5412 Counter{cSubDelReqToE2, uint64(subReqCount)},
5413 Counter{cSubDelRespFromE2, uint64(subReqCount)},
5414 })
5415
archaggeafbf95f2021-04-14 08:54:05 +03005416 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005417 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005418 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005419
5420 var e2SubsId []uint32
5421 for i := 0; i < subReqCount; i++ {
5422 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5423 xappConn1.ExpectRESTNotification(t, restSubId)
5424 e2termConn1.SendSubsResp(t, crereq, cremsg)
5425 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005426 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005427 e2SubsId = append(e2SubsId, instanceId)
5428 }
5429
5430 // Del
5431 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5432
5433 for i := 0; i < subReqCount; i++ {
5434 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5435 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5436 }
5437
5438 // Wait that subs is cleaned
5439 for i := 0; i < subReqCount; i++ {
5440 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5441 }
5442 xappConn1.TestMsgChanEmpty(t)
5443 e2termConn1.TestMsgChanEmpty(t)
5444 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005445 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02005446 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03005447}
5448
archaggeafbf95f2021-04-14 08:54:05 +03005449func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5450
archaggeafbf95f2021-04-14 08:54:05 +03005451 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005452 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005453 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005454 Counter{cSubReqToE2, 2},
5455 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005456 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005457 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005458 Counter{cSubDelReqToE2, 2},
5459 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005460 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005461 })
5462
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005463 const subReqCount int = 2
5464
archaggeafbf95f2021-04-14 08:54:05 +03005465 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005466 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005467 restSubId := xappConn1.SendRESTSubsReq(t, params)
5468 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5469
5470 assert.Equal(t, len(e2SubsIds), 2)
5471
5472 // Del
5473 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5474 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5475
5476 xappConn1.TestMsgChanEmpty(t)
5477 e2termConn1.TestMsgChanEmpty(t)
5478 mainCtrl.wait_registry_empty(t, 10)
5479
5480 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005481 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005482}
archaggeafbf95f2021-04-14 08:54:05 +03005483func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5484
archaggeafbf95f2021-04-14 08:54:05 +03005485 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005486 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005487 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005488 Counter{cSubReqToE2, 19},
5489 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005490 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005491 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005492 Counter{cSubDelReqToE2, 19},
5493 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005494 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005495 })
5496
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005497 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005498 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005499 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005500 restSubId := xappConn1.SendRESTSubsReq(t, params)
5501 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5502
5503 assert.Equal(t, len(e2SubsIds), 19)
5504
5505 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5506 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5507
5508 xappConn1.TestMsgChanEmpty(t)
5509 e2termConn1.TestMsgChanEmpty(t)
5510 mainCtrl.wait_registry_empty(t, 10)
5511
5512 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005513 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005514}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005515
archaggeafbf95f2021-04-14 08:54:05 +03005516func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5517
5518 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005519
5520 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005521 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005522 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005523 Counter{cSubReqToE2, uint64(subReqCount)},
5524 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005525 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005526 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005527 Counter{cSubDelReqToE2, uint64(subReqCount)},
5528 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005529 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005530 })
5531
5532 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005533 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005534 restSubId := xappConn1.SendRESTSubsReq(t, params)
5535 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5536
5537 assert.Equal(t, len(e2SubsIds), subReqCount)
5538
5539 // Del
5540 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5541 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5542
5543 xappConn1.TestMsgChanEmpty(t)
5544 e2termConn1.TestMsgChanEmpty(t)
5545 mainCtrl.wait_registry_empty(t, 10)
5546
5547 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005548 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005549}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005550
archaggeafbf95f2021-04-14 08:54:05 +03005551func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5552
5553 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005554
5555 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005556 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005557 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005558 Counter{cSubReqToE2, uint64(subReqCount)},
5559 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005560 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005561 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005562 Counter{cSubDelReqToE2, uint64(subReqCount)},
5563 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005564 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005565 })
5566
5567 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005568 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005569 restSubId := xappConn1.SendRESTSubsReq(t, params)
5570 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5571
5572 assert.Equal(t, len(e2SubsIds), subReqCount)
5573
5574 // Del
5575 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5576 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5577
5578 xappConn1.TestMsgChanEmpty(t)
5579 e2termConn1.TestMsgChanEmpty(t)
5580 mainCtrl.wait_registry_empty(t, 10)
5581
5582 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005583 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005584}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005585
archaggeafbf95f2021-04-14 08:54:05 +03005586func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5587
5588 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005589
5590 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005591 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005592 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005593 Counter{cSubReqToE2, uint64(subReqCount)},
5594 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005595 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005596 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005597 Counter{cSubDelReqToE2, uint64(subReqCount)},
5598 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005599 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005600 })
5601
5602 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005603 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005604 restSubId := xappConn1.SendRESTSubsReq(t, params)
5605 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5606
5607 assert.Equal(t, len(e2SubsIds), subReqCount)
5608
5609 // Del
5610 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5611 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5612
5613 xappConn1.TestMsgChanEmpty(t)
5614 e2termConn1.TestMsgChanEmpty(t)
5615 mainCtrl.wait_registry_empty(t, 10)
5616
5617 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005618 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005619}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005620
5621func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5622 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5623
5624 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005625 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005626 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005627 Counter{cSubReqToE2, 2},
5628 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005629 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005630 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005631 Counter{cSubDelReqToE2, 2},
5632 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005633 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005634 })
5635
5636 // Req1
5637 var params *teststube2ap.RESTSubsReqParams = nil
5638
5639 //Subs Create
5640 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005641 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005642
5643 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5644
5645 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005646 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005647 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005648 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005649 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5650
5651 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005652 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005653 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5654 xappConn2.ExpectRESTNotification(t, restSubId2)
5655 e2termConn1.SendSubsResp(t, crereq, cremsg)
5656 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5657
5658 deleteXapp1Subscription(t, &restSubId1)
5659 deleteXapp2Subscription(t, &restSubId2)
5660
5661 waitSubsCleanup(t, e2SubsId1, 10)
5662 waitSubsCleanup(t, e2SubsId2, 10)
5663
5664 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005665 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005666}
5667
5668func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5669 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5670
5671 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005672 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005673 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005674 Counter{cSubReqToE2, 2},
5675 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005676 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005677 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005678 Counter{cSubDelReqToE2, 2},
5679 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005680 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005681 })
5682
5683 // Req1
5684 var params *teststube2ap.RESTSubsReqParams = nil
5685
5686 //Subs Create
5687 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005688 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005689
5690 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5691
5692 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005693 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005694 params.SetMeid("RAN_NAME_1")
5695
5696 actionId := int64(1)
5697 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005698 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005699 subsequestActionType := "continue"
5700 timeToWait := "w10ms"
5701 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5702
5703 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005704 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005705 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5706 xappConn2.ExpectRESTNotification(t, restSubId2)
5707 e2termConn1.SendSubsResp(t, crereq, cremsg)
5708 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5709
5710 deleteXapp1Subscription(t, &restSubId1)
5711 deleteXapp2Subscription(t, &restSubId2)
5712
5713 waitSubsCleanup(t, e2SubsId1, 10)
5714 waitSubsCleanup(t, e2SubsId2, 10)
5715
5716 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005717 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005718}
5719
5720func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5721 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5722
5723 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005724 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005725 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005726 Counter{cSubReqToE2, 2},
5727 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005728 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005729 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005730 Counter{cSubDelReqToE2, 2},
5731 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005732 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005733 })
5734
5735 // Req1
5736 var params *teststube2ap.RESTSubsReqParams = nil
5737
5738 //Subs Create
5739 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005740 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005741
5742 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5743
5744 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005745 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005746 params.SetMeid("RAN_NAME_1")
5747 params.SetSubActionIDs(int64(2))
5748
5749 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005750 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005751 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5752 xappConn2.ExpectRESTNotification(t, restSubId2)
5753 e2termConn1.SendSubsResp(t, crereq, cremsg)
5754 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5755
5756 deleteXapp1Subscription(t, &restSubId1)
5757 deleteXapp2Subscription(t, &restSubId2)
5758
5759 waitSubsCleanup(t, e2SubsId1, 10)
5760 waitSubsCleanup(t, e2SubsId2, 10)
5761
5762 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005763 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005764}
5765
5766func TestRESTSubReqDiffActionType(t *testing.T) {
5767 CaseBegin("TestRESTSubReqDiffActionType")
5768
5769 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005770 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005771 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005772 Counter{cSubReqToE2, 2},
5773 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005774 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005775 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005776 Counter{cSubDelReqToE2, 2},
5777 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005778 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005779 })
5780
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005781 const e2Timeout int64 = 2
5782 const e2RetryCount int64 = 2
5783 const routingNeeded bool = true
5784
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005785 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005786 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005787 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005788
5789 //Subs Create
5790 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005791 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005792
5793 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5794
5795 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005796 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005797 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005798 params.SetMeid("RAN_NAME_1")
5799
5800 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005801 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005802 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5803 xappConn2.ExpectRESTNotification(t, restSubId2)
5804 e2termConn1.SendSubsResp(t, crereq, cremsg)
5805 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5806
5807 deleteXapp1Subscription(t, &restSubId1)
5808 deleteXapp2Subscription(t, &restSubId2)
5809
5810 waitSubsCleanup(t, e2SubsId1, 10)
5811 waitSubsCleanup(t, e2SubsId2, 10)
5812
5813 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005814 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005815}
5816
5817func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5818 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5819
5820 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005821 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005822 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005823 Counter{cSubReqToE2, 2},
5824 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005825 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005826 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005827 Counter{cSubDelReqToE2, 2},
5828 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005829 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005830 })
5831
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005832 const e2Timeout int64 = 2
5833 const e2RetryCount int64 = 2
5834 const routingNeeded bool = true
5835
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005836 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005837 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005838 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005839
5840 //Subs Create
5841 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005842 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005843
5844 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5845
5846 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005847 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005848 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005849 params.SetMeid("RAN_NAME_1")
5850
5851 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005852 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005853 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5854 xappConn2.ExpectRESTNotification(t, restSubId2)
5855 e2termConn1.SendSubsResp(t, crereq, cremsg)
5856 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5857
5858 deleteXapp1Subscription(t, &restSubId1)
5859 deleteXapp2Subscription(t, &restSubId2)
5860
5861 waitSubsCleanup(t, e2SubsId1, 10)
5862 waitSubsCleanup(t, e2SubsId2, 10)
5863
5864 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005865 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005866}
5867
5868func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5869 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5870
5871 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005872 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005873 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005874 Counter{cSubReqToE2, 2},
5875 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005876 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005877 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005878 Counter{cSubDelReqToE2, 2},
5879 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005880 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005881 })
5882
5883 // Req1
5884 var params *teststube2ap.RESTSubsReqParams = nil
5885
5886 //Subs Create
5887 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005888 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005889
5890 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5891
5892 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005893 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005894 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005895 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005896 params.SetSubActionDefinition(actionDefinition)
5897
5898 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005899 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005900 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5901 xappConn2.ExpectRESTNotification(t, restSubId2)
5902 e2termConn1.SendSubsResp(t, crereq, cremsg)
5903 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5904
5905 deleteXapp1Subscription(t, &restSubId1)
5906 deleteXapp2Subscription(t, &restSubId2)
5907
5908 waitSubsCleanup(t, e2SubsId1, 10)
5909 waitSubsCleanup(t, e2SubsId2, 10)
5910
5911 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005912 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005913}
5914
5915func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5916 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5917
5918 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005919 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005920 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005921 Counter{cSubReqToE2, 2},
5922 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005923 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005924 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005925 Counter{cSubDelReqToE2, 2},
5926 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005927 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005928 })
5929
5930 // Req1
5931 var params *teststube2ap.RESTSubsReqParams = nil
5932
5933 //Subs Create
5934 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005935 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005936
5937 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5938
5939 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005940 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005941 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005942 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005943 params.SetSubActionDefinition(actionDefinition)
5944
5945 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005946 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005947 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5948 xappConn2.ExpectRESTNotification(t, restSubId2)
5949 e2termConn1.SendSubsResp(t, crereq, cremsg)
5950 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5951
5952 deleteXapp1Subscription(t, &restSubId1)
5953 deleteXapp2Subscription(t, &restSubId2)
5954
5955 waitSubsCleanup(t, e2SubsId1, 10)
5956 waitSubsCleanup(t, e2SubsId2, 10)
5957
5958 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005959 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005960}
5961
5962func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5963 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5964
5965 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005966 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005967 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005968 Counter{cSubReqToE2, 2},
5969 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005970 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005971 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005972 Counter{cSubDelReqToE2, 2},
5973 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005974 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005975 })
5976
5977 // Req1
5978 var params *teststube2ap.RESTSubsReqParams = nil
5979
5980 //Subs Create
5981 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005982 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005983
5984 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5985
5986 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005987 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005988 params.SetMeid("RAN_NAME_1")
5989 params.SetTimeToWait("w200ms")
5990 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005991 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005992 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5993 xappConn2.ExpectRESTNotification(t, restSubId2)
5994 e2termConn1.SendSubsResp(t, crereq, cremsg)
5995 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5996
5997 deleteXapp1Subscription(t, &restSubId1)
5998 deleteXapp2Subscription(t, &restSubId2)
5999
6000 waitSubsCleanup(t, e2SubsId1, 10)
6001 waitSubsCleanup(t, e2SubsId2, 10)
6002
6003 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006004 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006005}
6006
Anssi Mannila51122392021-05-25 11:51:31 +03006007//-----------------------------------------------------------------------------
6008// TestRESTUnpackSubscriptionResponseDecodeFail
6009//
6010// stub stub
6011// +-------+ +---------+ +---------+
6012// | xapp | | submgr | | e2term |
6013// +-------+ +---------+ +---------+
6014// | | |
6015// | RestSubReq | |
6016// |---------------->| |
6017// | | |
6018// | RESTSubResp | |
6019// |<----------------| |
6020// | | |
6021// | | SubReq |
6022// | |------------->|
6023// | | |
6024// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02006025// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006026// | | |
6027// | | SubReq |
6028// | |------------->|
6029// | | |
6030// | | SubFail | Duplicated action
6031// | |<-------------|
6032// | RESTNotif (fail)| |
6033// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006034// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006035// | [SUBS DELETE] |
6036// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006037//
6038//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006039
Anssi Mannila51122392021-05-25 11:51:31 +03006040func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006041 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
Anssi Mannila21782182021-12-10 10:56:02 +02006042
6043 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6044 Counter{cRestSubReqFromXapp, 1},
6045 Counter{cRestSubRespToXapp, 1},
6046 Counter{cSubReqToE2, 1},
6047 Counter{cSubReqTimerExpiry, 1},
6048 Counter{cSubReReqToE2, 1},
6049 Counter{cSubRespFromE2, 1},
6050 Counter{cSubFailFromE2, 1},
6051 Counter{cRestSubFailNotifToXapp, 1},
6052 Counter{cRestSubDelReqFromXapp, 1},
6053 Counter{cRestSubDelRespToXapp, 1},
6054 })
6055
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006056 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006057
6058 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006059 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006060 restSubId := xappConn1.SendRESTSubsReq(t, params)
6061
6062 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6063 // Decode of this response fails which will result resending original request
6064 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6065
6066 _, cremsg = e2termConn1.RecvSubsReq(t)
6067
Markku Virtanen55d2a282021-06-04 14:46:56 +03006068 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006069
6070 // Subscription already created in E2 Node.
6071 fparams := &teststube2ap.E2StubSubsFailParams{}
6072 fparams.Set(crereq)
6073 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6074 e2termConn1.SendSubsFail(t, fparams, cremsg)
6075
Anssi Mannila51122392021-05-25 11:51:31 +03006076 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006077 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006078
Anssi Mannilab43397e2021-11-16 12:06:16 +02006079 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6080
Anssi Mannila51122392021-05-25 11:51:31 +03006081 // Wait that subs is cleaned
6082 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6083
6084 xappConn1.TestMsgChanEmpty(t)
6085 e2termConn1.TestMsgChanEmpty(t)
6086 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006087 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006088 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006089}
6090
6091//-----------------------------------------------------------------------------
6092// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6093//
6094// stub stub
6095// +-------+ +---------+ +---------+
6096// | xapp | | submgr | | e2term |
6097// +-------+ +---------+ +---------+
6098// | | |
6099// | RestSubReq | |
6100// |---------------->| |
6101// | | |
6102// | RESTSubResp | |
6103// |<----------------| |
6104// | | |
6105// | | SubReq |
6106// | |------------->|
6107// | | |
6108// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02006109// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03006110// | | |
6111// | | SubReq |
6112// | |------------->|
6113// | | |
6114// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02006115// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03006116// | RESTNotif (fail)| |
6117// |<----------------| |
6118// | | SubDelReq |
6119// | |------------->|
6120// | | |
6121// | | SubDelResp |
6122// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02006123// | | |
6124// | [SUBS DELETE] |
6125// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006126//
6127//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006128
Anssi Mannila51122392021-05-25 11:51:31 +03006129func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006130 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
Anssi Mannila21782182021-12-10 10:56:02 +02006131
6132 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6133 Counter{cRestSubReqFromXapp, 1},
6134 Counter{cRestSubRespToXapp, 1},
6135 Counter{cSubReqToE2, 1},
6136 Counter{cSubReqTimerExpiry, 2},
6137 Counter{cSubReReqToE2, 1},
6138 Counter{cSubRespFromE2, 1},
6139 Counter{cSubFailFromE2, 1},
6140 Counter{cRestSubFailNotifToXapp, 1},
6141 Counter{cRestSubDelReqFromXapp, 1},
6142 Counter{cRestSubDelRespToXapp, 1},
6143 Counter{cSubDelReqToE2, 1},
6144 Counter{cSubDelRespFromE2, 1},
6145 })
6146
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006147 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006148
6149 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006150 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006151 restSubId := xappConn1.SendRESTSubsReq(t, params)
6152
6153 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6154
Anssi Mannila21782182021-12-10 10:56:02 +02006155 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03006156 orgInstanceId := crereq.RequestId.InstanceId
6157 crereq.RequestId.InstanceId = 0
6158 e2termConn1.SendSubsResp(t, crereq, cremsg)
6159
6160 _, cremsg = e2termConn1.RecvSubsReq(t)
6161
Markku Virtanen55d2a282021-06-04 14:46:56 +03006162 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006163
Anssi Mannila21782182021-12-10 10:56:02 +02006164 // 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 +03006165 fparams := &teststube2ap.E2StubSubsFailParams{}
6166 fparams.Set(crereq)
6167 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6168 e2termConn1.SendSubsFail(t, fparams, cremsg)
6169
6170 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6171 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6172
6173 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006174 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006175
Anssi Mannilab43397e2021-11-16 12:06:16 +02006176 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6177
Anssi Mannila51122392021-05-25 11:51:31 +03006178 // Wait that subs is cleaned
6179 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6180
6181 xappConn1.TestMsgChanEmpty(t)
6182 e2termConn1.TestMsgChanEmpty(t)
6183 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006184 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006185 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006186}
6187
6188//-----------------------------------------------------------------------------
6189// TestRESTUnpackSubscriptionResponseNoTransaction
6190//
6191// stub stub
6192// +-------+ +---------+ +---------+
6193// | xapp | | submgr | | e2term |
6194// +-------+ +---------+ +---------+
6195// | | |
6196// | RestSubReq | |
6197// |---------------->| |
6198// | | |
6199// | RESTSubResp | |
6200// |<----------------| |
6201// | | |
6202// | | SubReq |
6203// | |------------->|
6204// | | |
6205// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02006206// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006207// | | |
6208// | | SubReq |
6209// | |------------->|
6210// | | |
6211// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02006212// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03006213// | RESTNotif (fail)| |
6214// |<----------------| |
6215// | | SubDelReq |
6216// | |------------->|
6217// | | |
6218// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02006219// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006220// | | |
6221// | | SubDelReq |
6222// | |------------->|
6223// | | |
6224// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02006225// | |<-------------| Ongoing transaction not found.
6226// | | |
6227// | [SUBS DELETE] |
6228// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006229//
6230//-----------------------------------------------------------------------------
6231func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006232 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
Anssi Mannila21782182021-12-10 10:56:02 +02006233
6234 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6235 Counter{cRestSubReqFromXapp, 1},
6236 Counter{cRestSubRespToXapp, 1},
6237 Counter{cSubReqToE2, 1},
6238 Counter{cSubReqTimerExpiry, 2},
6239 Counter{cSubReReqToE2, 1},
6240 Counter{cSubRespFromE2, 1},
6241 Counter{cSubFailFromE2, 1},
6242 Counter{cRestSubFailNotifToXapp, 1},
6243 Counter{cRestSubDelReqFromXapp, 1},
6244 Counter{cRestSubDelRespToXapp, 1},
6245 Counter{cSubDelReqToE2, 1},
6246 Counter{cSubDelReqTimerExpiry, 2},
6247 Counter{cSubDelReReqToE2, 1},
6248 Counter{cSubDelRespFromE2, 2},
6249 })
6250
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006251 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006252
6253 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006254 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006255 restSubId := xappConn1.SendRESTSubsReq(t, params)
6256
6257 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6258
6259 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6260 // No transaction exist for this response which will result resending original request
6261 e2termConn1.SendSubsResp(t, crereq, cremsg)
6262
6263 _, cremsg = e2termConn1.RecvSubsReq(t)
6264
Markku Virtanen55d2a282021-06-04 14:46:56 +03006265 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006266
6267 // Subscription already created in E2 Node.
6268 fparams := &teststube2ap.E2StubSubsFailParams{}
6269 fparams.Set(crereq)
6270 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6271 e2termConn1.SendSubsFail(t, fparams, cremsg)
6272
6273 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6275
6276 // Resending happens because there no transaction
6277 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6278 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6279
6280 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006281 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006282
Anssi Mannilab43397e2021-11-16 12:06:16 +02006283 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6284
Anssi Mannila51122392021-05-25 11:51:31 +03006285 // Wait that subs is cleaned
6286 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6287
6288 xappConn1.TestMsgChanEmpty(t)
6289 e2termConn1.TestMsgChanEmpty(t)
6290 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006291 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006292 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006293}
6294
6295//-----------------------------------------------------------------------------
6296// TestRESTUnpackSubscriptionFailureDecodeFail
6297//
6298// stub stub
6299// +-------+ +---------+ +---------+
6300// | xapp | | submgr | | e2term |
6301// +-------+ +---------+ +---------+
6302// | | |
6303// | RestSubReq | |
6304// |---------------->| |
6305// | | |
6306// | RESTSubResp | |
6307// |<----------------| |
6308// | | |
6309// | | SubReq |
6310// | |------------->|
6311// | | |
6312// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02006313// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006314// | | |
6315// | | SubReq |
6316// | |------------->|
6317// | | |
6318// | | SubFail | Duplicated action
6319// | |<-------------|
6320// | RESTNotif (fail)| |
6321// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006322// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006323// | [SUBS DELETE] |
6324// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006325//
6326//-----------------------------------------------------------------------------
6327func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006328 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
Anssi Mannila21782182021-12-10 10:56:02 +02006329
6330 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6331 Counter{cRestSubReqFromXapp, 1},
6332 Counter{cRestSubRespToXapp, 1},
6333 Counter{cSubReqToE2, 1},
6334 Counter{cSubReqTimerExpiry, 1},
6335 Counter{cSubReReqToE2, 1},
6336 Counter{cSubFailFromE2, 2},
6337 Counter{cRestSubFailNotifToXapp, 1},
6338 Counter{cRestSubDelReqFromXapp, 1},
6339 Counter{cRestSubDelRespToXapp, 1},
6340 })
6341
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006342 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006343
6344 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006345 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006346 restSubId := xappConn1.SendRESTSubsReq(t, params)
6347
6348 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6349
6350 // Decode of this response fails which will result resending original request
6351 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6352
6353 _, cremsg = e2termConn1.RecvSubsReq(t)
6354
Markku Virtanen55d2a282021-06-04 14:46:56 +03006355 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006356
6357 // Subscription already created in E2 Node.
6358 fparams := &teststube2ap.E2StubSubsFailParams{}
6359 fparams.Set(crereq)
6360 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6361 e2termConn1.SendSubsFail(t, fparams, cremsg)
6362
Anssi Mannila51122392021-05-25 11:51:31 +03006363 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006364 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006365
Anssi Mannilab43397e2021-11-16 12:06:16 +02006366 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6367
Anssi Mannila51122392021-05-25 11:51:31 +03006368 // Wait that subs is cleaned
6369 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6370
6371 xappConn1.TestMsgChanEmpty(t)
6372 e2termConn1.TestMsgChanEmpty(t)
6373 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006374 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006375 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006376}
6377
6378//-----------------------------------------------------------------------------
6379// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6380//
6381// stub stub
6382// +-------+ +---------+ +---------+
6383// | xapp | | submgr | | e2term |
6384// +-------+ +---------+ +---------+
6385// | | |
6386// | RestSubReq | |
6387// |---------------->| |
6388// | | |
6389// | RESTSubResp | |
6390// |<----------------| |
6391// | | |
6392// | | SubReq |
6393// | |------------->|
6394// | | |
6395// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02006396// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006397// | | |
6398// | | SubReq |
6399// | |------------->|
6400// | | |
6401// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02006402// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03006403// | RESTNotif (fail)| |
6404// |<----------------| |
6405// | | SubDelReq |
6406// | |------------->|
6407// | | |
6408// | | SubDelResp |
6409// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02006410// | | |
6411// | [SUBS DELETE] |
6412// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006413//
6414//-----------------------------------------------------------------------------
6415func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006416 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6417 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006418
Anssi Mannila21782182021-12-10 10:56:02 +02006419 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6420 Counter{cRestSubReqFromXapp, 1},
6421 Counter{cRestSubRespToXapp, 1},
6422 Counter{cSubReqToE2, 1},
6423 Counter{cSubReqTimerExpiry, 2},
6424 Counter{cSubReReqToE2, 1},
6425 Counter{cSubFailFromE2, 2},
6426 Counter{cRestSubFailNotifToXapp, 1},
6427 Counter{cRestSubDelReqFromXapp, 1},
6428 Counter{cRestSubDelRespToXapp, 1},
6429 Counter{cSubDelReqToE2, 1},
6430 Counter{cSubDelRespFromE2, 1},
6431 })
6432
Anssi Mannila51122392021-05-25 11:51:31 +03006433 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006434 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006435 restSubId := xappConn1.SendRESTSubsReq(t, params)
6436
6437 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6438
Anssi Mannila21782182021-12-10 10:56:02 +02006439 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03006440 fparams := &teststube2ap.E2StubSubsFailParams{}
6441 fparams.Set(crereq)
6442 fparams.Fail.RequestId.InstanceId = 0
6443 e2termConn1.SendSubsFail(t, fparams, cremsg)
6444
6445 _, cremsg = e2termConn1.RecvSubsReq(t)
6446
Markku Virtanen55d2a282021-06-04 14:46:56 +03006447 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006448
Anssi Mannila21782182021-12-10 10:56:02 +02006449 // 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 +03006450 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6451 e2termConn1.SendSubsFail(t, fparams, cremsg)
6452
6453 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6454 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6455
6456 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006457 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006458
Anssi Mannilab43397e2021-11-16 12:06:16 +02006459 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6460
Anssi Mannila51122392021-05-25 11:51:31 +03006461 // Wait that subs is cleaned
6462 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6463
6464 xappConn1.TestMsgChanEmpty(t)
6465 e2termConn1.TestMsgChanEmpty(t)
6466 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006467 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006468 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006469}
6470
6471//-----------------------------------------------------------------------------
6472// TestRESTUnpackSubscriptionFailureNoTransaction
6473//
6474// stub stub
6475// +-------+ +---------+ +---------+
6476// | xapp | | submgr | | e2term |
6477// +-------+ +---------+ +---------+
6478// | | |
6479// | RestSubReq | |
6480// |---------------->| |
6481// | | |
6482// | RESTSubResp | |
6483// |<----------------| |
6484// | | |
6485// | | SubReq |
6486// | |------------->|
6487// | | |
6488// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02006489// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006490// | | |
6491// | | SubReq |
6492// | |------------->|
6493// | | |
6494// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02006495// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03006496// | RESTNotif (fail)| |
6497// |<----------------| |
6498// | | SubDelReq |
6499// | |------------->|
6500// | | |
6501// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02006502// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
6503// | | |
6504// | | SubDelReq |
6505// | |------------->|
6506// | | |
6507// | | SubDelResp |
6508// | |<-------------| Ongoing transaction not found.
6509// | | |
6510// | [SUBS DELETE] |
6511// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006512//
6513//-----------------------------------------------------------------------------
6514func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006515 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6516 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006517
Anssi Mannila21782182021-12-10 10:56:02 +02006518 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6519 Counter{cRestSubReqFromXapp, 1},
6520 Counter{cRestSubRespToXapp, 1},
6521 Counter{cSubReqToE2, 1},
6522 Counter{cSubReqTimerExpiry, 2},
6523 Counter{cSubReReqToE2, 1},
6524 Counter{cSubFailFromE2, 2},
6525 Counter{cRestSubFailNotifToXapp, 1},
6526 Counter{cRestSubDelReqFromXapp, 1},
6527 Counter{cRestSubDelRespToXapp, 1},
6528 Counter{cSubDelReqToE2, 1},
6529 Counter{cSubDelReqTimerExpiry, 2},
6530 Counter{cSubDelReReqToE2, 1},
6531 Counter{cSubDelRespFromE2, 2},
6532 })
6533
Anssi Mannila51122392021-05-25 11:51:31 +03006534 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006535 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006536 restSubId := xappConn1.SendRESTSubsReq(t, params)
6537
6538 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6539
6540 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6541
6542 // No transaction exist for this response which will result resending original request
6543 fparams := &teststube2ap.E2StubSubsFailParams{}
6544 fparams.Set(crereq)
6545 e2termConn1.SendSubsFail(t, fparams, cremsg)
6546
6547 _, cremsg = e2termConn1.RecvSubsReq(t)
6548
Markku Virtanen55d2a282021-06-04 14:46:56 +03006549 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006550
6551 // Subscription already created in E2 Node.
6552 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6553 e2termConn1.SendSubsFail(t, fparams, cremsg)
6554
6555 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6556 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6557
6558 // Resending happens because there no transaction
6559 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6561
6562 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006563 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006564
Anssi Mannilab43397e2021-11-16 12:06:16 +02006565 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6566
Anssi Mannila51122392021-05-25 11:51:31 +03006567 // Wait that subs is cleaned
6568 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6569
6570 xappConn1.TestMsgChanEmpty(t)
6571 e2termConn1.TestMsgChanEmpty(t)
6572 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006573 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006574 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006575}
6576
6577//-----------------------------------------------------------------------------
6578// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6579//
6580// stub stub
6581// +-------+ +---------+ +---------+
6582// | xapp | | submgr | | e2term |
6583// +-------+ +---------+ +---------+
6584// | | |
6585// | [SUBS CREATE] |
6586// | | |
6587// | | |
6588// | RESTSubDelReq | |
6589// |---------------->| |
6590// | | |
6591// | RESTSubDelResp | |
6592// |<----------------| |
6593// | | |
6594// | | SubDelReq |
6595// | |------------->|
6596// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006597// | | SubDelResp | ASN.1 decode fails.
6598// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006599// | | |
6600// | | SubDelReq |
6601// | |------------->|
6602// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006603// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03006604// | |<-------------|
6605// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006606// | [SUBS DELETE] |
6607// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006608//
6609//-----------------------------------------------------------------------------
6610func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006611 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006612
Anssi Mannila21782182021-12-10 10:56:02 +02006613 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6614 Counter{cRestSubReqFromXapp, 1},
6615 Counter{cRestSubRespToXapp, 1},
6616 Counter{cSubReqToE2, 1},
6617 Counter{cSubRespFromE2, 1},
6618 Counter{cRestSubNotifToXapp, 1},
6619 Counter{cRestSubDelReqFromXapp, 1},
6620 Counter{cRestSubDelRespToXapp, 1},
6621 Counter{cSubDelReqToE2, 1},
6622 Counter{cSubDelReqTimerExpiry, 1},
6623 Counter{cSubDelReReqToE2, 1},
6624 Counter{cSubDelFailFromE2, 1},
6625 Counter{cSubDelRespFromE2, 1},
6626 })
6627
Anssi Mannila51122392021-05-25 11:51:31 +03006628 // Req
6629 var params *teststube2ap.RESTSubsReqParams = nil
6630 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6631
6632 // Del
6633 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6634
6635 // E2t: Receive 1st SubsDelReq
6636 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6637
6638 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02006639 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03006640
6641 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6642 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6643
6644 // Subscription does not exist in in E2 Node.
6645 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6646
6647 // Wait that subs is cleaned
6648 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6649
6650 xappConn1.TestMsgChanEmpty(t)
6651 e2termConn1.TestMsgChanEmpty(t)
6652 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006653 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006654 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006655}
6656
6657//-----------------------------------------------------------------------------
6658// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6659//
6660// stub stub
6661// +-------+ +---------+ +---------+
6662// | xapp | | submgr | | e2term |
6663// +-------+ +---------+ +---------+
6664// | | |
6665// | [SUBS CREATE] |
6666// | | |
6667// | | |
6668// | RESTSubDelReq | |
6669// |---------------->| |
6670// | | |
6671// | RESTSubDelResp | |
6672// |<----------------| |
6673// | | |
6674// | | SubDelReq |
6675// | |------------->|
6676// | | |
6677// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02006678// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006679// | | |
6680// | | SubDelReq |
6681// | |------------->|
6682// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006683// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03006684// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02006685// | | |
6686// | [SUBS DELETE] |
6687// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006688//-----------------------------------------------------------------------------
6689func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006690 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006691
Anssi Mannila21782182021-12-10 10:56:02 +02006692 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6693 Counter{cRestSubReqFromXapp, 1},
6694 Counter{cRestSubRespToXapp, 1},
6695 Counter{cSubReqToE2, 1},
6696 Counter{cSubRespFromE2, 1},
6697 Counter{cRestSubNotifToXapp, 1},
6698 Counter{cRestSubDelReqFromXapp, 1},
6699 Counter{cRestSubDelRespToXapp, 1},
6700 Counter{cSubDelReqToE2, 1},
6701 Counter{cSubDelReqTimerExpiry, 1},
6702 Counter{cSubDelReReqToE2, 1},
6703 Counter{cSubDelRespFromE2, 1},
6704 Counter{cSubDelFailFromE2, 1},
6705 })
6706
Anssi Mannila51122392021-05-25 11:51:31 +03006707 // Req
6708 var params *teststube2ap.RESTSubsReqParams = nil
6709 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6710
6711 // Del
6712 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6713
6714 // E2t: Receive 1st SubsDelReq
6715 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6716
6717 // Unknown instanceId in this response which will result resending original request
6718 delreq.RequestId.InstanceId = 0
6719 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6720
6721 // E2t: Receive 2nd SubsDelReq
6722 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6723
6724 // Subscription does not exist in in E2 Node.
6725 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6726
6727 // Wait that subs is cleaned
6728 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6729
6730 xappConn1.TestMsgChanEmpty(t)
6731 e2termConn1.TestMsgChanEmpty(t)
6732 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006733 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006734 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006735}
6736
6737//-----------------------------------------------------------------------------
6738// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6739//
6740// stub stub
6741// +-------+ +---------+ +---------+
6742// | xapp | | submgr | | e2term |
6743// +-------+ +---------+ +---------+
6744// | | |
6745// | [SUBS CREATE] |
6746// | | |
6747// | | |
6748// | RESTSubDelReq | |
6749// |---------------->| |
6750// | | |
6751// | RESTSubDelResp | |
6752// |<----------------| |
6753// | | |
6754// | | SubDelReq |
6755// | |------------->|
6756// | | |
6757// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02006758// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006759// | | |
6760// | | SubDelReq |
6761// | |------------->|
6762// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006763// | | SubDelFail | Subscription does exist any more in E2 node
6764// | |<-------------| Ongoing transaction not found. This will result timer expiry
6765// | | |
6766// | [SUBS DELETE] |
6767// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006768//-----------------------------------------------------------------------------
6769func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006770 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006771
Anssi Mannila21782182021-12-10 10:56:02 +02006772 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6773 Counter{cRestSubReqFromXapp, 1},
6774 Counter{cRestSubRespToXapp, 1},
6775 Counter{cSubReqToE2, 1},
6776 Counter{cSubRespFromE2, 1},
6777 Counter{cRestSubNotifToXapp, 1},
6778 Counter{cRestSubDelReqFromXapp, 1},
6779 Counter{cRestSubDelRespToXapp, 1},
6780 Counter{cSubDelReqToE2, 1},
6781 Counter{cSubDelReqTimerExpiry, 2},
6782 Counter{cSubDelReReqToE2, 1},
6783 Counter{cSubDelRespFromE2, 1},
6784 Counter{cSubDelFailFromE2, 1},
6785 })
6786
Anssi Mannila51122392021-05-25 11:51:31 +03006787 // Req
6788 var params *teststube2ap.RESTSubsReqParams = nil
6789 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6790
6791 // Del
6792 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6793
6794 // E2t: Receive 1st SubsDelReq
6795 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6796
6797 mainCtrl.MakeTransactionNil(t, e2SubsId)
6798
6799 // No transaction exist for this response which will result resending original request
6800 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6801
6802 // E2t: Receive 2nd SubsDelReq
6803 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6804
6805 // Subscription does not exist in in E2 Node.
6806 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6807
6808 // Wait that subs is cleaned
6809 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6810
6811 xappConn1.TestMsgChanEmpty(t)
6812 e2termConn1.TestMsgChanEmpty(t)
6813 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006814 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006815 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006816}
6817
6818//-----------------------------------------------------------------------------
6819// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6820//
6821// stub stub
6822// +-------+ +---------+ +---------+
6823// | xapp | | submgr | | e2term |
6824// +-------+ +---------+ +---------+
6825// | | |
6826// | [SUBS CREATE] |
6827// | | |
6828// | | |
6829// | RESTSubDelReq | |
6830// |---------------->| |
6831// | | |
6832// | RESTSubDelResp | |
6833// |<----------------| |
6834// | | |
6835// | | SubDelReq |
6836// | |------------->|
6837// | | |
6838// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02006839// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006840// | | |
6841// | | SubDelReq |
6842// | |------------->|
6843// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006844// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03006845// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02006846// | | |
6847// | [SUBS DELETE] |
6848// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006849//-----------------------------------------------------------------------------
6850func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006851 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006852
Anssi Mannila21782182021-12-10 10:56:02 +02006853 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6854 Counter{cRestSubReqFromXapp, 1},
6855 Counter{cRestSubRespToXapp, 1},
6856 Counter{cSubReqToE2, 1},
6857 Counter{cSubRespFromE2, 1},
6858 Counter{cRestSubNotifToXapp, 1},
6859 Counter{cRestSubDelReqFromXapp, 1},
6860 Counter{cRestSubDelRespToXapp, 1},
6861 Counter{cSubDelReqToE2, 1},
6862 Counter{cSubDelReqTimerExpiry, 1},
6863 Counter{cSubDelReReqToE2, 1},
6864 Counter{cSubDelFailFromE2, 2},
6865 })
6866
Anssi Mannila51122392021-05-25 11:51:31 +03006867 // Req
6868 var params *teststube2ap.RESTSubsReqParams = nil
6869 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6870
6871 // Del
6872 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6873
6874 // E2t: Receive 1st SubsDelReq
6875 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6876
6877 // Decode of this response fails which will result resending original request
6878 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6879
6880 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6881 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6882
6883 // Subscription does not exist in in E2 Node.
6884 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6885
6886 // Wait that subs is cleaned
6887 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6888
6889 xappConn1.TestMsgChanEmpty(t)
6890 e2termConn1.TestMsgChanEmpty(t)
6891 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006892 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006893 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006894}
6895
6896//-----------------------------------------------------------------------------
6897// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6898//
6899// stub stub
6900// +-------+ +---------+ +---------+
6901// | xapp | | submgr | | e2term |
6902// +-------+ +---------+ +---------+
6903// | | |
6904// | [SUBS CREATE] |
6905// | | |
6906// | | |
6907// | RESTSubDelReq | |
6908// |---------------->| |
6909// | | |
6910// | RESTSubDelResp | |
6911// |<----------------| |
6912// | | |
6913// | | SubDelReq |
6914// | |------------->|
6915// | | |
6916// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02006917// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006918// | | |
6919// | | SubDelReq |
6920// | |------------->|
6921// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02006922// | | SubDelFail | Subscription does exist any more in E2 node
6923// | |<-------------| No valid subscription found with subIds [0].
6924// | | |
6925// | [SUBS DELETE] |
6926// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006927//-----------------------------------------------------------------------------
6928func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006929 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006930
Anssi Mannila21782182021-12-10 10:56:02 +02006931 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6932 Counter{cRestSubReqFromXapp, 1},
6933 Counter{cRestSubRespToXapp, 1},
6934 Counter{cSubReqToE2, 1},
6935 Counter{cSubRespFromE2, 1},
6936 Counter{cRestSubNotifToXapp, 1},
6937 Counter{cRestSubDelReqFromXapp, 1},
6938 Counter{cRestSubDelRespToXapp, 1},
6939 Counter{cSubDelReqToE2, 1},
6940 Counter{cSubDelReqTimerExpiry, 1},
6941 Counter{cSubDelReReqToE2, 1},
6942 Counter{cSubDelFailFromE2, 2},
6943 })
6944
Anssi Mannila51122392021-05-25 11:51:31 +03006945 // Req
6946 var params *teststube2ap.RESTSubsReqParams = nil
6947 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6948
6949 // Del
6950 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6951
6952 // E2t: Receive 1st SubsDelReq
6953 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6954
Anssi Mannila21782182021-12-10 10:56:02 +02006955 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03006956 delreq.RequestId.InstanceId = 0
6957 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6958
6959 // E2t: Receive 2nd SubsDelReq
6960 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6961
Anssi Mannila21782182021-12-10 10:56:02 +02006962 // 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 +03006963 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6964
6965 // Wait that subs is cleaned
6966 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6967
6968 xappConn1.TestMsgChanEmpty(t)
6969 e2termConn1.TestMsgChanEmpty(t)
6970 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006971 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006972 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006973}
6974
6975//-----------------------------------------------------------------------------
6976// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6977//
6978// stub stub
6979// +-------+ +---------+ +---------+
6980// | xapp | | submgr | | e2term |
6981// +-------+ +---------+ +---------+
6982// | | |
6983// | [SUBS CREATE] |
6984// | | |
6985// | | |
6986// | RESTSubDelReq | |
6987// |---------------->| |
6988// | | |
6989// | RESTSubDelResp | |
6990// |<----------------| |
6991// | | |
6992// | | SubDelReq |
6993// | |------------->|
6994// | | |
6995// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02006996// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03006997// | | |
6998// | | SubDelReq |
6999// | |------------->|
7000// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007001// | | SubDelFail | Subscription does exist any more in E2 node
7002// | |<-------------| Ongoing transaction not found. This will result timer expiry
7003// | | |
7004// | [SUBS DELETE] |
7005// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007006//-----------------------------------------------------------------------------
7007func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007008 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03007009
Anssi Mannila21782182021-12-10 10:56:02 +02007010 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7011 Counter{cRestSubReqFromXapp, 1},
7012 Counter{cRestSubRespToXapp, 1},
7013 Counter{cSubReqToE2, 1},
7014 Counter{cSubRespFromE2, 1},
7015 Counter{cRestSubNotifToXapp, 1},
7016 Counter{cRestSubDelReqFromXapp, 1},
7017 Counter{cRestSubDelRespToXapp, 1},
7018 Counter{cSubDelReqToE2, 1},
7019 Counter{cSubDelReqTimerExpiry, 2},
7020 Counter{cSubDelReReqToE2, 1},
7021 Counter{cSubDelFailFromE2, 2},
7022 })
7023
Anssi Mannila51122392021-05-25 11:51:31 +03007024 // Req
7025 var params *teststube2ap.RESTSubsReqParams = nil
7026 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7027
7028 // Del
7029 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7030
7031 // E2t: Receive 1st SubsDelReq
7032 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7033
7034 mainCtrl.MakeTransactionNil(t, e2SubsId)
7035
7036 // No transaction exist for this response which will result resending original request
7037 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7038
7039 // E2t: Receive 2nd SubsDelReq
7040 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7041
7042 // Subscription does not exist in in E2 Node.
7043 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7044
7045 // Wait that subs is cleaned
7046 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7047
7048 xappConn1.TestMsgChanEmpty(t)
7049 e2termConn1.TestMsgChanEmpty(t)
7050 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007051 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007052 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007053}
7054
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007055//-----------------------------------------------------------------------------
7056// TestRESTSubReqFailAsn1PackSubReqError
7057//
7058// stub stub
7059// +-------+ +---------+ +---------+
7060// | xapp | | submgr | | e2term |
7061// +-------+ +---------+ +---------+
7062// | | |
7063// | RESTSubReq | |
7064// |---------------->| |
7065// | | |
7066// | RESTSubResp | |
7067// |<----------------| |
7068// | | |
7069// | ASN.1 encode fails |
7070// | | |
7071// | | SubDelReq |
7072// | |------------->|
7073// | | |
7074// | | SubDelFail |
7075// | |<-------------|
7076// | | |
7077// | RESTNotif | |
7078// | unsuccess | |
7079// |<----------------| |
7080// | | |
7081// | [SUBS DELETE] |
7082// | | |
7083//
7084//-----------------------------------------------------------------------------
7085func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
7086
7087 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007088 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007089 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007090 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02007091 Counter{cRestSubDelReqFromXapp, 1},
7092 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007093 })
7094
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007095 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007096
7097 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007098 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007099 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
7100
7101 // Req
7102 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007103 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007104
7105 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03007106 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007107
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007108 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007109 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007110
7111 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007112
7113 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7114
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007115 // Wait that subs is cleaned
7116 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007117 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007118 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00007119}
7120
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007121func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
7122 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
7123
7124 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7125 Counter{cRestSubReqFromXapp, 2},
7126 Counter{cRestSubRespToXapp, 2},
7127 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02007128 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007129 Counter{cSubRespFromE2, 1},
7130 Counter{cRestSubNotifToXapp, 1},
7131 Counter{cRestSubFailNotifToXapp, 1},
7132 Counter{cRestSubDelReqFromXapp, 1},
7133 Counter{cSubDelReqToE2, 1},
7134 Counter{cSubDelRespFromE2, 1},
7135 Counter{cRestSubDelRespToXapp, 1},
7136 })
7137
7138 const e2Timeout int64 = 1
7139 const e2RetryCount int64 = 0
7140 const routingNeeded bool = false
7141
7142 // Req1
7143 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7144 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7145
7146 // Subs Create
7147 restSubId := xappConn1.SendRESTSubsReq(t, params)
7148 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7149
7150 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7151 xappConn1.ExpectRESTNotification(t, restSubId)
7152 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7153 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7154 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7155
7156 // Policy change
7157 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7158 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7159 params.SetSubscriptionID(&restSubId)
7160 params.SetTimeToWait("w200ms")
7161 restSubId = xappConn1.SendRESTSubsReq(t, params)
7162 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7163
7164 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7165 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03007166 // SubsResp is missing, e2SubsId will be 0
7167 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7168 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007169
7170 // Del
7171 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7172 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7173 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7174
7175 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007176 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007177 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007178}
7179
7180//-----------------------------------------------------------------------------
7181// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
7182//
7183// stub stub
7184// +-------+ +---------+ +---------+
7185// | xapp | | submgr | | e2term |
7186// +-------+ +---------+ +---------+
7187// | | |
7188// | RESTSubReq | |
7189// |---------------->| |
7190// | | |
7191// | RESTSubResp | |
7192// |<----------------| |
7193// | | SubReq |
7194// | |------------->|
7195// | | |
7196// | | SubResp |
7197// | |<-------------|
7198// | | |
7199// | RESTNotif | |
7200// |<----------------| |
7201// | | |
7202// | RESTSubReq | |
7203// |---------------->| |
7204// | | |
7205// | RESTSubResp | |
7206// |<----------------| |
7207// | | SubReq |
7208// | |------------->|
7209// | |
7210// | Submgr restart |
7211// | | |
7212// | RESTSubDelReq | |
7213// |---------------->| |
7214// | | |
7215// | | SubDelReq |
7216// | |------------->|
7217// | | |
7218// | | SubDelResp |
7219// | |<-------------|
7220// | | |
7221// | RESTSubDelResp | |
7222// |<----------------| |
7223//
7224//-----------------------------------------------------------------------------
7225
7226func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
7227 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
7228
7229 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7230 Counter{cRestSubReqFromXapp, 2},
7231 Counter{cRestSubRespToXapp, 2},
7232 Counter{cSubReqToE2, 2},
7233 Counter{cSubRespFromE2, 1},
7234 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007235 Counter{cRestSubDelReqFromXapp, 1},
7236 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02007237 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007238 Counter{cRestSubDelRespToXapp, 1},
7239 })
7240
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007241 const e2Timeout int64 = 1
7242 const e2RetryCount int64 = 0
7243 const routingNeeded bool = false
7244
7245 // Req1
7246 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7247 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7248 // Create subscription
7249 restSubId := xappConn1.SendRESTSubsReq(t, params)
7250 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7251
7252 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7253 xappConn1.ExpectRESTNotification(t, restSubId)
7254 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7255 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7256 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7257
7258 // Check subscription
7259 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7260
7261 // Policy change
7262 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7263 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7264 params.SetSubscriptionID(&restSubId)
7265 params.SetTimeToWait("w200ms")
7266 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7267 restSubId = xappConn1.SendRESTSubsReq(t, params)
7268 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7269
7270 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7271 mainCtrl.SetResetTestFlag(t, false)
7272
7273 // SubsResp is missing due to submgr restart
7274
7275 mainCtrl.SimulateRestart(t)
7276 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7277
Anssi Mannila54838ed2021-11-19 11:25:01 +02007278 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
7279 // That needs to be completed before successful subscription query is possible
7280 <-time.After(time.Second * 1)
7281
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007282 // Check subscription
7283 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7284
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007285 // Delete subscription
7286 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7287 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7288 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7289
7290 //Wait that subs is cleaned
7291 waitSubsCleanup(t, e2SubsId, 10)
7292
7293 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007294 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007295}
7296
archaggeafbf95f2021-04-14 08:54:05 +03007297////////////////////////////////////////////////////////////////////////////////////
7298// Services for UT cases
7299////////////////////////////////////////////////////////////////////////////////////
7300const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007301const host string = "localhost"
7302
7303func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7304 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007305 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007306 }
7307 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007308 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007309
7310 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7311 fromXappConn.ExpectRESTNotification(t, restSubId)
7312 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7313 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007314 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007315
7316 return restSubId, e2SubsId
7317}
7318
7319func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7320
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007321 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007322 if meid != "" {
7323 params.SetMeid(meid)
7324 }
7325 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7326 restSubId := xappConn2.SendRESTSubsReq(t, params)
7327 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007328 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007329 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007330 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007331
7332 return restSubId, e2SubsId
7333}
7334
7335func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007336
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007337 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007338 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007339 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007340
7341 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7342 xappConn1.ExpectRESTNotification(t, restSubId)
7343 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7344 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007345 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007346
7347 return restSubId, e2SubsId
7348}
7349
7350func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007351 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007352 restSubId := xappConn1.SendRESTSubsReq(t, params)
7353
7354 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7355 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7356 fparams1.Set(crereq1)
7357 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7358
7359 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7360 xappConn1.ExpectRESTNotification(t, restSubId)
7361 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7362 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007363 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007364
7365 return restSubId, e2SubsId
7366}
7367
7368func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7369 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7370 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7371 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7372}
7373
7374func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7375 xappConn1.SendRESTSubsDelReq(t, restSubId)
7376 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7377 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7378}
7379
7380func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7381 xappConn2.SendRESTSubsDelReq(t, restSubId)
7382 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7383 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7384}
7385
7386func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7387 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02007388 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
7389 assert.Equal(t, meid, resp[0].Meid)
7390 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03007391}
7392
7393func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7394 //Wait that subs is cleaned
7395 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7396
7397 xappConn1.TestMsgChanEmpty(t)
7398 xappConn2.TestMsgChanEmpty(t)
7399 e2termConn1.TestMsgChanEmpty(t)
7400 mainCtrl.wait_registry_empty(t, timeout)
7401}
7402
7403func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7404
7405 var e2SubsId []uint32
7406
7407 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007408 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007409 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7410 fromXappConn.ExpectRESTNotification(t, restSubId)
7411 toE2termConn.SendSubsResp(t, crereq, cremsg)
7412 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7413 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007414 xapp.Logger.Debug("TEST: %v", e2SubsId)
7415 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007416 <-time.After(100 * time.Millisecond)
7417 }
7418 return e2SubsId
7419}
7420
7421func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7422
7423 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007424 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007425 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7426 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7427 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007428 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007429 <-time.After(100 * time.Millisecond)
7430 }
7431
7432 // Wait that subs is cleaned
7433 for i := 0; i < len(e2SubsIds); i++ {
7434 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7435 }
7436
7437}