blob: 6ce7b5106e0b513787e3786a481f4d9d1337849f [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 Mannila3d80b722021-11-12 13:17:15 +0200100 //os.Exit(1)
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)
678
679 mainCtrl.VerifyCounterValues(t)
680}
681
682//-----------------------------------------------------------------------------
683// TestSubMergeDelAndRouteUpdateNok
684// stub stub
685// +-------+ +-------+ +---------+ +---------+
686// | xapp2 | | xapp1 | | submgr | | e2term |
687// +-------+ +-------+ +---------+ +---------+
688// | | | |
689// | | | |
690// | | | |
691// | | SubReq1 | |
692// | |------------->| |
693// | | | |
694// | | | SubReq1 |
695// | | |------------->|
696// | | | SubResp1 |
697// | | |<-------------|
698// | | SubResp1 | |
699// | |<-------------| |
700// | | | |
701// | SubReq2 | |
702// |--------------------------->| |
703// | | | |
704// | SubResp2 | |
705// |<---------------------------| |
706// | | | |
707// | | SubDelReq 1 | |
708// | |------------->| |
709// | | | RouteUpdate |
710// | | |-----> rtmgr |
711// | | | |
712// | | | RouteUpdate |
713// | | | status:400 |
714// | | |<----- rtmgr |
715// | | | |
716// | | SubDelResp 1 | |
717// | |<-------------| |
718// | | | |
719// | SubDelReq 2 | |
720// |--------------------------->| |
721// | | | |
722// | | | SubDelReq 2 |
723// | | |------------->|
724// | | | |
725// | | | SubDelReq 2 |
726// | | |------------->|
727// | | | |
728// | SubDelResp 2 | |
729// |<---------------------------| |
730//
731//-----------------------------------------------------------------------------
732func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
733 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
734
735 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200736 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
737 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200738 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200739 Counter{cSubReqToE2, 1},
740 Counter{cSubRespFromE2, 1},
741 Counter{cSubRespToXapp, 2},
742 Counter{cSubDelReqFromXapp, 2},
743 Counter{cRouteDeleteUpdateFail, 1},
744 Counter{cSubDelReqToE2, 1},
745 Counter{cSubDelRespFromE2, 1},
746 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200747 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200748 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200749
750 //Req1
751 rparams1 := &teststube2ap.E2StubSubsReqParams{}
752 rparams1.Init()
753 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
754 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
755 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
756 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
757
758 //Req2
759 rparams2 := &teststube2ap.E2StubSubsReqParams{}
760 rparams2.Init()
761 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
762 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
763
764 resp, _ := xapp.Subscription.QuerySubscriptions()
765 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
766 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300767 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200768
769 //Del1
770 waiter := rtmgrHttp.AllocNextEvent(false)
771 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
772 waiter.WaitResult(t)
773
774 xappConn1.RecvSubsDelResp(t, deltrans1)
775
776 //Del2
777 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
778 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
779 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
780 xappConn2.RecvSubsDelResp(t, deltrans2)
781 //Wait that subs is cleaned
782 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
783
784 xappConn1.TestMsgChanEmpty(t)
785 xappConn2.TestMsgChanEmpty(t)
786 e2termConn1.TestMsgChanEmpty(t)
787 mainCtrl.wait_registry_empty(t, 10)
788
789 mainCtrl.VerifyCounterValues(t)
790}
791
792//-----------------------------------------------------------------------------
793
794//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200795// TestSubReqAndSubDelOk
796//
797// stub stub
798// +-------+ +---------+ +---------+
799// | xapp | | submgr | | e2term |
800// +-------+ +---------+ +---------+
801// | | |
802// | SubReq | |
803// |------------->| |
804// | | |
805// | | SubReq |
806// | |------------->|
807// | | |
808// | | SubResp |
809// | |<-------------|
810// | | |
811// | SubResp | |
812// |<-------------| |
813// | | |
814// | | |
815// | SubDelReq | |
816// |------------->| |
817// | | |
818// | | SubDelReq |
819// | |------------->|
820// | | |
821// | | SubDelResp |
822// | |<-------------|
823// | | |
824// | SubDelResp | |
825// |<-------------| |
826//
827//-----------------------------------------------------------------------------
828func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200829 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200830
Anssi Mannila4abf1802021-01-28 13:06:46 +0200831 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200832 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
833 Counter{cSubReqFromXapp, 1},
834 Counter{cSubReqToE2, 1},
835 Counter{cSubRespFromE2, 1},
836 Counter{cSubRespToXapp, 1},
837 Counter{cSubDelReqFromXapp, 1},
838 Counter{cSubDelReqToE2, 1},
839 Counter{cSubDelRespFromE2, 1},
840 Counter{cSubDelRespToXapp, 1},
841 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200842
843 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200844 crereq, cremsg := e2termConn1.RecvSubsReq(t)
845 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200847
848 resp, _ := xapp.Subscription.QuerySubscriptions()
849 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
850 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300851 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200852
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200853 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200854 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200855
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200856 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200857 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200858
859 //Wait that subs is cleaned
860 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
861
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200862 xappConn1.TestMsgChanEmpty(t)
863 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200864 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200865 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200866
867 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200868}
869
870//-----------------------------------------------------------------------------
871// TestSubReqRetransmission
872//
873// stub stub
874// +-------+ +---------+ +---------+
875// | xapp | | submgr | | e2term |
876// +-------+ +---------+ +---------+
877// | | |
878// | SubReq | |
879// |------------->| |
880// | | |
881// | | SubReq |
882// | |------------->|
883// | | |
884// | SubReq | |
885// | (retrans) | |
886// |------------->| |
887// | | |
888// | | SubResp |
889// | |<-------------|
890// | | |
891// | SubResp | |
892// |<-------------| |
893// | | |
894// | [SUBS DELETE] |
895// | | |
896//
897//-----------------------------------------------------------------------------
898func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200899 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200900
901 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200902 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200903 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200904
905 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200906 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200907 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
908
Juha Hyttinen1683f912020-04-17 10:39:57 +0300909 // hack as there is no real way to see has message be handled.
910 // Previuos counter check just tells that is has been received by submgr
911 // --> artificial delay
912 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200913 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200914 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200915
916 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200917 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200918 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
919 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200920 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200921
922 //Wait that subs is cleaned
923 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
924
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200925 xappConn1.TestMsgChanEmpty(t)
926 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200927 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200928 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200929}
930
931//-----------------------------------------------------------------------------
932// TestSubDelReqRetransmission
933//
934// stub stub
935// +-------+ +---------+ +---------+
936// | xapp | | submgr | | e2term |
937// +-------+ +---------+ +---------+
938// | | |
939// | [SUBS CREATE] |
940// | | |
941// | | |
942// | SubDelReq | |
943// |------------->| |
944// | | |
945// | | SubDelReq |
946// | |------------->|
947// | | |
948// | SubDelReq | |
949// | (same sub) | |
950// | (same xid) | |
951// |------------->| |
952// | | |
953// | | SubDelResp |
954// | |<-------------|
955// | | |
956// | SubDelResp | |
957// |<-------------| |
958//
959//-----------------------------------------------------------------------------
960func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200961 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200962
963 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200964 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200965 crereq, cremsg := e2termConn1.RecvSubsReq(t)
966 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200967 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200968
969 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200970 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200971 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200972
973 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200974 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200975 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
976
Juha Hyttinen1683f912020-04-17 10:39:57 +0300977 // hack as there is no real way to see has message be handled.
978 // Previuos counter check just tells that is has been received by submgr
979 // --> artificial delay
980 <-time.After(1 * time.Second)
981
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200982 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200983 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200984
985 //Wait that subs is cleaned
986 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
987
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200988 xappConn1.TestMsgChanEmpty(t)
989 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200990 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200991 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200992}
993
994//-----------------------------------------------------------------------------
995// TestSubDelReqCollision
996//
997// stub stub
998// +-------+ +---------+ +---------+
999// | xapp | | submgr | | e2term |
1000// +-------+ +---------+ +---------+
1001// | | |
1002// | [SUBS CREATE] |
1003// | | |
1004// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001005// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006// |------------->| |
1007// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001008// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001009// | |------------->|
1010// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001011// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001012// | (same sub) | |
1013// | (diff xid) | |
1014// |------------->| |
1015// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001016// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001017// | |<-------------|
1018// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001019// | SubDelResp 1 | |
1020// |<-------------| |
1021// | | |
1022// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001023// |<-------------| |
1024//
1025//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001026
Juha Hyttinenfa015662020-01-24 10:05:18 +02001027func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001028 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001029
1030 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001031 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001032 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1033 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001034 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001035
1036 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001037 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001038 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001039
Juha Hyttinen3944a222020-01-24 11:51:46 +02001040 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001041 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001042 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1043 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001044 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1045
Juha Hyttinen1683f912020-04-17 10:39:57 +03001046 // hack as there is no real way to see has message be handled.
1047 // Previuos counter check just tells that is has been received by submgr
1048 // --> artificial delay
1049 <-time.After(1 * time.Second)
1050
Juha Hyttinen3944a222020-01-24 11:51:46 +02001051 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001052 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001053
1054 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001055 xappConn1.RecvSubsDelResp(t, nil)
1056 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001057
1058 //Wait that subs is cleaned
1059 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1060
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001061 xappConn1.TestMsgChanEmpty(t)
1062 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001063 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001064 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001065}
1066
1067//-----------------------------------------------------------------------------
1068// TestSubReqAndSubDelOkTwoParallel
1069//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001070// stub stub stub
1071// +-------+ +-------+ +---------+ +---------+
1072// | xapp | | xapp | | submgr | | e2term |
1073// +-------+ +-------+ +---------+ +---------+
1074// | | | |
1075// | | | |
1076// | | | |
1077// | | SubReq1 | |
1078// | |------------->| |
1079// | | | |
1080// | | | SubReq1 |
1081// | | |------------->|
1082// | | | |
1083// | SubReq2 | |
1084// |------------------------>| |
1085// | | | |
1086// | | | SubReq2 |
1087// | | |------------->|
1088// | | | |
1089// | | | SubResp1 |
1090// | | |<-------------|
1091// | | SubResp1 | |
1092// | |<-------------| |
1093// | | | |
1094// | | | SubResp2 |
1095// | | |<-------------|
1096// | SubResp2 | |
1097// |<------------------------| |
1098// | | | |
1099// | | [SUBS 1 DELETE] |
1100// | | | |
1101// | | [SUBS 2 DELETE] |
1102// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001103//
1104//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001105
Juha Hyttinenfa015662020-01-24 10:05:18 +02001106func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001107 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001108
1109 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001110 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001111 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001112 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001113 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001114
1115 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001116 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001117 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001118
1119 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1120 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1121 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1122
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001124 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001125
1126 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001127 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001129
1130 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001131 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001132 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001133
1134 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001135 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001136 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1137 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001138 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001139 //Wait that subs is cleaned
1140 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1141
1142 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001143 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001144 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1145 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001146 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147 //Wait that subs is cleaned
1148 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1149
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001150 xappConn1.TestMsgChanEmpty(t)
1151 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001152 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001153 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001154}
1155
1156//-----------------------------------------------------------------------------
1157// TestSameSubsDiffRan
1158// Same subscription to different RANs
1159//
1160// stub stub
1161// +-------+ +---------+ +---------+
1162// | xapp | | submgr | | e2term |
1163// +-------+ +---------+ +---------+
1164// | | |
1165// | | |
1166// | | |
1167// | SubReq(r1) | |
1168// |------------->| |
1169// | | |
1170// | | SubReq(r1) |
1171// | |------------->|
1172// | | |
1173// | | SubResp(r1) |
1174// | |<-------------|
1175// | | |
1176// | SubResp(r1) | |
1177// |<-------------| |
1178// | | |
1179// | SubReq(r2) | |
1180// |------------->| |
1181// | | |
1182// | | SubReq(r2) |
1183// | |------------->|
1184// | | |
1185// | | SubResp(r2) |
1186// | |<-------------|
1187// | | |
1188// | SubResp(r2) | |
1189// |<-------------| |
1190// | | |
1191// | [SUBS r1 DELETE] |
1192// | | |
1193// | [SUBS r2 DELETE] |
1194// | | |
1195//
1196//-----------------------------------------------------------------------------
1197func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001198 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001199
1200 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001201 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1202 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001203 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1204 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001205 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001206
1207 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001208 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1209 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001210 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1211 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001212 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001213
1214 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001215 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1216 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001217 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1218 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001220 //Wait that subs is cleaned
1221 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1222
1223 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001224 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1225 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001226 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1227 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001228 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001229 //Wait that subs is cleaned
1230 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1231
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001232 xappConn1.TestMsgChanEmpty(t)
1233 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001234 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001235 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001236}
1237
1238//-----------------------------------------------------------------------------
1239// TestSubReqRetryInSubmgr
1240//
1241// stub stub
1242// +-------+ +---------+ +---------+
1243// | xapp | | submgr | | e2term |
1244// +-------+ +---------+ +---------+
1245// | | |
1246// | SubReq | |
1247// |------------->| |
1248// | | |
1249// | | SubReq |
1250// | |------------->|
1251// | | |
1252// | | |
1253// | | SubReq |
1254// | |------------->|
1255// | | |
1256// | | SubResp |
1257// | |<-------------|
1258// | | |
1259// | SubResp | |
1260// |<-------------| |
1261// | | |
1262// | [SUBS DELETE] |
1263// | | |
1264//
1265//-----------------------------------------------------------------------------
1266
1267func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001268 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001269
1270 // Init counter check
1271 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1272 Counter{cSubReqFromXapp, 1},
1273 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001274 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001275 Counter{cSubReReqToE2, 1},
1276 Counter{cSubRespFromE2, 1},
1277 Counter{cSubRespToXapp, 1},
1278 Counter{cSubDelReqFromXapp, 1},
1279 Counter{cSubDelReqToE2, 1},
1280 Counter{cSubDelRespFromE2, 1},
1281 Counter{cSubDelRespToXapp, 1},
1282 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001283
1284 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001285 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001286
1287 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001288 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001289
1290 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001291 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1292 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001293
1294 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001295 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001296
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001297 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001298 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1299 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001300 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001301
1302 // Wait that subs is cleaned
1303 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1304
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001305 xappConn1.TestMsgChanEmpty(t)
1306 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001307 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001308 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001309
1310 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001311}
1312
1313//-----------------------------------------------------------------------------
1314// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1315//
1316// stub stub
1317// +-------+ +---------+ +---------+
1318// | xapp | | submgr | | e2term |
1319// +-------+ +---------+ +---------+
1320// | | |
1321// | SubReq | |
1322// |------------->| |
1323// | | |
1324// | | SubReq |
1325// | |------------->|
1326// | | |
1327// | | |
1328// | | SubReq |
1329// | |------------->|
1330// | | |
1331// | | SubDelReq |
1332// | |------------->|
1333// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001334// | | SubDelResp |
1335// | |<-------------|
1336// | | |
1337//
1338//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001339func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001340 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001341
1342 // Init counter check
1343 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1344 Counter{cSubReqFromXapp, 1},
1345 Counter{cSubReqToE2, 1},
1346 Counter{cSubReReqToE2, 1},
1347 Counter{cSubReqTimerExpiry, 2},
1348 Counter{cSubDelReqToE2, 1},
1349 Counter{cSubDelRespFromE2, 1},
1350 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001351
1352 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001353 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001354
1355 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001356 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001357
1358 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001359 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001360
1361 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001362 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1363 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001364
1365 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001366 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001367
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001368 xappConn1.TestMsgChanEmpty(t)
1369 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001370 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001371 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001372
1373 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001374}
1375
1376//-----------------------------------------------------------------------------
1377// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1378//
1379// stub stub
1380// +-------+ +---------+ +---------+
1381// | xapp | | submgr | | e2term |
1382// +-------+ +---------+ +---------+
1383// | | |
1384// | SubReq | |
1385// |------------->| |
1386// | | |
1387// | | SubReq |
1388// | |------------->|
1389// | | |
1390// | | |
1391// | | SubReq |
1392// | |------------->|
1393// | | |
1394// | | SubDelReq |
1395// | |------------->|
1396// | | |
1397// | | |
1398// | | SubDelReq |
1399// | |------------->|
1400// | | |
1401// | | |
1402//
1403//-----------------------------------------------------------------------------
1404
1405func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001406 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001407
1408 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1409 Counter{cSubReqFromXapp, 1},
1410 Counter{cSubReqToE2, 1},
1411 Counter{cSubReReqToE2, 1},
1412 Counter{cSubReqTimerExpiry, 2},
1413 Counter{cSubDelReqToE2, 1},
1414 Counter{cSubDelReReqToE2, 1},
1415 Counter{cSubDelReqTimerExpiry, 2},
1416 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001417
1418 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001419 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001420
1421 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001422 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001423
1424 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001425 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001426
1427 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001428 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001429
1430 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001431 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001432
1433 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001434 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001435
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001436 xappConn1.TestMsgChanEmpty(t)
1437 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001438 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001439 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001440
1441 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001442}
1443
1444//-----------------------------------------------------------------------------
1445// TestSubReqSubFailRespInSubmgr
1446//
1447// stub stub
1448// +-------+ +---------+ +---------+
1449// | xapp | | submgr | | e2term |
1450// +-------+ +---------+ +---------+
1451// | | |
1452// | SubReq | |
1453// |------------->| |
1454// | | |
1455// | | SubReq |
1456// | |------------->|
1457// | | |
1458// | | SubFail |
1459// | |<-------------|
1460// | | |
1461// | SubFail | |
1462// |<-------------| |
1463// | | |
1464//
1465//-----------------------------------------------------------------------------
1466
1467func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001468 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001469
1470 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1471 Counter{cSubReqFromXapp, 1},
1472 Counter{cSubReqToE2, 1},
1473 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001474 Counter{cSubFailToXapp, 1},
1475 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001476
1477 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001478 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001479
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001480 // E2t: Receive SubsReq and send SubsFail (first)
1481 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1482 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1483 fparams1.Set(crereq1)
1484 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1485
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001486 // Xapp: Receive SubsFail
1487 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1488
1489 // Wait that subs is cleaned
1490 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1491
1492 xappConn1.TestMsgChanEmpty(t)
1493 xappConn2.TestMsgChanEmpty(t)
1494 e2termConn1.TestMsgChanEmpty(t)
1495 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001496
1497 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001498}
1499
1500//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001501// TestSubDelReqRetryInSubmgr
1502//
1503// stub stub
1504// +-------+ +---------+ +---------+
1505// | xapp | | submgr | | e2term |
1506// +-------+ +---------+ +---------+
1507// | | |
1508// | [SUBS CREATE] |
1509// | | |
1510// | | |
1511// | SubDelReq | |
1512// |------------->| |
1513// | | |
1514// | | SubDelReq |
1515// | |------------->|
1516// | | |
1517// | | SubDelReq |
1518// | |------------->|
1519// | | |
1520// | | SubDelResp |
1521// | |<-------------|
1522// | | |
1523// | SubDelResp | |
1524// |<-------------| |
1525//
1526//-----------------------------------------------------------------------------
1527
1528func TestSubDelReqRetryInSubmgr(t *testing.T) {
1529
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001530 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001531
1532 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001533 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001534 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1535 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001536 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001537
1538 // Subs Delete
1539 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001540 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001541
1542 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001543 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001544
1545 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001546 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1547 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001548
1549 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001550 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001551
1552 // Wait that subs is cleaned
1553 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1554
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001555 xappConn1.TestMsgChanEmpty(t)
1556 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001557 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001558 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001559}
1560
1561//-----------------------------------------------------------------------------
1562// TestSubDelReqTwoRetriesNoRespInSubmgr
1563//
1564// stub stub
1565// +-------+ +---------+ +---------+
1566// | xapp | | submgr | | e2term |
1567// +-------+ +---------+ +---------+
1568// | | |
1569// | [SUBS CREATE] |
1570// | | |
1571// | | |
1572// | SubDelReq | |
1573// |------------->| |
1574// | | |
1575// | | SubDelReq |
1576// | |------------->|
1577// | | |
1578// | | SubDelReq |
1579// | |------------->|
1580// | | |
1581// | | |
1582// | SubDelResp | |
1583// |<-------------| |
1584//
1585//-----------------------------------------------------------------------------
1586
1587func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1588
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001589 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001590
1591 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001592 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001593 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1594 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001595 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001596
1597 // Subs Delete
1598 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001599 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001600
1601 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001602 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001603
1604 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001605 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001606
1607 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001608 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001609
1610 // Wait that subs is cleaned
1611 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1612
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001613 xappConn1.TestMsgChanEmpty(t)
1614 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001615 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001616 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001617}
1618
1619//-----------------------------------------------------------------------------
1620// TestSubDelReqSubDelFailRespInSubmgr
1621//
1622// stub stub
1623// +-------+ +---------+ +---------+
1624// | xapp | | submgr | | e2term |
1625// +-------+ +---------+ +---------+
1626// | | |
1627// | [SUBS CREATE] |
1628// | | |
1629// | | |
1630// | SubDelReq | |
1631// |------------->| |
1632// | | |
1633// | | SubDelReq |
1634// | |------------->|
1635// | | |
1636// | | SubDelFail |
1637// | |<-------------|
1638// | | |
1639// | SubDelResp | |
1640// |<-------------| |
1641// | | |
1642//
1643//-----------------------------------------------------------------------------
1644
1645func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001646 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001647
1648 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1649 Counter{cSubReqFromXapp, 1},
1650 Counter{cSubReqToE2, 1},
1651 Counter{cSubRespFromE2, 1},
1652 Counter{cSubRespToXapp, 1},
1653 Counter{cSubDelReqFromXapp, 1},
1654 Counter{cSubDelReqToE2, 1},
1655 Counter{cSubDelFailFromE2, 1},
1656 Counter{cSubDelRespToXapp, 1},
1657 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001658
1659 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001660 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001661 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1662 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001663 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001664
1665 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001666 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001667
1668 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001669 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1670 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001671
1672 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001673 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001674
1675 // Wait that subs is cleaned
1676 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1677
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001678 xappConn1.TestMsgChanEmpty(t)
1679 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001680 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001681 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001682
1683 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001684}
1685
1686//-----------------------------------------------------------------------------
1687// TestSubReqAndSubDelOkSameAction
1688//
1689// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001690// +-------+ +-------+ +---------+ +---------+
1691// | xapp2 | | xapp1 | | submgr | | e2term |
1692// +-------+ +-------+ +---------+ +---------+
1693// | | | |
1694// | | | |
1695// | | | |
1696// | | SubReq1 | |
1697// | |------------->| |
1698// | | | |
1699// | | | SubReq1 |
1700// | | |------------->|
1701// | | | SubResp1 |
1702// | | |<-------------|
1703// | | SubResp1 | |
1704// | |<-------------| |
1705// | | | |
1706// | SubReq2 | |
1707// |--------------------------->| |
1708// | | | |
1709// | SubResp2 | |
1710// |<---------------------------| |
1711// | | | |
1712// | | SubDelReq 1 | |
1713// | |------------->| |
1714// | | | |
1715// | | SubDelResp 1 | |
1716// | |<-------------| |
1717// | | | |
1718// | SubDelReq 2 | |
1719// |--------------------------->| |
1720// | | | |
1721// | | | SubDelReq 2 |
1722// | | |------------->|
1723// | | | |
1724// | | | SubDelReq 2 |
1725// | | |------------->|
1726// | | | |
1727// | SubDelResp 2 | |
1728// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001729//
1730//-----------------------------------------------------------------------------
1731func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001732 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001733
Anssi Mannila4abf1802021-01-28 13:06:46 +02001734 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001735 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1736 Counter{cSubReqFromXapp, 2},
1737 Counter{cSubReqToE2, 1},
1738 Counter{cSubRespFromE2, 1},
1739 Counter{cSubRespToXapp, 2},
1740 Counter{cMergedSubscriptions, 1},
1741 Counter{cUnmergedSubscriptions, 1},
1742 Counter{cSubDelReqFromXapp, 2},
1743 Counter{cSubDelReqToE2, 1},
1744 Counter{cSubDelRespFromE2, 1},
1745 Counter{cSubDelRespToXapp, 2},
1746 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001747
Juha Hyttinen3944a222020-01-24 11:51:46 +02001748 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001749 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001750 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001751 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001752 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1753 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001754 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001755
1756 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001757 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001758 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001759 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001760 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001761
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001762 resp, _ := xapp.Subscription.QuerySubscriptions()
1763 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1764 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001765 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001766
Juha Hyttinen3944a222020-01-24 11:51:46 +02001767 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001769 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001770
1771 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001773 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1774 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001775 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001776 //Wait that subs is cleaned
1777 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1778
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001779 xappConn1.TestMsgChanEmpty(t)
1780 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001781 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001782 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001783
1784 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001785}
1786
1787//-----------------------------------------------------------------------------
1788// TestSubReqAndSubDelOkSameActionParallel
1789//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001790// stub stub stub
1791// +-------+ +-------+ +---------+ +---------+
1792// | xapp2 | | xapp1 | | submgr | | e2term |
1793// +-------+ +-------+ +---------+ +---------+
1794// | | | |
1795// | | | |
1796// | | | |
1797// | | SubReq1 | |
1798// | |------------->| |
1799// | | | |
1800// | | | SubReq1 |
1801// | | |------------->|
1802// | SubReq2 | |
1803// |--------------------------->| |
1804// | | | SubResp1 |
1805// | | |<-------------|
1806// | | SubResp1 | |
1807// | |<-------------| |
1808// | | | |
1809// | SubResp2 | |
1810// |<---------------------------| |
1811// | | | |
1812// | | SubDelReq 1 | |
1813// | |------------->| |
1814// | | | |
1815// | | SubDelResp 1 | |
1816// | |<-------------| |
1817// | | | |
1818// | SubDelReq 2 | |
1819// |--------------------------->| |
1820// | | | |
1821// | | | SubDelReq 2 |
1822// | | |------------->|
1823// | | | |
1824// | | | SubDelReq 2 |
1825// | | |------------->|
1826// | | | |
1827// | SubDelResp 2 | |
1828// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001829//
1830//-----------------------------------------------------------------------------
1831func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001832 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001833
1834 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001835 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001836 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001837 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001838 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001839
1840 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001841 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001842 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001843 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001844
1845 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001846 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001847 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001848
1849 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001850 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001851
1852 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001853 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1854 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001855
1856 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001857 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001858 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1859 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001860 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001861
1862 //Wait that subs is cleaned
1863 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1864
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001865 xappConn1.TestMsgChanEmpty(t)
1866 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001867 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001868 mainCtrl.wait_registry_empty(t, 10)
1869}
1870
1871//-----------------------------------------------------------------------------
1872// TestSubReqAndSubDelNokSameActionParallel
1873//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001874// stub stub stub
1875// +-------+ +-------+ +---------+ +---------+
1876// | xapp2 | | xapp1 | | submgr | | e2term |
1877// +-------+ +-------+ +---------+ +---------+
1878// | | | |
1879// | | | |
1880// | | | |
1881// | | SubReq1 | |
1882// | |------------->| |
1883// | | | |
1884// | | | SubReq1 |
1885// | | |------------->|
1886// | SubReq2 | |
1887// |--------------------------->| |
1888// | | | SubFail1 |
1889// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001890// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001891// | | SubFail1 | |
1892// | |<-------------| |
1893// | | | |
1894// | SubFail2 | |
1895// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001896//
1897//-----------------------------------------------------------------------------
1898func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001899 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001900
1901 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001902 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001903 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001904 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001905
1906 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001907 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001908
1909 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001910 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001911 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001912 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001913 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001914 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001915
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001916 // E2t: send SubsFail (first)
1917 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1918 fparams1.Set(crereq1)
1919 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1920
Juha Hyttinen3944a222020-01-24 11:51:46 +02001921 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001922 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001923 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001924 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001925
1926 //Wait that subs is cleaned
1927 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1928
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001929 xappConn1.TestMsgChanEmpty(t)
1930 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001931 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001932 mainCtrl.wait_registry_empty(t, 10)
1933}
1934
1935//-----------------------------------------------------------------------------
1936// TestSubReqAndSubDelNoAnswerSameActionParallel
1937//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001938// stub stub stub
1939// +-------+ +-------+ +---------+ +---------+
1940// | xapp2 | | xapp1 | | submgr | | e2term |
1941// +-------+ +-------+ +---------+ +---------+
1942// | | | |
1943// | | | |
1944// | | | |
1945// | | SubReq1 | |
1946// | |------------->| |
1947// | | | |
1948// | | | SubReq1 |
1949// | | |------------->|
1950// | | SubReq2 | |
1951// |--------------------------->| |
1952// | | | |
1953// | | | SubReq1 |
1954// | | |------------->|
1955// | | | |
1956// | | | |
1957// | | | SubDelReq |
1958// | | |------------->|
1959// | | | |
1960// | | | SubDelResp |
1961// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001962//
1963//-----------------------------------------------------------------------------
1964func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001965 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001966
1967 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001968 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001969 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001970 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001971
Juha Hyttinen1683f912020-04-17 10:39:57 +03001972 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001973
1974 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001975 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001976 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001977 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001978 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001979 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001980
1981 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001982 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001983
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001984 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1985 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001986
1987 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001988 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001989
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001990 xappConn1.TestMsgChanEmpty(t)
1991 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001992 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001993 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001994}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001995
1996//----------------------------- Policy cases ---------------------------------
1997//-----------------------------------------------------------------------------
1998// TestSubReqPolicyAndSubDelOk
1999//
2000// stub stub
2001// +-------+ +---------+ +---------+
2002// | xapp | | submgr | | e2term |
2003// +-------+ +---------+ +---------+
2004// | | |
2005// | SubReq | |
2006// |------------->| |
2007// | | |
2008// | | SubReq |
2009// | |------------->|
2010// | | |
2011// | | SubResp |
2012// | |<-------------|
2013// | | |
2014// | SubResp | |
2015// |<-------------| |
2016// | | |
2017// | | |
2018// | SubDelReq | |
2019// |------------->| |
2020// | | |
2021// | | SubDelReq |
2022// | |------------->|
2023// | | |
2024// | | SubDelResp |
2025// | |<-------------|
2026// | | |
2027// | SubDelResp | |
2028// |<-------------| |
2029//
2030//-----------------------------------------------------------------------------
2031func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2032 CaseBegin("TestSubReqAndSubDelOk")
2033
2034 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2035 rparams1.Init()
2036 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2037 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2038
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002039 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2040 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002041 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2042 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002043 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002044
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002045 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002046 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002047
2048 //Wait that subs is cleaned
2049 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2050
2051 xappConn1.TestMsgChanEmpty(t)
2052 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002053 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002054 mainCtrl.wait_registry_empty(t, 10)
2055}
2056
2057//-----------------------------------------------------------------------------
2058// TestSubReqPolicyChangeAndSubDelOk
2059//
2060// stub stub
2061// +-------+ +---------+ +---------+
2062// | xapp | | submgr | | e2term |
2063// +-------+ +---------+ +---------+
2064// | | |
2065// | SubReq | |
2066// |------------->| |
2067// | | |
2068// | | SubReq |
2069// | |------------->|
2070// | | |
2071// | | SubResp |
2072// | |<-------------|
2073// | | |
2074// | SubResp | |
2075// |<-------------| |
2076// | | |
2077// | SubReq | |
2078// |------------->| |
2079// | | |
2080// | | SubReq |
2081// | |------------->|
2082// | | |
2083// | | SubResp |
2084// | |<-------------|
2085// | | |
2086// | SubResp | |
2087// |<-------------| |
2088// | | |
2089// | SubDelReq | |
2090// |------------->| |
2091// | | |
2092// | | SubDelReq |
2093// | |------------->|
2094// | | |
2095// | | SubDelResp |
2096// | |<-------------|
2097// | | |
2098// | SubDelResp | |
2099// |<-------------| |
2100//
2101//-----------------------------------------------------------------------------
2102
2103func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2104 CaseBegin("TestSubReqAndSubDelOk")
2105
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002106 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2107 rparams1.Init()
2108 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2109 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002110
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002111 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2112 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002113 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2114
2115 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002116 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002117 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2118 xappConn1.SendSubsReq(t, rparams1, cretrans)
2119
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002120 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2121 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002122 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2123 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002124 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002125
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002126 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002127 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002128
2129 //Wait that subs is cleaned
2130 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2131
2132 xappConn1.TestMsgChanEmpty(t)
2133 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002134 e2termConn1.TestMsgChanEmpty(t)
2135 mainCtrl.wait_registry_empty(t, 10)
2136}
2137
2138//-----------------------------------------------------------------------------
2139// TestSubReqAndSubDelOkTwoE2termParallel
2140//
2141// stub stub stub
2142// +-------+ +---------+ +---------+ +---------+
2143// | xapp | | submgr | | e2term1 | | e2term2 |
2144// +-------+ +---------+ +---------+ +---------+
2145// | | | |
2146// | | | |
2147// | | | |
2148// | SubReq1 | | |
2149// |------------->| | |
2150// | | | |
2151// | | SubReq1 | |
2152// | |------------->| |
2153// | | | |
2154// | SubReq2 | | |
2155// |------------->| | |
2156// | | | |
2157// | | SubReq2 | |
2158// | |---------------------------->|
2159// | | | |
2160// | | SubResp1 | |
2161// | |<-------------| |
2162// | SubResp1 | | |
2163// |<-------------| | |
2164// | | SubResp2 | |
2165// | |<----------------------------|
2166// | SubResp2 | | |
2167// |<-------------| | |
2168// | | | |
2169// | [SUBS 1 DELETE] | |
2170// | | | |
2171// | [SUBS 2 DELETE] | |
2172// | | | |
2173//
2174//-----------------------------------------------------------------------------
2175func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2176 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2177
2178 //Req1
2179 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2180 xappConn1.SendSubsReq(t, nil, cretrans1)
2181 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2182
2183 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2184 xappConn1.SendSubsReq(t, nil, cretrans2)
2185 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2186
2187 //Resp1
2188 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2189 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2190
2191 //Resp2
2192 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2193 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2194
2195 //Del1
2196 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2197 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2198 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2199 xappConn1.RecvSubsDelResp(t, deltrans1)
2200 //Wait that subs is cleaned
2201 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2202
2203 //Del2
2204 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2205 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2206 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2207 xappConn1.RecvSubsDelResp(t, deltrans2)
2208 //Wait that subs is cleaned
2209 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2210
2211 xappConn1.TestMsgChanEmpty(t)
2212 xappConn2.TestMsgChanEmpty(t)
2213 e2termConn1.TestMsgChanEmpty(t)
2214 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002215 mainCtrl.wait_registry_empty(t, 10)
2216}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002217
2218//-----------------------------------------------------------------------------
2219// TestSubReqInsertAndSubDelOk
2220//
2221// stub stub
2222// +-------+ +---------+ +---------+
2223// | xapp | | submgr | | e2term |
2224// +-------+ +---------+ +---------+
2225// | | |
2226// | SubReq | |
2227// |------------->| |
2228// | | |
2229// | | SubReq |
2230// | |------------->|
2231// | | |
2232// | | SubResp |
2233// | |<-------------|
2234// | | |
2235// | SubResp | |
2236// |<-------------| |
2237// | | |
2238// | | |
2239// | SubDelReq | |
2240// |------------->| |
2241// | | |
2242// | | SubDelReq |
2243// | |------------->|
2244// | | |
2245// | | SubDelResp |
2246// | |<-------------|
2247// | | |
2248// | SubDelResp | |
2249// |<-------------| |
2250//
2251//-----------------------------------------------------------------------------
2252func TestSubReqInsertAndSubDelOk(t *testing.T) {
2253 CaseBegin("TestInsertSubReqAndSubDelOk")
2254
2255 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2256 rparams1.Init()
2257 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2258 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2259
2260 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2261 e2termConn1.SendSubsResp(t, crereq, cremsg)
2262 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2263 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2264 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2265
2266 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2267 xappConn1.RecvSubsDelResp(t, deltrans)
2268
2269 //Wait that subs is cleaned
2270 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2271
2272 xappConn1.TestMsgChanEmpty(t)
2273 xappConn2.TestMsgChanEmpty(t)
2274 e2termConn1.TestMsgChanEmpty(t)
2275 mainCtrl.wait_registry_empty(t, 10)
2276}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002277
2278//-----------------------------------------------------------------------------
2279// TestSubReqRetransmissionWithSameSubIdDiffXid
2280//
2281// This case simulates case where xApp restarts and starts sending same
2282// subscription requests which have already subscribed successfully
2283
2284// stub stub
2285// +-------+ +---------+ +---------+
2286// | xapp | | submgr | | e2term |
2287// +-------+ +---------+ +---------+
2288// | | |
2289// | SubReq | |
2290// |------------->| |
2291// | | |
2292// | | SubReq |
2293// | |------------->|
2294// | | |
2295// | | SubResp |
2296// | |<-------------|
2297// | | |
2298// | SubResp | |
2299// |<-------------| |
2300// | | |
2301// | xApp restart | |
2302// | | |
2303// | SubReq | |
2304// | (retrans with same xApp generated subid but diff xid)
2305// |------------->| |
2306// | | |
2307// | SubResp | |
2308// |<-------------| |
2309// | | |
2310// | [SUBS DELETE] |
2311// | | |
2312//
2313//-----------------------------------------------------------------------------
2314func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2315 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2316
2317 //Subs Create
2318 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2319 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2320 e2termConn1.SendSubsResp(t, crereq, cremsg)
2321 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2322
2323 // xApp restart here
2324 // --> artificial delay
2325 <-time.After(1 * time.Second)
2326
2327 //Subs Create
2328 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2329 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2330
2331 //Subs Delete
2332 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2333 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2334 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2335 xappConn1.RecvSubsDelResp(t, deltrans)
2336
2337 //Wait that subs is cleaned
2338 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2339
2340 xappConn1.TestMsgChanEmpty(t)
2341 xappConn2.TestMsgChanEmpty(t)
2342 e2termConn1.TestMsgChanEmpty(t)
2343 mainCtrl.wait_registry_empty(t, 10)
2344}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002345
2346//-----------------------------------------------------------------------------
2347// TestSubReqNokAndSubDelOkWithRestartInMiddle
2348//
2349// stub stub
2350// +-------+ +---------+ +---------+
2351// | xapp | | submgr | | e2term |
2352// +-------+ +---------+ +---------+
2353// | | |
2354// | SubReq | |
2355// |------------->| |
2356// | | |
2357// | | SubReq |
2358// | |------------->|
2359// | | |
2360// | | SubResp |
2361// | <----|
2362// | |
2363// | Submgr restart |
2364// | |
2365// | | |
2366// | | SubDelReq |
2367// | |------------->|
2368// | | |
2369// | | SubDelResp |
2370// | |<-------------|
2371// | | |
2372//
2373//-----------------------------------------------------------------------------
2374
2375func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2376 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2377
2378 // Remove possible existing subscrition
2379 mainCtrl.removeExistingSubscriptions(t)
2380
2381 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2382 xappConn1.SendSubsReq(t, nil, nil)
2383 e2termConn1.RecvSubsReq(t)
2384 mainCtrl.SetResetTestFlag(t, false)
2385
2386 resp, _ := xapp.Subscription.QuerySubscriptions()
2387 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002388 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002389 e2SubsId := uint32(resp[0].SubscriptionID)
2390 t.Logf("e2SubsId = %v", e2SubsId)
2391
archaggeafbf95f2021-04-14 08:54:05 +03002392 mainCtrl.SimulateRestart(t)
2393 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002394
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002395 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2397 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2398
2399 // Wait that subs is cleaned
2400 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2401
2402 xappConn1.TestMsgChanEmpty(t)
2403 xappConn2.TestMsgChanEmpty(t)
2404 e2termConn1.TestMsgChanEmpty(t)
2405 mainCtrl.wait_registry_empty(t, 10)
2406}
2407
2408//-----------------------------------------------------------------------------
2409// TestSubReqAndSubDelOkWithRestartInMiddle
2410//
2411// stub stub
2412// +-------+ +---------+ +---------+
2413// | xapp | | submgr | | e2term |
2414// +-------+ +---------+ +---------+
2415// | | |
2416// | SubReq | |
2417// |------------->| |
2418// | | |
2419// | | SubReq |
2420// | |------------->|
2421// | | |
2422// | | SubResp |
2423// | |<-------------|
2424// | | |
2425// | SubResp | |
2426// |<-------------| |
2427// | | |
2428// | |
2429// | Submgr restart |
2430// | |
2431// | SubDelReq | |
2432// |------------->| |
2433// | | |
2434// | | SubDelReq |
2435// | |------------->|
2436// | | |
2437// | | SubDelResp |
2438// | |<-------------|
2439// | | |
2440// | SubDelResp | |
2441// |<-------------| |
2442//
2443//-----------------------------------------------------------------------------
2444
2445func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2446 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2447
2448 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2449 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2450 e2termConn1.SendSubsResp(t, crereq, cremsg)
2451 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2452
2453 // Check subscription
2454 resp, _ := xapp.Subscription.QuerySubscriptions()
2455 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2456 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002457 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002458
2459 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002460 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002461
2462 // 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
2556 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2557 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
2564 // Check that subscription is restored correctly after restart
2565 resp, _ = xapp.Subscription.QuerySubscriptions()
2566 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2567 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002568 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002569
2570 //Del1
2571 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2572 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2573 xappConn1.RecvSubsDelResp(t, deltrans1)
2574 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2575
2576 mainCtrl.SimulateRestart(t)
2577 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2578
2579 //Del2
2580 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2581 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2582
2583 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2584 xappConn2.RecvSubsDelResp(t, deltrans2)
2585
2586 //Wait that subs is cleaned
2587 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2588
2589 xappConn1.TestMsgChanEmpty(t)
2590 xappConn2.TestMsgChanEmpty(t)
2591 e2termConn1.TestMsgChanEmpty(t)
2592 mainCtrl.wait_registry_empty(t, 10)
2593}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002594
archaggeafbf95f2021-04-14 08:54:05 +03002595//*****************************************************************************
2596// REST interface test cases
2597//*****************************************************************************
2598
Anssi Mannila47518ae2021-04-16 09:27:07 +03002599//-----------------------------------------------------------------------------
2600// Test debug GET and POST requests
2601//
2602// curl
2603// +-------+ +---------+
2604// | user | | submgr |
2605// +-------+ +---------+
2606// | |
2607// | GET/POST Req |
2608// |------------->|
2609// | Resp |
2610// |<-------------|
2611// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002612func TestGetSubscriptions(t *testing.T) {
2613
2614 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2615}
2616
2617func TestGetSymptomData(t *testing.T) {
2618
2619 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2620}
2621
2622func TestPostdeleteSubId(t *testing.T) {
2623
2624 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2625}
2626
2627func TestPostEmptyDb(t *testing.T) {
2628
2629 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2630}
archaggeafbf95f2021-04-14 08:54:05 +03002631
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002632func TestGetRestSubscriptions(t *testing.T) {
2633
2634 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2635}
2636
archaggeafbf95f2021-04-14 08:54:05 +03002637//-----------------------------------------------------------------------------
2638// TestRESTSubReqAndRouteNok
2639//
2640// stub stub
2641// +-------+ +---------+ +---------+
2642// | xapp | | submgr | | rtmgr |
2643// +-------+ +---------+ +---------+
2644// | | |
2645// | RESTSubReq | |
2646// |---------------->| |
2647// | | |
2648// | RESTSubResp | |
2649// |<----------------| |
2650// | | RouteCreate |
2651// | |------------->|
2652// | | |
2653// | | RouteCreate |
2654// | | status:400 |
2655// | |(Bad request) |
2656// | |<-------------|
2657// | RESTNotif | |
2658// |<----------------| |
2659// | | |
2660// | [SUBS INT DELETE] |
2661// | | |
2662// | RESTSubDelReq | |
2663// |---------------->| |
2664// | RESTSubDelResp | |
2665// |<----------------| |
2666//
2667//-----------------------------------------------------------------------------
2668func TestRESTSubReqAndRouteNok(t *testing.T) {
2669 CaseBegin("TestRESTSubReqAndRouteNok")
2670
2671 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002672 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002673 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002674 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002675 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002676 Counter{cRestSubDelReqFromXapp, 1},
2677 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002678 })
2679
2680 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002681
Markku Virtanenda34eec2021-05-20 08:22:04 +00002682 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2683 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002684 newSubsId := mainCtrl.get_registry_next_subid(t)
2685
2686 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002687 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002688 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002689 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002690 waiter.WaitResult(t)
2691
archaggeafbf95f2021-04-14 08:54:05 +03002692 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002693 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002694
2695 // Del
2696 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2697
2698 // Wait that subs is cleaned
2699 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2700 waitSubsCleanup(t, e2SubsId, 10)
2701 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002702 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002703}
2704
2705func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2706 CaseBegin("TestSubReqAndRouteUpdateNok")
2707
2708 //Init counter check
2709 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002710 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002711 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002712 Counter{cSubReqToE2, 1},
2713 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002714 Counter{cRestSubNotifToXapp, 1},
2715 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002716 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002717 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002718 Counter{cSubDelReqToE2, 1},
2719 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002720 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002721 })
2722
2723 var params *teststube2ap.RESTSubsReqParams = nil
2724
2725 //Subs Create
2726 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2727
2728 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2729
2730 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2731 waiter := rtmgrHttp.AllocNextEvent(false)
2732 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002733 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002734 params.SetMeid("RAN_NAME_1")
2735 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002736 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002737 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002738 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03002739 xappConn2.WaitRESTNotification(t, restSubId2)
2740
2741 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2742
2743 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002744 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03002745
2746 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2747 //Wait that subs is cleaned
2748 waitSubsCleanup(t, e2SubsId, 10)
2749
2750 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002751 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002752}
2753
2754func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2755 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2756
2757 // Init counter check
2758 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002759 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002760 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002761 Counter{cSubReqToE2, 1},
2762 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002763 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002764 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002765 Counter{cRouteDeleteFail, 1},
2766 Counter{cSubDelReqToE2, 1},
2767 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002768 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002769 })
2770
2771 var params *teststube2ap.RESTSubsReqParams = nil
2772
2773 //Subs Create
2774 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2775
2776 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2777
2778 waiter := rtmgrHttp.AllocNextEvent(false)
2779 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2780 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2781 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2782 waiter.WaitResult(t)
2783
2784 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002785 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002786 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002787}
2788
2789func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2790 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2791
2792 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002793 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002794 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002795 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002796 Counter{cSubReqToE2, 1},
2797 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002798 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002799 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002800 Counter{cRouteDeleteUpdateFail, 1},
2801 Counter{cSubDelReqToE2, 1},
2802 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002803 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002804 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002805 })
2806
2807 var params *teststube2ap.RESTSubsReqParams = nil
2808
2809 //Subs Create
2810 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2811
2812 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2813 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2814
2815 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2816
2817 //Del1, this shall fail on rtmgr side
2818 waiter := rtmgrHttp.AllocNextEvent(false)
2819 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2820 waiter.WaitResult(t)
2821
2822 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2823
2824 //Del2
2825 deleteXapp2Subscription(t, &restSubId2)
2826
2827 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002828 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002829 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002830}
2831
2832//-----------------------------------------------------------------------------
2833// TestRESTSubReqRetransmission
2834//
2835// stub stub
2836// +-------+ +---------+ +---------+
2837// | xapp | | submgr | | e2term |
2838// +-------+ +---------+ +---------+
2839// | | |
2840// | RESTSubReq1 | |
2841// |---------------->| |
2842// | | |
2843// | RESTSubResp | |
2844// |<----------------| |
2845// | | SubReq1 |
2846// | |------------->|
2847// | | |
2848// | RESTSubReq2 | |
2849// | (retrans) | |
2850// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002851// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002852// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002853// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002854// | | SubResp1 |
2855// | |<-------------|
2856// | RESTNotif1 | |
2857// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002858// | | |
2859// | [SUBS DELETE] |
2860// | | |
2861//
2862//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002863
archaggeafbf95f2021-04-14 08:54:05 +03002864func TestRESTSubReqRetransmission(t *testing.T) {
2865 CaseBegin("TestRESTSubReqRetransmission")
2866
2867 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002868 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002869 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002870 Counter{cSubReqToE2, 1},
2871 Counter{cSubRespFromE2, 1},
2872 Counter{cRestSubNotifToXapp, 1},
2873 Counter{cRestSubDelReqFromXapp, 1},
2874 Counter{cSubDelReqToE2, 1},
2875 Counter{cSubDelRespFromE2, 1},
2876 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002877 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002878 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002879 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2880 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2881
2882 // Subs Create
2883 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002884
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002885 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002886 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002887
Anssi Mannilab43397e2021-11-16 12:06:16 +02002888 xappConn1.SendRESTSubsReq(t, params)
2889 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03002890
Anssi Mannilab43397e2021-11-16 12:06:16 +02002891 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03002892
2893 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02002894 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03002895 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2896 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002897
Anssi Mannilab43397e2021-11-16 12:06:16 +02002898 e2SubsId := <-xappConn1.ListedRESTNotifications
2899
2900 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002901
2902 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02002903 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002904 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2905 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2906
Anssi Mannilab43397e2021-11-16 12:06:16 +02002907 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002908
2909 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002910 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002911}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002912
Markku Virtanen42723e22021-06-15 10:09:23 +03002913//-----------------------------------------------------------------------------
2914// stub stub stub
2915// +-------+ +---------+ +---------+ +---------+
2916// | xapp | | submgr | | e2term | | rtmgr |
2917// +-------+ +---------+ +---------+ +---------+
2918// | | | |
2919// | RESTSubReq | | |
2920// |---------------->| | |
2921// | RESTSubResp | | |
2922// |<----------------| | |
2923// | | RouteCreate | |
2924// | |--------------------------->|
2925// | | RouteResponse| |
2926// | |<---------------------------| // The order of these events may vary
2927// | | SubReq | |
2928// | |------------->| | // The order of these events may vary
2929// | | SubResp | |
2930// | |<-------------| |
2931// | RESTNotif1 | | |
2932// |<----------------| | |
2933// | RESTSubReq | | |
2934// | [RETRANS1] | | |
2935// |---------------->| | |
2936// | RESTNotif1 | | |
2937// |<----------------| | |
2938// | RESTSubReq | | |
2939// | [RETRANS2] | | |
2940// |---------------->| | |
2941// | RESTNotif1 | | |
2942// |<----------------| | |
2943// | RESTSubDelReq | | |
2944// |---------------->| | |
2945// | | SubDelReq | |
2946// | |------------->| |
2947// | RESTSubDelResp| | |
2948// |<----------------| | |
2949// | | SubDelResp | |
2950// | |<-------------| |
2951// | | | |
2952//
2953//-----------------------------------------------------------------------------
2954
2955func TestRESTSubReqRetransmissionV2(t *testing.T) {
2956 CaseBegin("TestRESTSubReqRetransmissionV2")
2957
2958 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2959 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002960 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03002961 Counter{cRestSubRespToXapp, 3},
2962 Counter{cSubReqToE2, 1},
2963 Counter{cSubRespFromE2, 1},
2964 Counter{cRestSubNotifToXapp, 3},
2965 Counter{cRestSubDelReqFromXapp, 1},
2966 Counter{cSubDelReqToE2, 1},
2967 Counter{cSubDelRespFromE2, 1},
2968 Counter{cRestSubDelRespToXapp, 1},
2969 })
2970
2971 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2972
2973 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2974
2975 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2976
2977 //1.st resend
2978 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2979
2980 assert.Equal(t, restSubId_resend, restSubId)
2981
2982 <-time.After(100 * time.Millisecond)
2983
2984 //2.nd resend
2985 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2986
2987 assert.Equal(t, restSubId_resend2, restSubId)
2988
2989 <-time.After(100 * time.Millisecond)
2990
2991 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2992
2993 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03002994 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002995 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002996}
2997
2998//-----------------------------------------------------------------------------
2999// stub stub stub
3000// +-------+ +---------+ +---------+ +---------+
3001// | xapp | | submgr | | e2term | | rtmgr |
3002// +-------+ +---------+ +---------+ +---------+
3003// | | | |
3004// | RESTSubReq | | |
3005// |---------------->| | |
3006// | RESTSubResp | | |
3007// |<----------------| | |
3008// | | RouteCreate | |
3009// | |--------------------------->|
3010// | | RouteResponse| |
3011// | |<---------------------------| // The order of these events may vary
3012// | | SubReq | |
3013// | |------------->| | // The order of these events may vary
3014// | | SubResp | |
3015// | |<-------------| |
3016// | RESTNotif1 | | |
3017// |<----------------| | |
3018// | RESTSubReq | | |
3019// | [RETRANS, with RESTsubsId] | |
3020// |---------------->| | |
3021// | RESTNotif1 | | |
3022// |<----------------| | |
3023// | RESTSubReq | | |
3024// | [RETRANS, without RESTsubsId] | |
3025// |---------------->| | |
3026// | RESTNotif1 | | |
3027// |<----------------| | |
3028// | RESTSubDelReq | | |
3029// |---------------->| | |
3030// | | SubDelReq | |
3031// | |------------->| |
3032// | RESTSubDelResp| | |
3033// |<----------------| | |
3034// | | SubDelResp | |
3035// | |<-------------| |
3036// | | | |
3037//
3038//-----------------------------------------------------------------------------
3039func TestRESTSubReqRetransmissionV3(t *testing.T) {
3040 CaseBegin("TestRESTSubReqRetransmissionV3")
3041
3042 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3043 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003044 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003045 Counter{cRestSubRespToXapp, 3},
3046 Counter{cSubReqToE2, 1},
3047 Counter{cSubRespFromE2, 1},
3048 Counter{cRestSubNotifToXapp, 3},
3049 Counter{cRestSubDelReqFromXapp, 1},
3050 Counter{cSubDelReqToE2, 1},
3051 Counter{cSubDelRespFromE2, 1},
3052 Counter{cRestSubDelRespToXapp, 1},
3053 })
3054
3055 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3056
3057 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3058
3059 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3060
3061 <-time.After(100 * time.Millisecond)
3062
3063 //1.st resend with subscription ID
3064 params.SetSubscriptionID(&restSubId)
3065 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3066
3067 assert.Equal(t, restSubId_resend, restSubId)
3068
3069 <-time.After(100 * time.Millisecond)
3070
3071 //2.nd resend without subscription ID (faking app restart)
3072 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3073 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3074
3075 assert.Equal(t, restSubId_resend2, restSubId)
3076
3077 <-time.After(100 * time.Millisecond)
3078
3079 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3080
3081 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003082 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003083 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003084}
3085
3086//-----------------------------------------------------------------------------
3087// stub stub stub
3088// +-------+ +---------+ +---------+ +---------+
3089// | xapp | | submgr | | e2term | | rtmgr |
3090// +-------+ +---------+ +---------+ +---------+
3091// | | | |
3092// | RESTSubReq | | |
3093// |---------------->| | |
3094// | RESTSubResp | | |
3095// |<----------------| | |
3096// | | RouteCreate | |
3097// | |--------------------------->|
3098// | | RouteResponse| |
3099// | |<---------------------------|
3100// | | SubReq | |
3101// | |------------->| |
3102// | | SubResp | |
3103// | |<-------------| |
3104// | RESTNotif1 | | |
3105// |<----------------| | |
3106// | RESTSubReq | | |
3107// | [with RestSUbsId + one additional e2 subDetail]
3108// |---------------->| | |
3109// | RESTNotif1 | | |
3110// | [for initial e2 subDetail] | |
3111// |<----------------| | |
3112// | | RouteCreate | |
3113// | |--------------------------->|
3114// | | RouteResponse| |
3115// | |<---------------------------|
3116// | | SubReq | |
3117// | |------------->| |
3118// | | SubResp | |
3119// | |<-------------| |
3120// | RESTNotif1 | | |
3121// |<----------------| | |
3122// | RESTSubReq | | |
3123// | [with RESTsubsId initial request] |
3124// |---------------->| | |
3125// | RESTNotif1 | | |
3126// |<----------------| | |
3127// | RESTSubDelReq | | |
3128// |---------------->| | |
3129// | RESTSubDelResp| | |
3130// |<----------------| | |
3131// | | SubDelReq | |
3132// | |------------->| |
3133// | | SubDelResp | |
3134// | |<-------------| |
3135// | | SubDelReq | |
3136// | |------------->| |
3137// | | SubDelResp | |
3138// | |<-------------| |
3139// | | | |
3140//
3141//-----------------------------------------------------------------------------
3142
3143func TestRESTSubReqRetransmissionV4(t *testing.T) {
3144 CaseBegin("TestRESTSubReqRetransmissionV4")
3145
3146 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3147 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003148 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003149 Counter{cRestSubRespToXapp, 3},
3150 Counter{cSubReqToE2, 2},
3151 Counter{cSubRespFromE2, 2},
3152 Counter{cRestSubNotifToXapp, 4},
3153 Counter{cRestSubDelReqFromXapp, 1},
3154 Counter{cSubDelReqToE2, 2},
3155 Counter{cSubDelRespFromE2, 2},
3156 Counter{cRestSubDelRespToXapp, 1},
3157 })
3158
3159 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3160
3161 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3162
3163 <-time.After(100 * time.Millisecond)
3164
3165 // Send modified requst, this time with e2 subscriptions.
3166 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3167 params2.SetSubscriptionID(&restSubId)
3168
3169 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003170 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003171 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3172 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003173 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3174 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003175
3176 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3177
Markku Virtanen2b512b62021-07-30 12:04:00 +00003178 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003179 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3180 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3181 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3182 assert.NotEqual(t, e2SubsId2, 0)
3183
3184 <-time.After(100 * time.Millisecond)
3185
3186 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3187 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3188 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003189 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003190 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3191 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3192 assert.Equal(t, restSubId_resend, restSubId_resend2)
3193
Markku Virtanen2b512b62021-07-30 12:04:00 +00003194 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3195 assert.Equal(t, e2SubsId, e2SubsId1)
3196
Markku Virtanen42723e22021-06-15 10:09:23 +03003197 // Delete both e2 subscriptions
3198 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3199 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3200 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3201
3202 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003203 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003204 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003205}
3206
3207//-----------------------------------------------------------------------------
3208// stub stub stub
3209// +-------+ +---------+ +---------+ +---------+
3210// | xapp | | submgr | | e2term | | rtmgr |
3211// +-------+ +---------+ +---------+ +---------+
3212// | | | |
3213// | RESTSubReq | | |
3214// |---------------->| | |
3215// | RESTSubResp | | |
3216// |<----------------| | |
3217// | | RouteCreate | |
3218// | |--------------------------->|
3219// | | RouteResponse| |
3220// | |<---------------------------|
3221// | | SubReq | |
3222// | |------------->| |
3223// | | SubResp | |
3224// | |<-------------| |
3225// | RESTNotif1 | | |
3226// |<----------------| | |
3227// | RESTSubReq | | |
3228// | [with RestSUbsId + one additional e2 subDetail]
3229// |---------------->| | |
3230// | RESTNotif1 | | |
3231// | [for initial e2 subDetail] | |
3232// |<----------------| | |
3233// | | RouteCreate | |
3234// | |--------------------------->|
3235// | | RouteResponse| |
3236// | |<---------------------------|
3237// | | SubReq | |
3238// | |------------->| |
3239// | | SubResp | |
3240// | |<-------------| |
3241// | RESTNotif1 | | |
3242// |<----------------| | |
3243// | RESTSubReq | | |
3244// | [without RESTsubsId initial request] |
3245// |---------------->| | |
3246// | RESTNotif1 | | |
3247// |<----------------| | |
3248// | RESTSubDelReq | | |
3249// |---------------->| | |
3250// | RESTSubDelResp| | |
3251// |<----------------| | |
3252// | | SubDelReq | |
3253// | |------------->| |
3254// | | SubDelResp | |
3255// | |<-------------| |
3256// | | SubDelReq | |
3257// | |------------->| |
3258// | | SubDelResp | |
3259// | |<-------------| |
3260// | | | |
3261//
3262//-----------------------------------------------------------------------------
3263
3264func TestRESTSubReqRetransmissionV5(t *testing.T) {
3265 CaseBegin("TestRESTSubReqRetransmissionV5")
3266
3267 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3268 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003269 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003270 Counter{cRestSubRespToXapp, 3},
3271 Counter{cSubReqToE2, 2},
3272 Counter{cSubRespFromE2, 2},
3273 Counter{cRestSubNotifToXapp, 4},
3274 Counter{cRestSubDelReqFromXapp, 1},
3275 Counter{cSubDelReqToE2, 2},
3276 Counter{cSubDelRespFromE2, 2},
3277 Counter{cRestSubDelRespToXapp, 1},
3278 })
3279
3280 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3281
3282 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3283
3284 <-time.After(100 * time.Millisecond)
3285
3286 // Send modified requst, this time with e2 subscriptions.
3287 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3288 params2.SetSubscriptionID(&restSubId)
3289
3290 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003291 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003292 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3293 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3294
Markku Virtanen2b512b62021-07-30 12:04:00 +00003295 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3296 assert.Equal(t, e2SubsId, e2SubsId1)
3297 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3298 xappConn1.DecrementRequestCount()
3299
Markku Virtanen42723e22021-06-15 10:09:23 +03003300 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3301
3302 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3303 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3304 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3305 assert.NotEqual(t, e2SubsId2, 0)
3306
3307 <-time.After(100 * time.Millisecond)
3308
3309 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3310 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003311 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003312 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3313 // md5sum shall find the original request
3314 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3315 assert.Equal(t, restSubId_resend, restSubId_resend2)
3316
Markku Virtanen2b512b62021-07-30 12:04:00 +00003317 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3318 assert.Equal(t, e2SubsId, e2SubsId1)
3319
Markku Virtanen42723e22021-06-15 10:09:23 +03003320 // Delete both e2 subscriptions
3321 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3322 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3323 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3324
3325 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003326 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003327 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003328}
3329
3330//-----------------------------------------------------------------------------
3331// stub stub stub
3332// +-------+ +---------+ +---------+ +---------+
3333// | xapp | | submgr | | e2term | | rtmgr |
3334// +-------+ +---------+ +---------+ +---------+
3335// | | | |
3336// | RESTSubReq | | |
3337// |---------------->| | |
3338// | RESTSubResp | | |
3339// |<----------------| | |
3340// | | RouteCreate | |
3341// | |--------------------------->|
3342// | | RouteResponse| |
3343// | |<---------------------------|
3344// | | SubReq | |
3345// | |------------->| |
3346// | | SubResp | |
3347// | |<-------------| |
3348// | RESTNotif1 | | |
3349// |<----------------| | |
3350// | RESTSubReq | | |
3351// | [with RestSUbsId + one additional e2 subDetail]
3352// |---------------->| | |
3353// | RESTNotif1 | | |
3354// | [for initial e2 subDetail] | |
3355// |<----------------| | |
3356// | | RouteCreate | |
3357// | |--------------------------->|
3358// | | RouteResponse| |
3359// | |<---------------------------|
3360// | | SubReq | |
3361// | |------------->| |
3362// | | SubResp | |
3363// | |<-------------| |
3364// | RESTNotif1 | | |
3365// |<----------------| | |
3366// | RESTSubDelReq | | |
3367// |---------------->| | |
3368// | RESTSubDelResp| | |
3369// |<----------------| | |
3370// | | SubDelReq | |
3371// | |------------->| |
3372// | | SubDelResp | |
3373// | |<-------------| |
3374// | | SubDelReq | |
3375// | |------------->| |
3376// | | SubDelResp | |
3377// | |<-------------| |
3378// | RESTSubReq | | |
3379// | [with RESTsubsId initial request] |
3380// |---------------->| | |
3381// | RESTSubResp | | |
3382// |<----------------| | |
3383// | | RouteCreate | |
3384// | |--------------------------->|
3385// | | RouteResponse| |
3386// | |<---------------------------|
3387// | | SubReq | |
3388// | |------------->| |
3389// | | SubResp | |
3390// | |<-------------| |
3391// | RESTNotif1 | | |
3392// |<----------------| | |
3393// | | | |
3394//
3395//-----------------------------------------------------------------------------
3396func TestRESTSubReqRetransmissionV6(t *testing.T) {
3397 CaseBegin("TestRESTSubReqRetransmissionV6")
3398
3399 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3400 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003401 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003402 Counter{cRestSubRespToXapp, 3},
3403 Counter{cSubReqToE2, 3},
3404 Counter{cSubRespFromE2, 3},
3405 Counter{cRestSubNotifToXapp, 4},
3406 Counter{cRestSubDelReqFromXapp, 2},
3407 Counter{cSubDelReqToE2, 3},
3408 Counter{cSubDelRespFromE2, 3},
3409 Counter{cRestSubDelRespToXapp, 2},
3410 })
3411
3412 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3413
3414 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3415
3416 <-time.After(100 * time.Millisecond)
3417
3418 // Send modified requst, this time with e2 subscriptions.
3419 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3420 params2.SetSubscriptionID(&restSubId)
3421
3422 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003423 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003424 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3425 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3426
Markku Virtanen2b512b62021-07-30 12:04:00 +00003427 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3428 assert.Equal(t, e2SubsId, e2SubsId1)
3429
Markku Virtanen42723e22021-06-15 10:09:23 +03003430 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3431
3432 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3433 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3434 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3435 assert.NotEqual(t, e2SubsId2, 0)
3436
3437 <-time.After(100 * time.Millisecond)
3438
3439 // Delete both e2 subscriptions
3440 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3441 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3442 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3443
3444 waitSubsCleanup(t, e2SubsId, 10)
3445
3446 // Resend the original request, we shall find it's previous md5sum/restsubs
3447 // but the restsubscription has been already removed. This shall trigger a
3448 // fresh create.
3449 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3450
3451 <-time.After(100 * time.Millisecond)
3452
3453 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3454
3455 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003456 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003457 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003458}
3459
archaggeafbf95f2021-04-14 08:54:05 +03003460func TestRESTSubDelReqRetransmission(t *testing.T) {
3461 CaseBegin("TestRESTSubDelReqRetransmission")
3462
3463 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003464 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003465 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003466 Counter{cSubReqToE2, 1},
3467 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003468 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003469 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003470 Counter{cSubDelReqToE2, 1},
3471 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003472 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003473 })
3474
3475 var params *teststube2ap.RESTSubsReqParams = nil
3476
3477 //Subs Create
3478 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3479
3480 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3481
3482 //Subs Delete
3483 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3484 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3485
3486 seqBef := mainCtrl.get_msgcounter(t)
3487 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3488 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3489
3490 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3491
3492 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003493 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003494 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003495}
3496
3497//-----------------------------------------------------------------------------
3498// TestRESTSubReqDelReq
3499//
3500// stub stub
3501// +-------+ +---------+ +---------+
3502// | xapp | | submgr | | e2term |
3503// +-------+ +---------+ +---------+
3504// | | |
3505// | RESTSubReq | |
3506// |---------------->| |
3507// | | |
3508// | RESTSubResp | |
3509// |<----------------| |
3510// | | SubReq |
3511// | |------------->|
3512// | RESTSubDelReq | |
3513// |---------------->| |
3514// | RESTSubDelResp | |
3515// | unsuccess | |
3516// |<----------------| |
3517// | | SubResp |
3518// | |<-------------|
3519// | RESTNotif1 | |
3520// |<----------------| |
3521// | | |
3522// | [SUBS DELETE] |
3523// | | |
3524//
3525//-----------------------------------------------------------------------------
3526func TestRESTSubReqDelReq(t *testing.T) {
3527 CaseBegin("TestRESTSubReqDelReq")
3528
3529 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003530 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003531 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003532 Counter{cSubReqToE2, 1},
3533 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003534 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003535 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003536 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003537 Counter{cSubDelReqToE2, 1},
3538 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003539 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003540 })
3541
3542 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003543
3544 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003545 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003546 restSubId := xappConn1.SendRESTSubsReq(t, params)
3547
3548 // Del. This will fail as processing of the subscription
3549 // is still ongoing in submgr. Deletion is not allowed before
3550 // subscription creation has been completed.
3551 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3552 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3553 xappConn1.ExpectRESTNotification(t, restSubId)
3554 e2termConn1.SendSubsResp(t, crereq, cremsg)
3555 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3556
3557 // Retry del
3558 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3559
3560 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3561 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3562
3563 // Wait that subs is cleaned
3564 waitSubsCleanup(t, e2SubsId, 10)
3565 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003566 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003567}
3568
3569func TestRESTSubDelReqCollision(t *testing.T) {
3570 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3571}
3572
3573func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3574 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3575
3576 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003577 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003578 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003579 Counter{cSubReqToE2, 2},
3580 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003581 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003582 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003583 Counter{cSubDelReqToE2, 2},
3584 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003585 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003586 })
3587
3588 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003589 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003590 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003591 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003592
3593 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003594 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003595 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003596 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003597
3598 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3599 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3600
3601 //XappConn1 receives both of the responses
3602 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3603
3604 //Resp1
3605 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3606 //Resp2
3607 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3608
3609 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003610 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003611 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003612 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003613
3614 //Del1
3615 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3616 //Del2
3617 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3618
3619 //Wait that subs is cleaned
3620 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3621 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3622
3623 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003624 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003625}
3626
3627func TestRESTSameSubsDiffRan(t *testing.T) {
3628 CaseBegin("TestRESTSameSubsDiffRan")
3629
3630 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003631 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003632 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003633 Counter{cSubReqToE2, 2},
3634 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003635 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003636 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003637 Counter{cSubDelReqToE2, 2},
3638 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003639 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003640 })
3641
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003642 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003643 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003644 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003645
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003646 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003647 params.SetMeid("RAN_NAME_2")
3648 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003649 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003650
3651 //Del1
3652 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3653 //Del2
3654 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3655
3656 //Wait that subs is cleaned
3657 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3658 waitSubsCleanup(t, e2SubsId2, 10)
3659
3660 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003661 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003662}
3663
3664func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3665 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3666
3667 // Init counter check
3668 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003669 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003670 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003671 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003672 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003673 Counter{cSubReReqToE2, 1},
3674 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003675 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003676 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003677 Counter{cSubDelReqToE2, 1},
3678 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003679 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003680 })
3681
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003682 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003683 restSubId := xappConn1.SendRESTSubsReq(t, params)
3684
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003685 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003686
3687 // Catch the first message and ignore it
3688 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003689 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003690
3691 // The second request is being handled normally
3692 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3693 xappConn1.ExpectRESTNotification(t, restSubId)
3694 e2termConn1.SendSubsResp(t, crereq, cremsg)
3695 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3696
3697 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3698
3699 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3700
3701 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3702 //Wait that subs is cleaned
3703 waitSubsCleanup(t, e2SubsId, 10)
3704
3705 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003706 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003707}
3708
3709//-----------------------------------------------------------------------------
3710// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3711//
3712// stub stub
3713// +-------+ +---------+ +---------+
3714// | xapp | | submgr | | e2term |
3715// +-------+ +---------+ +---------+
3716// | | |
3717// | RESTSubReq | |
3718// |---------------->| |
3719// | | |
3720// | RESTSubResp | |
3721// |<----------------| |
3722// | | SubReq |
3723// | |------------->|
3724// | | |
3725// | | |
3726// | | SubReq |
3727// | |------------->|
3728// | | |
3729// | | SubDelReq |
3730// | |------------->|
3731// | | |
3732// | | |
3733// | | SubDelReq |
3734// | |------------->|
3735// | | |
3736// | | |
3737// | | SubDelResp |
3738// | |<-------------|
3739// | RESTNotif | |
3740// | unsuccess | |
3741// |<----------------| |
3742// | | |
3743// | [SUBS DELETE] |
3744// | | |
3745//
3746//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003747
archaggeafbf95f2021-04-14 08:54:05 +03003748func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3749 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3750
3751 // Init counter check
3752 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003753 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003754 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003755 Counter{cSubReqToE2, 1},
3756 Counter{cSubReReqToE2, 1},
3757 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003758 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003759 Counter{cSubDelReqToE2, 1},
3760 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003761 Counter{cRestSubDelReqFromXapp, 1},
3762 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003763 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003764
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003765 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003766 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003767 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003768
3769 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003770 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003771
3772 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003773 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003774
3775 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003776 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003777 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003778 xappConn1.WaitRESTNotification(t, restSubId)
3779
Anssi Mannilab43397e2021-11-16 12:06:16 +02003780 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3781
archaggeafbf95f2021-04-14 08:54:05 +03003782 // Wait that subs is cleaned
3783 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003784 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003785 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003786}
3787
3788func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3789 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3790
3791 // Init counter check
3792 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003793 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003794 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003795 Counter{cSubReqToE2, 1},
3796 Counter{cSubReReqToE2, 1},
3797 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003798 Counter{cSubDelReReqToE2, 1},
3799 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003800 Counter{cSubDelReqToE2, 1},
3801 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003802 Counter{cRestSubDelReqFromXapp, 1},
3803 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003804 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003805
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003806 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003807 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003808 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003809
3810 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003811 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003812
3813 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003814 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003815
3816 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003817 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003818
Markku Virtanen55d2a282021-06-04 14:46:56 +03003819 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003820 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003821 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003822
3823 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3824
Anssi Mannilab43397e2021-11-16 12:06:16 +02003825 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003826
Anssi Mannilab43397e2021-11-16 12:06:16 +02003827 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003828 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003829 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003830}
3831
3832//-----------------------------------------------------------------------------
3833// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3834//
3835// stub stub
3836// +-------+ +---------+ +---------+
3837// | xapp | | submgr | | e2term |
3838// +-------+ +---------+ +---------+
3839// | | |
3840// | RESTSubReq | |
3841// |---------------->| |
3842// | | |
3843// | RESTSubResp | |
3844// |<----------------| |
3845// | | SubReq |
3846// | |------------->|
3847// | | |
3848// | | |
3849// | | SubReq |
3850// | |------------->|
3851// | | |
3852// | | SubDelReq |
3853// | |------------->|
3854// | | |
3855// | | |
3856// | | SubDelReq |
3857// | |------------->|
3858// | | |
3859// | | |
3860// | | SubDelResp |
3861// | |<-------------|
3862// | RESTNotif | |
3863// | unsuccess | |
3864// |<----------------| |
3865// | | |
3866// | [SUBS DELETE] |
3867// | | |
3868//
3869//-----------------------------------------------------------------------------
3870func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3871 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3872
3873 // Init counter check
3874 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003875 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003876 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003877 Counter{cSubReqToE2, 1},
3878 Counter{cSubReReqToE2, 1},
3879 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003880 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003881 Counter{cSubDelReqToE2, 1},
3882 Counter{cSubDelReReqToE2, 1},
3883 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003884 Counter{cRestSubDelReqFromXapp, 1},
3885 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003886 })
3887
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003888 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003889 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003890 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003891
3892 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003893 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003894
3895 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003896 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003897
3898 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003899 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003900
Markku Virtanen55d2a282021-06-04 14:46:56 +03003901 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003902 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003903 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003904
3905 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3906
Anssi Mannilab43397e2021-11-16 12:06:16 +02003907 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003908
Anssi Mannilab43397e2021-11-16 12:06:16 +02003909 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003910 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003911 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003912}
3913
3914//-----------------------------------------------------------------------------
3915// TestRESTSubReqSubFailRespInSubmgr
3916//
3917// stub stub
3918// +-------+ +---------+ +---------+
3919// | xapp | | submgr | | e2term |
3920// +-------+ +---------+ +---------+
3921// | | |
3922// | RESTSubReq | |
3923// |---------------->| |
3924// | | |
3925// | RESTSubResp | |
3926// |<----------------| |
3927// | | SubReq |
3928// | |------------->|
3929// | | |
3930// | | SubFail |
3931// | |<-------------|
3932// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003933// | RESTNotif | |
3934// | unsuccess | |
3935// |<----------------| |
3936// | | |
3937// | [SUBS DELETE] |
3938// | | |
3939//
3940//-----------------------------------------------------------------------------
3941func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3942 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3943
3944 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003945 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003946 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003947 Counter{cSubReqToE2, 1},
3948 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003949 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003950 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003951 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003952 })
3953
3954 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003955 const e2Timeout int64 = 2
3956 const e2RetryCount int64 = 1
3957 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003958
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003959 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003960 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003961 restSubId := xappConn1.SendRESTSubsReq(t, params)
3962
3963 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3964 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3965 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003966 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003967 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3968
archaggeafbf95f2021-04-14 08:54:05 +03003969 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003970 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003971
3972 // REST subscription sill there to be deleted
3973 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3974
3975 // Wait that subs is cleaned
3976 waitSubsCleanup(t, e2SubsId, 10)
3977
3978 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003979 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003980}
3981
3982//-----------------------------------------------------------------------------
3983// TestRESTSubDelReqRetryInSubmgr
3984//
3985// stub stub
3986// +-------+ +---------+ +---------+
3987// | xapp | | submgr | | e2term |
3988// +-------+ +---------+ +---------+
3989// | | |
3990// | [SUBS CREATE] |
3991// | | |
3992// | | |
3993// | RESTSubDelReq | |
3994// |---------------->| |
3995// | | |
3996// | RESTSubDelResp | |
3997// |<----------------| |
3998// | | SubDelReq |
3999// | |------------->|
4000// | | |
4001// | | SubDelReq |
4002// | |------------->|
4003// | | |
4004// | | SubDelResp |
4005// | |<-------------|
4006// | | |
4007//
4008//-----------------------------------------------------------------------------
4009func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4010 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4011
4012 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004013 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004014 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004015 Counter{cSubReqToE2, 1},
4016 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004017 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004018 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004019 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004020 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004021 Counter{cSubDelReReqToE2, 1},
4022 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004023 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004024 })
4025 // Req
4026 var params *teststube2ap.RESTSubsReqParams = nil
4027 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4028
4029 // Del
4030 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4031
4032 // E2t: Receive 1st SubsDelReq
4033 e2termConn1.RecvSubsDelReq(t)
4034
4035 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4036 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4037 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4038
4039 //Wait that subs is cleaned
4040 waitSubsCleanup(t, e2SubsId, 10)
4041
4042 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004043 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004044}
4045
4046//-----------------------------------------------------------------------------
4047// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4048//
4049// stub stub
4050// +-------+ +---------+ +---------+
4051// | xapp | | submgr | | e2term |
4052// +-------+ +---------+ +---------+
4053// | | |
4054// | [SUBS CREATE] |
4055// | | |
4056// | | |
4057// | RESTSubDelReq | |
4058// |---------------->| |
4059// | | |
4060// | RESTSubDelResp | |
4061// |<----------------| |
4062// | | SubDelReq |
4063// | |------------->|
4064// | | |
4065// | | SubDelReq |
4066// | |------------->|
4067// | | |
4068// | | |
4069//
4070//-----------------------------------------------------------------------------
4071func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4072 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4073
4074 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004075 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004076 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004077 Counter{cSubReqToE2, 1},
4078 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004079 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004080 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004081 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004082 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004083 Counter{cSubDelReReqToE2, 1},
4084 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004085 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004086 })
4087
4088 // Req
4089 var params *teststube2ap.RESTSubsReqParams = nil
4090 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4091
4092 // Del
4093 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4094
4095 // E2t: Receive 1st SubsDelReq
4096 e2termConn1.RecvSubsDelReq(t)
4097
4098 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4099 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4100 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4101
4102 //Wait that subs is cleaned
4103 waitSubsCleanup(t, e2SubsId, 10)
4104
4105 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004106 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004107}
4108
4109//-----------------------------------------------------------------------------
4110// TestRESTSubDelReqSubDelFailRespInSubmgr
4111//
4112// stub stub
4113// +-------+ +---------+ +---------+
4114// | xapp | | submgr | | e2term |
4115// +-------+ +---------+ +---------+
4116// | | |
4117// | [SUBS CREATE] |
4118// | | |
4119// | | |
4120// | RESTSubDelReq | |
4121// |---------------->| |
4122// | | |
4123// | RESTSubDelResp | |
4124// |<----------------| |
4125// | | SubDelReq |
4126// | |------------->|
4127// | | |
4128// | | SubDelFail |
4129// | |<-------------|
4130// | | |
4131//
4132//-----------------------------------------------------------------------------
4133func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4134 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4135
4136 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004137 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004138 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004139 Counter{cSubReqToE2, 1},
4140 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004141 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004142 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004143 Counter{cSubDelReqToE2, 1},
4144 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004145 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004146 })
4147
4148 // Req
4149 var params *teststube2ap.RESTSubsReqParams = nil
4150 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4151
4152 // Del
4153 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4154
4155 // E2t: Send receive SubsDelReq and send SubsDelFail
4156 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4157 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4158
4159 //Wait that subs is cleaned
4160 waitSubsCleanup(t, e2SubsId, 10)
4161
4162 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004163 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004164}
4165
4166//-----------------------------------------------------------------------------
4167// TestRESTSubReqAndSubDelOkSameAction
4168//
4169// stub stub
4170// +-------+ +-------+ +---------+ +---------+
4171// | xapp2 | | xapp1 | | submgr | | e2term |
4172// +-------+ +-------+ +---------+ +---------+
4173// | | | |
4174// | | RESTSubReq1 | |
4175// | |---------------->| |
4176// | | | |
4177// | | RESTSubResp1 | |
4178// | |<----------------| |
4179// | | | |
4180// | | | SubReq1 |
4181// | | |------------->|
4182// | | | SubResp1 |
4183// | | |<-------------|
4184// | | RESTNotif1 | |
4185// | |<----------------| |
4186// | | | |
4187// | RESTSubReq2 | |
4188// |------------------------------>| |
4189// | | | |
4190// | RESTSubResp2 | |
4191// |<------------------------------| |
4192// | | | |
4193// | | RESTNotif2 | |
4194// |<------------------------------| |
4195// | | | |
4196// | | RESTSubDelReq1 | |
4197// | |---------------->| |
4198// | | | |
4199// | | RESTSubDelResp1 | |
4200// | |<----------------| |
4201// | | | |
4202// | RESTSubDelReq2 | |
4203// |------------------------------>| |
4204// | | | |
4205// | RESTSubDelResp2 | |
4206// |<------------------------------| |
4207// | | | |
4208// | | | SubDelReq2 |
4209// | | |------------->|
4210// | | | |
4211// | | | SubDelResp2 |
4212// | | |<-------------|
4213// | | | |
4214//
4215//-----------------------------------------------------------------------------
4216func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4217 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4218
4219 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004220 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004221 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004222 Counter{cSubReqToE2, 1},
4223 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004224 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004225 Counter{cMergedSubscriptions, 1},
4226 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004227 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004228 Counter{cSubDelReqToE2, 1},
4229 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004230 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004231 })
4232
4233 // Req1
4234 var params *teststube2ap.RESTSubsReqParams = nil
4235
4236 //Subs Create
4237 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4238 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4239
4240 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004241 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004242 params.SetMeid("RAN_NAME_1")
4243
4244 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004245 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004246 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004247 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004248 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004249 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004250 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004251 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004252
4253 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4254
4255 // Del1
4256 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4257
4258 // Del2
4259 deleteXapp2Subscription(t, &restSubId2)
4260
4261 //Wait that subs is cleaned
4262 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004263 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004264 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004265}
4266
4267//-----------------------------------------------------------------------------
4268// TestSubReqAndSubDelOkSameActionParallel
4269//
4270// stub stub stub
4271// +-------+ +-------+ +---------+ +---------+
4272// | xapp2 | | xapp1 | | submgr | | e2term |
4273// +-------+ +-------+ +---------+ +---------+
4274// | | | |
4275// | | | |
4276// | | | |
4277// | | SubReq1 | |
4278// | |------------->| |
4279// | | | |
4280// | | | SubReq1 |
4281// | | |------------->|
4282// | SubReq2 | |
4283// |--------------------------->| |
4284// | | | SubResp1 |
4285// | | |<-------------|
4286// | | SubResp1 | |
4287// | |<-------------| |
4288// | | | SubReq2 |
4289// | | |------------->|
4290// | | | |
4291// | | | SubResp2 |
4292// | | |<-------------|
4293// | SubResp2 | |
4294// |<---------------------------| |
4295// | | | |
4296// | | SubDelReq 1 | |
4297// | |------------->| |
4298// | | | |
4299// | | SubDelResp 1 | |
4300// | |<-------------| |
4301// | | | |
4302// | SubDelReq 2 | |
4303// |--------------------------->| |
4304// | | | |
4305// | | | SubDelReq 2 |
4306// | | |------------->|
4307// | | | |
4308// | | | SubDelReq 2 |
4309// | | |------------->|
4310// | | | |
4311// | SubDelResp 2 | |
4312// |<---------------------------| |
4313//
4314func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4315 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4316
4317 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004318 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004319 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004320 Counter{cSubReqToE2, 2},
4321 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004322 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004323 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004324 Counter{cSubDelReqToE2, 2},
4325 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004326 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004327 })
4328
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004329 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004330 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4331 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4332
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004333 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004334 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4335
4336 xappConn1.ExpectRESTNotification(t, restSubId1)
4337 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4338 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4339
4340 xappConn2.ExpectRESTNotification(t, restSubId2)
4341 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4342 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4343 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4344
4345 // Del1
4346 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4347 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4348 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4349 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4350
4351 // Del2
4352 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4353 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4354 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4355
4356 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004357 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004358 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004359}
4360
Anssi Mannilab43397e2021-11-16 12:06:16 +02004361/*
archaggeafbf95f2021-04-14 08:54:05 +03004362//-----------------------------------------------------------------------------
4363// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4364//
4365// stub stub stub
4366// +-------+ +-------+ +---------+ +---------+
4367// | xapp2 | | xapp1 | | submgr | | e2term |
4368// +-------+ +-------+ +---------+ +---------+
4369// | | | |
4370// | | | |
4371// | | | |
4372// | | RESTSubReq1 | |
4373// | |---------------->| |
4374// | | | |
4375// | | RESTSubResp1 | |
4376// | |<----------------| |
4377// | | | SubReq1 |
4378// | | |------------->|
4379// | RESTSubReq2 | |
4380// |------------------------------>| |
4381// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004382// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004383// |<------------------------------| |
4384// | | | SubReq1 |
4385// | | |------------->|
4386// | | | |
4387// | | | |
4388// | | | SubDelReq |
4389// | | |------------->|
4390// | | | |
4391// | | | SubDelResp |
4392// | | |<-------------|
4393// | | RESTNotif1 | |
4394// | | unsuccess | |
4395// | |<----------------| |
4396// | RESTNotif2 | |
4397// | | unsuccess | |
4398// |<------------------------------| |
4399// | | | |
4400// | | RESTSubDelReq1 | |
4401// | |---------------->| |
4402// | | | |
4403// | | RESTSubDelResp1 | |
4404// | |<----------------| |
4405// | | | |
4406// | RESTSubDelReq2 | |
4407// |------------------------------>| |
4408// | | | |
4409// | RESTSubDelResp2 | |
4410// |<------------------------------| |
4411//
4412//-----------------------------------------------------------------------------
4413func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4414 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4415
4416 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004417 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004418 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004419 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004420 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004421 Counter{cSubReqTimerExpiry, 2},
4422 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004423 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004424 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004425 Counter{cSubDelReqToE2, 1},
4426 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004427 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004428 })
archaggeafbf95f2021-04-14 08:54:05 +03004429 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004430
4431 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004432 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004433 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4434 crereq1, _ := e2termConn1.RecvSubsReq(t)
4435
4436 // Req2
4437 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004438 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004439 params2.SetMeid("RAN_NAME_1")
4440 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4441 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4442
4443 //Req1 (retransmitted)
4444 e2termConn1.RecvSubsReq(t)
4445
4446 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004447
4448 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004449 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4450
Markku Virtanenda34eec2021-05-20 08:22:04 +00004451 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004452 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004453 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004454 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004455
4456 // Del1
4457 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4458
4459 // Del2
4460 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4461
Markku Virtanenda34eec2021-05-20 08:22:04 +00004462 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4463
archaggeafbf95f2021-04-14 08:54:05 +03004464 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004465 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004466 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004467 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004468}
4469
4470//-----------------------------------------------------------------------------
4471// TestRESTSubReqAndSubDelNokSameActionParallel
4472//
4473// stub stub stub
4474// +-------+ +-------+ +---------+ +---------+
4475// | xapp2 | | xapp1 | | submgr | | e2term |
4476// +-------+ +-------+ +---------+ +---------+
4477// | | | |
4478// | | | |
4479// | | | |
4480// | | RESTSubReq1 | |
4481// | |---------------->| |
4482// | | | |
4483// | | RESTSubResp1 | |
4484// | |<----------------| |
4485// | | | SubReq1 |
4486// | | |------------->|
4487// | RESTSubReq2 | |
4488// |------------------------------>| |
4489// | | | |
4490// | RESTSubDelResp2 | |
4491// |<------------------------------| |
4492// | | | SubFail1 |
4493// | | |<-------------|
4494// | | | |
4495// | | RESTNotif1 | |
4496// | | unsuccess | |
4497// | |<----------------| |
4498// | RESTNotif2 | |
4499// | | unsuccess | |
4500// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004501// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004502// | | 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 +03004503// | |---------------->| |
4504// | | | |
4505// | | RESTSubDelResp1 | |
4506// | |<----------------| |
4507// | | | |
4508// | RESTSubDelReq2 | |
4509// |------------------------------>| |
4510// | | | |
4511// | RESTSubDelResp2 | |
4512// |<------------------------------| |
4513//
4514//-----------------------------------------------------------------------------
4515func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4516 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4517
4518 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004519 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004520 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004521 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004522 Counter{cSubReqToE2, 1},
4523 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004524 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004525 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004526 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004527 })
4528
4529 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004530
4531 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004532 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004533 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4534 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4535
4536 // Req2
4537 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004538 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004539 params2.SetMeid("RAN_NAME_1")
4540 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4541 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4542
4543 // E2t: send SubsFail (first)
4544 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4545 fparams1.Set(crereq1)
4546 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4547
archaggeafbf95f2021-04-14 08:54:05 +03004548 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004549 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004550 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004551 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004552 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004553
4554 // Del1
4555 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4556
4557 // Del2
4558 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4559
4560 //Wait that subs is cleaned
4561 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4562 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004563 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004564 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004565}
Anssi Mannilab43397e2021-11-16 12:06:16 +02004566*/
archaggeafbf95f2021-04-14 08:54:05 +03004567func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4568 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4569
4570 // Init counter check
4571 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004572 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004573 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004574 Counter{cSubReqToE2, 1},
4575 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004576 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004577 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004578 Counter{cSubDelReqToE2, 1},
4579 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004580 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004581 })
4582
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004583 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004584 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004585 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004586
4587 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4588 xappConn1.ExpectRESTNotification(t, restSubId)
4589 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4590 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004591 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004592
4593 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4594 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4595 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4596
4597 // Wait that subs is cleaned
4598 waitSubsCleanup(t, e2SubsId, 10)
4599 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004600 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004601}
4602
4603//-----------------------------------------------------------------------------
4604// TestRESTSubReqPolicyChangeAndSubDelOk
4605//
4606// stub stub
4607// +-------+ +---------+ +---------+
4608// | xapp | | submgr | | e2term |
4609// +-------+ +---------+ +---------+
4610// | | |
4611// | RESTSubReq | |
4612// |---------------->| |
4613// | | |
4614// | RESTSubResp | |
4615// |<----------------| |
4616// | | SubReq |
4617// | |------------->|
4618// | | |
4619// | | SubResp |
4620// | |<-------------|
4621// | | |
4622// | RESTNotif | |
4623// |<----------------| |
4624// | | |
4625// | RESTSubReq | |
4626// |---------------->| |
4627// | | |
4628// | RESTSubResp | |
4629// |<----------------| |
4630// | | SubReq |
4631// | |------------->|
4632// | | |
4633// | | SubResp |
4634// | |<-------------|
4635// | | |
4636// | RESTNotif | |
4637// |<----------------| |
4638// | | |
4639// | RESTSubDelReq | |
4640// |---------------->| |
4641// | | |
4642// | | SubDelReq |
4643// | |------------->|
4644// | | |
4645// | | SubDelResp |
4646// | |<-------------|
4647// | | |
4648// | RESTSubDelResp | |
4649// |<----------------| |
4650//
4651//-----------------------------------------------------------------------------
4652func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4653 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4654
4655 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004656 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004657 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004658 Counter{cSubReqToE2, 2},
4659 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004660 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004661 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004662 Counter{cSubDelReqToE2, 1},
4663 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004664 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004665 })
4666
4667 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004668 const e2Timeout int64 = 1
4669 const e2RetryCount int64 = 0
4670 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004671
4672 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004673 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004674 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004675 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4676
4677 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004678 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004679
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004680 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004681 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004682 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004683 params.SetTimeToWait("w200ms")
4684 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4685
4686 // Del
4687 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4688
4689 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4690 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4691
4692 // Wait that subs is cleaned
4693 waitSubsCleanup(t, e2SubsId, 10)
4694 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004695 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004696}
4697
4698//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004699// TestRESTSubReqPolicyChangeNOk
4700//
4701// stub stub
4702// +-------+ +---------+ +---------+
4703// | xapp | | submgr | | e2term |
4704// +-------+ +---------+ +---------+
4705// | | |
4706// | RESTSubReq | |
4707// |---------------->| |
4708// | | |
4709// | RESTSubResp | |
4710// |<----------------| |
4711// | | SubReq |
4712// | |------------->|
4713// | | |
4714// | | SubResp |
4715// | |<-------------|
4716// | | |
4717// | RESTNotif | |
4718// |<----------------| |
4719// | | |
4720// | RESTSubReq | |
4721// |---------------->| |
4722// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004723// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004724// | | |
4725// | RESTSubDelReq | |
4726// |---------------->| |
4727// | | |
4728// | | SubDelReq |
4729// | |------------->|
4730// | | |
4731// | | SubDelResp |
4732// | |<-------------|
4733// | | |
4734// | RESTSubDelResp | |
4735// |<----------------| |
4736//
4737//-----------------------------------------------------------------------------
4738func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4739 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4740
4741 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4742 Counter{cRestSubReqFromXapp, 2},
4743 Counter{cRestSubRespToXapp, 1},
4744 Counter{cSubReqToE2, 1},
4745 Counter{cSubRespFromE2, 1},
4746 Counter{cRestSubNotifToXapp, 1},
4747 Counter{cRestSubFailToXapp, 1},
4748 Counter{cRestSubDelReqFromXapp, 1},
4749 Counter{cSubDelReqToE2, 1},
4750 Counter{cSubDelRespFromE2, 1},
4751 Counter{cRestSubDelRespToXapp, 1},
4752 })
4753
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004754 // Req
4755 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4756 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4757
4758 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004759 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4760
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004761 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004762 params.SetSubscriptionID(&restSubIdUpd)
4763 params.SetTimeToWait("w200ms")
4764
4765 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4766 assert.Equal(t, restSubId2, "")
4767
4768 // Del
4769 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4770
4771 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4772 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4773
4774 // Wait that subs is cleaned
4775 waitSubsCleanup(t, e2SubsId, 10)
4776 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004777 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004778}
4779
4780//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004781// TestRESTSubReqAndSubDelOkTwoE2termParallel
4782//
4783// stub stub stub
4784// +-------+ +---------+ +---------+ +---------+
4785// | xapp | | submgr | | e2term1 | | e2term2 |
4786// +-------+ +---------+ +---------+ +---------+
4787// | | | |
4788// | | | |
4789// | | | |
4790// | RESTSubReq1 | | |
4791// |---------------->| | |
4792// | | | |
4793// | RESTSubResp1 | | |
4794// |<----------------| | |
4795// | | SubReq1 | |
4796// | |------------->| |
4797// | | | |
4798// | RESTSubReq2 | | |
4799// |---------------->| | |
4800// | | | |
4801// | RESTSubResp2 | | |
4802// |<----------------| | |
4803// | | SubReq2 | |
4804// | |---------------------------->|
4805// | | | |
4806// | | SubResp1 | |
4807// | |<-------------| |
4808// | RESTNotif1 | | |
4809// |<----------------| | |
4810// | | SubResp2 | |
4811// | |<----------------------------|
4812// | RESTNotif2 | | |
4813// |<----------------| | |
4814// | | | |
4815// | [SUBS 1 DELETE] | |
4816// | | | |
4817// | [SUBS 2 DELETE] | |
4818// | | | |
4819//
4820//-----------------------------------------------------------------------------
4821func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4822 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4823
4824 // Init counter check
4825 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004826 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004827 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004828 Counter{cSubReqToE2, 2},
4829 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004830 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004831 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004832 Counter{cSubDelReqToE2, 2},
4833 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004834 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004835 })
4836
4837 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004838
4839 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004840 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004841 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4842 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4843
4844 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004845 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004846 params.SetMeid("RAN_NAME_11")
4847 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4848 // would not work as notification would not be received
4849 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4850 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4851
4852 // Resp1
4853 xappConn1.ExpectRESTNotification(t, restSubId1)
4854 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4855 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004856 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004857
4858 // Resp2
4859 xappConn2.ExpectRESTNotification(t, restSubId2)
4860 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4861 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004862 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004863
4864 // Delete1
4865 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4866 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4867 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4868
4869 // Wait that subs is cleaned
4870 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4871
4872 // Delete2
4873 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4874 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4875 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4876
4877 // Wait that subs is cleaned
4878 waitSubsCleanup(t, e2SubsId2, 10)
4879
4880 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004881 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004882}
4883
4884//-----------------------------------------------------------------------------
4885// TestRESTSubReqAsn1EncodeFail
4886//
4887// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4888// stub stub
4889// +-------+ +---------+ +---------+
4890// | xapp | | submgr | | e2term |
4891// +-------+ +---------+ +---------+
4892// | | |
4893// | RESTSubReq | |
4894// |---------------->| |
4895// | | |
4896// | RESTSubResp | |
4897// |<----------------| |
4898// | RESTSubDelReq | |
4899// |---------------->| |
4900// | RESTSubDelResp | |
4901// | unsuccess | |
4902// |<----------------| |
4903// | | |
4904//
4905//-----------------------------------------------------------------------------
4906func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4907 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4908
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004909 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004910
4911}
4912
4913//-----------------------------------------------------------------------------
4914// TestRESTSubReqInsertAndSubDelOk
4915//
4916// stub stub
4917// +-------+ +---------+ +---------+
4918// | xapp | | submgr | | e2term |
4919// +-------+ +---------+ +---------+
4920// | | |
4921// | RestSubReq | |
4922// |---------------->| |
4923// | | |
4924// | RESTSubResp | |
4925// |<----------------| |
4926// | | |
4927// | | SubReq |
4928// | |------------->|
4929// | | |
4930// | | SubResp |
4931// | |<-------------|
4932// | RESTNotif | |
4933// |<----------------| |
4934// | ... | ... |
4935// | | |
4936// | RESTSubDelReq | |
4937// |---------------->| |
4938// | | |
4939// | | SubDelReq |
4940// | |------------->|
4941// | | |
4942// | | SubDelResp |
4943// | |<-------------|
4944// | | |
4945// | RESTSubDelResp| |
4946// |<----------------| |
4947//
4948//-----------------------------------------------------------------------------
4949func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4950 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4951
4952 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004953 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004954 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004955 Counter{cSubReqToE2, 1},
4956 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004957 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004958 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004959 Counter{cSubDelReqToE2, 1},
4960 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004961 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004962 })
4963
4964 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004965
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004966 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004967 params.SetSubActionTypes("insert")
4968
4969 // Req
4970 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4971
4972 // Del
4973 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4974
4975 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4976 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4977
4978 // Wait that subs is cleaned
4979 waitSubsCleanup(t, e2SubsId, 10)
4980 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004981 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004982}
4983
4984//-----------------------------------------------------------------------------
4985// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4986//
4987// stub stub
4988// +-------+ +---------+ +---------+
4989// | xapp | | submgr | | e2term |
4990// +-------+ +---------+ +---------+
4991// | | |
4992// | RESTSubReq | |
4993// |------------->| |
4994// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02004995// | RESTSubResp | |
4996// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004997// | | SubReq |
4998// | |------------->|
4999// | | |
5000// | | SubResp |
5001// | <----|
5002// | |
5003// | Submgr restart |
5004// | |
5005// | | |
5006// | | SubDelReq |
5007// | |------------->|
5008// | | |
5009// | | SubDelResp |
5010// | |<-------------|
5011// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005012// | RESTNotif | |
5013// | unsuccess | |
5014// |<-------------| |
5015// | | |
5016// | RESTSubDelReq| |
5017// |------------->| |
5018// | | |
5019// |RESTSubDelResp| |
5020// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005021//
5022//-----------------------------------------------------------------------------
5023func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5024 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5025
5026 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005027 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005028 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005029 Counter{cSubReqToE2, 1},
5030 Counter{cSubDelReqFromXapp, 1},
5031 Counter{cSubDelReqToE2, 1},
5032 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005033 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005034 Counter{cRestSubDelReqFromXapp, 1},
5035 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005036 })
5037
5038 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005039
5040 // Remove possible existing subscription
5041 mainCtrl.removeExistingSubscriptions(t)
5042
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005043 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005044
5045 //Req
5046 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5047 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005048 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005049
5050 e2termConn1.RecvSubsReq(t)
5051
5052 mainCtrl.SetResetTestFlag(t, false)
5053
5054 mainCtrl.SimulateRestart(t)
5055 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5056
Anssi Mannilab43397e2021-11-16 12:06:16 +02005057 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005058 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5059 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5060
Anssi Mannilab43397e2021-11-16 12:06:16 +02005061 //Del
5062 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5063
archaggeafbf95f2021-04-14 08:54:05 +03005064 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005065 e2termConn1.TestMsgChanEmpty(t)
5066 mainCtrl.wait_registry_empty(t, 10)
5067
5068 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005069 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005070}
5071
5072//-----------------------------------------------------------------------------
5073// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5074//
5075// stub stub
5076// +-------+ +---------+ +---------+
5077// | xapp | | submgr | | e2term |
5078// +-------+ +---------+ +---------+
5079// | | |
5080// | RESTSubReq | |
5081// |---------------->| |
5082// | | |
5083// | RESTSubResp | |
5084// |<----------------| |
5085// | | SubReq |
5086// | |------------->|
5087// | | |
5088// | | SubResp |
5089// | |<-------------|
5090// | | |
5091// | RESTNotif | |
5092// |<----------------| |
5093// | | |
5094// | |
5095// | Submgr restart |
5096// | | |
5097// | RESTSubDelReq | |
5098// |---------------->| |
5099// | | |
5100// | | SubDelReq |
5101// | |------------->|
5102// | | |
5103// | | SubDelResp |
5104// | |<-------------|
5105// | | |
5106// | RESTSubDelResp | |
5107// |<----------------| |
5108//
5109//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005110
archaggeafbf95f2021-04-14 08:54:05 +03005111func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5112 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5113
5114 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005115 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005116 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005117 Counter{cSubReqToE2, 1},
5118 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005119 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005120 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005121 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005122 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005123 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005124 })
archaggeafbf95f2021-04-14 08:54:05 +03005125 // Remove possible existing subscription
5126 mainCtrl.removeExistingSubscriptions(t)
5127
5128 var params *teststube2ap.RESTSubsReqParams = nil
5129
5130 // Create subscription
5131 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005132 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005133
5134 // Check subscription
5135 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5136
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005137 mainCtrl.SimulateRestart(t)
5138 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005139
5140 // Check subscription
5141 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5142
5143 // Delete subscription
5144 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5145
5146 //Wait that subs is cleaned
5147 waitSubsCleanup(t, e2SubsId, 10)
5148
5149 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005150 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005151}
5152
5153//-----------------------------------------------------------------------------
5154// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5155//
5156// stub stub
5157// +-------+ +-------+ +---------+ +---------+
5158// | xapp2 | | xapp1 | | submgr | | e2term |
5159// +-------+ +-------+ +---------+ +---------+
5160// | | | |
5161// | | RESTSubReq1 | |
5162// | |---------------->| |
5163// | | | |
5164// | | RESTSubResp1 | |
5165// | |<----------------| |
5166// | | | |
5167// | | | SubReq1 |
5168// | | |------------->|
5169// | | | SubResp1 |
5170// | | |<-------------|
5171// | | RESTNotif1 | |
5172// | |<----------------| |
5173// | | | |
5174// | RESTSubReq2 | |
5175// |------------------------------>| |
5176// | | | |
5177// | RESTSubResp2 | |
5178// |<------------------------------| |
5179// | | | |
5180// | | RESTNotif2 | |
5181// |<------------------------------| |
5182// | | | |
5183// | | Submgr restart |
5184// | | | |
5185// | | RESTSubDelReq1 | |
5186// | |---------------->| |
5187// | | | |
5188// | | RESTSubDelResp1 | |
5189// | |<----------------| |
5190// | | | |
5191// | | Submgr restart |
5192// | | | |
5193// | RESTSubDelReq2 | |
5194// |------------------------------>| |
5195// | | | |
5196// | RESTSubDelResp2 | |
5197// |<------------------------------| |
5198// | | | |
5199// | | | SubDelReq2 |
5200// | | |------------->|
5201// | | | |
5202// | | | SubDelResp2 |
5203// | | |<-------------|
5204// | | | |
5205//
5206//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005207
archaggeafbf95f2021-04-14 08:54:05 +03005208func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5209 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5210
5211 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005212 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005213 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005214 Counter{cSubReqToE2, 1},
5215 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005216 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005217 Counter{cMergedSubscriptions, 1},
5218 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005219 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005220 Counter{cSubDelReqToE2, 1},
5221 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005222 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005223 })
5224
5225 // Remove possible existing subscription
5226 mainCtrl.removeExistingSubscriptions(t)
5227
5228 var params *teststube2ap.RESTSubsReqParams = nil
5229
5230 // Create subscription 1
5231 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005232 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005233
5234 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005235 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005236 params.SetMeid("RAN_NAME_1")
5237 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005238 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005239 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005240 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005241 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005242 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005243
5244 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5245
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005246 mainCtrl.SimulateRestart(t)
5247 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005248
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005249 // Delete subscription 1, and wait until it has removed the first endpoint
5250 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005251 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005252 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005253
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005254 mainCtrl.SimulateRestart(t)
5255 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005256 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5257
5258 // Delete subscription 2
5259 deleteXapp2Subscription(t, &restSubId2)
5260
5261 //Wait that subs is cleaned
5262 waitSubsCleanup(t, e2SubsId2, 10)
5263
5264 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005265 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005266}
5267
5268//-----------------------------------------------------------------------------
5269// TestRESTReportSubReqAndSubDelOk
5270//
5271// stub stub
5272// +-------+ +---------+ +---------+
5273// | xapp | | submgr | | e2term |
5274// +-------+ +---------+ +---------+
5275// | | |
5276// | RestSubReq | |
5277// |---------------->| |
5278// | | |
5279// | RESTSubResp | |
5280// |<----------------| |
5281// | | |
5282// | | SubReq |
5283// | |------------->|
5284// | | |
5285// | | SubResp |
5286// | |<-------------|
5287// | RESTNotif | |
5288// |<----------------| |
5289// | | SubReq |
5290// | |------------->|
5291// | | |
5292// | | SubResp |
5293// | |<-------------|
5294// | RESTNotif | |
5295// |<----------------| |
5296// | ... | ... |
5297// | | |
5298// | | |
5299// | RESTSubDelReq | |
5300// |---------------->| |
5301// | | |
5302// | | SubDelReq |
5303// | |------------->|
5304// | | |
5305// | | SubDelResp |
5306// | |<-------------|
5307// | | |
5308// | RESTSubDelResp| |
5309// |<----------------| |
5310//
5311//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005312
archaggeafbf95f2021-04-14 08:54:05 +03005313func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5314 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005315 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005316 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005317 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005318}
5319
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005320func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005321 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005322
5323 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005324 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005325 restSubId := xappConn1.SendRESTSubsReq(t, params)
5326
5327 var e2SubsId []uint32
5328 for i := 0; i < subReqCount; i++ {
5329 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5330 xappConn1.ExpectRESTNotification(t, restSubId)
5331
5332 e2termConn1.SendSubsResp(t, crereq, cremsg)
5333 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005334 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005335 e2SubsId = append(e2SubsId, instanceId)
5336 resp, _ := xapp.Subscription.QuerySubscriptions()
5337 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5338 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5339 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5340
5341 }
5342
5343 // Del
5344 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5345
5346 for i := 0; i < subReqCount; i++ {
5347 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5348 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5349 }
5350
5351 // Wait that subs is cleaned
5352 for i := 0; i < subReqCount; i++ {
5353 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5354 }
5355
5356 xappConn1.TestMsgChanEmpty(t)
5357 e2termConn1.TestMsgChanEmpty(t)
5358 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005359 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005360}
5361
5362/*
5363func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5364 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5365
5366 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005367 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005368 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005369
5370 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005371 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005372 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005373}
5374*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005375func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005376 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005377
5378 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005379 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005380 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005381
5382 var e2SubsId []uint32
5383 for i := 0; i < subReqCount; i++ {
5384 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5385 xappConn1.ExpectRESTNotification(t, restSubId)
5386 e2termConn1.SendSubsResp(t, crereq, cremsg)
5387 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005388 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005389 e2SubsId = append(e2SubsId, instanceId)
5390 }
5391
5392 // Del
5393 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5394
5395 for i := 0; i < subReqCount; i++ {
5396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5397 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5398 }
5399
5400 // Wait that subs is cleaned
5401 for i := 0; i < subReqCount; i++ {
5402 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5403 }
5404 xappConn1.TestMsgChanEmpty(t)
5405 e2termConn1.TestMsgChanEmpty(t)
5406 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005407 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005408}
5409
archaggeafbf95f2021-04-14 08:54:05 +03005410func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5411
archaggeafbf95f2021-04-14 08:54:05 +03005412 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005413 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005414 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005415 Counter{cSubReqToE2, 2},
5416 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005417 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005418 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005419 Counter{cSubDelReqToE2, 2},
5420 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005421 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005422 })
5423
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005424 const subReqCount int = 2
5425
archaggeafbf95f2021-04-14 08:54:05 +03005426 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005427 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005428 restSubId := xappConn1.SendRESTSubsReq(t, params)
5429 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5430
5431 assert.Equal(t, len(e2SubsIds), 2)
5432
5433 // Del
5434 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5435 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5436
5437 xappConn1.TestMsgChanEmpty(t)
5438 e2termConn1.TestMsgChanEmpty(t)
5439 mainCtrl.wait_registry_empty(t, 10)
5440
5441 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005442 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005443}
archaggeafbf95f2021-04-14 08:54:05 +03005444func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5445
archaggeafbf95f2021-04-14 08:54:05 +03005446 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005447 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005448 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005449 Counter{cSubReqToE2, 19},
5450 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005451 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005452 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005453 Counter{cSubDelReqToE2, 19},
5454 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005455 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005456 })
5457
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005458 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005459 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005460 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005461 restSubId := xappConn1.SendRESTSubsReq(t, params)
5462 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5463
5464 assert.Equal(t, len(e2SubsIds), 19)
5465
5466 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5467 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5468
5469 xappConn1.TestMsgChanEmpty(t)
5470 e2termConn1.TestMsgChanEmpty(t)
5471 mainCtrl.wait_registry_empty(t, 10)
5472
5473 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005474 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005475}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005476
archaggeafbf95f2021-04-14 08:54:05 +03005477func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5478
5479 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005480
5481 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005482 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005483 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005484 Counter{cSubReqToE2, uint64(subReqCount)},
5485 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005486 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005487 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005488 Counter{cSubDelReqToE2, uint64(subReqCount)},
5489 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005490 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005491 })
5492
5493 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005494 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005495 restSubId := xappConn1.SendRESTSubsReq(t, params)
5496 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5497
5498 assert.Equal(t, len(e2SubsIds), subReqCount)
5499
5500 // Del
5501 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5502 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5503
5504 xappConn1.TestMsgChanEmpty(t)
5505 e2termConn1.TestMsgChanEmpty(t)
5506 mainCtrl.wait_registry_empty(t, 10)
5507
5508 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005509 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005510}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005511
archaggeafbf95f2021-04-14 08:54:05 +03005512func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5513
5514 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005515
5516 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005517 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005518 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005519 Counter{cSubReqToE2, uint64(subReqCount)},
5520 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005521 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005522 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005523 Counter{cSubDelReqToE2, uint64(subReqCount)},
5524 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005525 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005526 })
5527
5528 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005529 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005530 restSubId := xappConn1.SendRESTSubsReq(t, params)
5531 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5532
5533 assert.Equal(t, len(e2SubsIds), subReqCount)
5534
5535 // Del
5536 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5537 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5538
5539 xappConn1.TestMsgChanEmpty(t)
5540 e2termConn1.TestMsgChanEmpty(t)
5541 mainCtrl.wait_registry_empty(t, 10)
5542
5543 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005544 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005545}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005546
archaggeafbf95f2021-04-14 08:54:05 +03005547func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5548
5549 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005550
5551 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005552 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005553 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005554 Counter{cSubReqToE2, uint64(subReqCount)},
5555 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005556 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005557 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005558 Counter{cSubDelReqToE2, uint64(subReqCount)},
5559 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005560 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005561 })
5562
5563 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005564 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005565 restSubId := xappConn1.SendRESTSubsReq(t, params)
5566 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5567
5568 assert.Equal(t, len(e2SubsIds), subReqCount)
5569
5570 // Del
5571 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5572 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5573
5574 xappConn1.TestMsgChanEmpty(t)
5575 e2termConn1.TestMsgChanEmpty(t)
5576 mainCtrl.wait_registry_empty(t, 10)
5577
5578 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005579 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005580}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005581
5582func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5583 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5584
5585 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005586 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005587 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005588 Counter{cSubReqToE2, 2},
5589 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005590 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005591 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005592 Counter{cSubDelReqToE2, 2},
5593 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005594 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005595 })
5596
5597 // Req1
5598 var params *teststube2ap.RESTSubsReqParams = nil
5599
5600 //Subs Create
5601 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005602 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005603
5604 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5605
5606 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005607 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005608 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005609 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005610 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5611
5612 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005613 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005614 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5615 xappConn2.ExpectRESTNotification(t, restSubId2)
5616 e2termConn1.SendSubsResp(t, crereq, cremsg)
5617 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5618
5619 deleteXapp1Subscription(t, &restSubId1)
5620 deleteXapp2Subscription(t, &restSubId2)
5621
5622 waitSubsCleanup(t, e2SubsId1, 10)
5623 waitSubsCleanup(t, e2SubsId2, 10)
5624
5625 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005626 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005627}
5628
5629func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5630 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5631
5632 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005633 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005634 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005635 Counter{cSubReqToE2, 2},
5636 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005637 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005638 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005639 Counter{cSubDelReqToE2, 2},
5640 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005641 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005642 })
5643
5644 // Req1
5645 var params *teststube2ap.RESTSubsReqParams = nil
5646
5647 //Subs Create
5648 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005649 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005650
5651 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5652
5653 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005654 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005655 params.SetMeid("RAN_NAME_1")
5656
5657 actionId := int64(1)
5658 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005659 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005660 subsequestActionType := "continue"
5661 timeToWait := "w10ms"
5662 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5663
5664 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005665 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005666 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5667 xappConn2.ExpectRESTNotification(t, restSubId2)
5668 e2termConn1.SendSubsResp(t, crereq, cremsg)
5669 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5670
5671 deleteXapp1Subscription(t, &restSubId1)
5672 deleteXapp2Subscription(t, &restSubId2)
5673
5674 waitSubsCleanup(t, e2SubsId1, 10)
5675 waitSubsCleanup(t, e2SubsId2, 10)
5676
5677 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005678 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005679}
5680
5681func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5682 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5683
5684 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005685 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005686 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005687 Counter{cSubReqToE2, 2},
5688 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005689 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005690 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005691 Counter{cSubDelReqToE2, 2},
5692 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005693 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005694 })
5695
5696 // Req1
5697 var params *teststube2ap.RESTSubsReqParams = nil
5698
5699 //Subs Create
5700 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005701 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005702
5703 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5704
5705 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005706 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005707 params.SetMeid("RAN_NAME_1")
5708 params.SetSubActionIDs(int64(2))
5709
5710 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005711 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005712 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5713 xappConn2.ExpectRESTNotification(t, restSubId2)
5714 e2termConn1.SendSubsResp(t, crereq, cremsg)
5715 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5716
5717 deleteXapp1Subscription(t, &restSubId1)
5718 deleteXapp2Subscription(t, &restSubId2)
5719
5720 waitSubsCleanup(t, e2SubsId1, 10)
5721 waitSubsCleanup(t, e2SubsId2, 10)
5722
5723 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005724 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005725}
5726
5727func TestRESTSubReqDiffActionType(t *testing.T) {
5728 CaseBegin("TestRESTSubReqDiffActionType")
5729
5730 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005731 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005732 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005733 Counter{cSubReqToE2, 2},
5734 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005735 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005736 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005737 Counter{cSubDelReqToE2, 2},
5738 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005739 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005740 })
5741
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005742 const e2Timeout int64 = 2
5743 const e2RetryCount int64 = 2
5744 const routingNeeded bool = true
5745
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005746 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005747 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005748 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005749
5750 //Subs Create
5751 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005752 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005753
5754 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5755
5756 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005757 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005758 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005759 params.SetMeid("RAN_NAME_1")
5760
5761 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005762 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005763 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5764 xappConn2.ExpectRESTNotification(t, restSubId2)
5765 e2termConn1.SendSubsResp(t, crereq, cremsg)
5766 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5767
5768 deleteXapp1Subscription(t, &restSubId1)
5769 deleteXapp2Subscription(t, &restSubId2)
5770
5771 waitSubsCleanup(t, e2SubsId1, 10)
5772 waitSubsCleanup(t, e2SubsId2, 10)
5773
5774 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005775 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005776}
5777
5778func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5779 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5780
5781 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005782 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005783 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005784 Counter{cSubReqToE2, 2},
5785 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005786 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005787 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005788 Counter{cSubDelReqToE2, 2},
5789 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005790 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005791 })
5792
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005793 const e2Timeout int64 = 2
5794 const e2RetryCount int64 = 2
5795 const routingNeeded bool = true
5796
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005797 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005798 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005799 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005800
5801 //Subs Create
5802 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005803 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005804
5805 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5806
5807 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005808 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005809 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005810 params.SetMeid("RAN_NAME_1")
5811
5812 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005813 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005814 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5815 xappConn2.ExpectRESTNotification(t, restSubId2)
5816 e2termConn1.SendSubsResp(t, crereq, cremsg)
5817 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5818
5819 deleteXapp1Subscription(t, &restSubId1)
5820 deleteXapp2Subscription(t, &restSubId2)
5821
5822 waitSubsCleanup(t, e2SubsId1, 10)
5823 waitSubsCleanup(t, e2SubsId2, 10)
5824
5825 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005826 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005827}
5828
5829func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5830 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5831
5832 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005833 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005834 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005835 Counter{cSubReqToE2, 2},
5836 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005837 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005838 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005839 Counter{cSubDelReqToE2, 2},
5840 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005841 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005842 })
5843
5844 // Req1
5845 var params *teststube2ap.RESTSubsReqParams = nil
5846
5847 //Subs Create
5848 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005849 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005850
5851 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5852
5853 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005854 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005855 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005856 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005857 params.SetSubActionDefinition(actionDefinition)
5858
5859 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005860 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005861 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5862 xappConn2.ExpectRESTNotification(t, restSubId2)
5863 e2termConn1.SendSubsResp(t, crereq, cremsg)
5864 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5865
5866 deleteXapp1Subscription(t, &restSubId1)
5867 deleteXapp2Subscription(t, &restSubId2)
5868
5869 waitSubsCleanup(t, e2SubsId1, 10)
5870 waitSubsCleanup(t, e2SubsId2, 10)
5871
5872 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005873 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005874}
5875
5876func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5877 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5878
5879 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005880 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005881 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005882 Counter{cSubReqToE2, 2},
5883 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005884 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005885 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005886 Counter{cSubDelReqToE2, 2},
5887 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005888 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005889 })
5890
5891 // Req1
5892 var params *teststube2ap.RESTSubsReqParams = nil
5893
5894 //Subs Create
5895 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005896 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005897
5898 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5899
5900 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005901 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005902 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005903 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005904 params.SetSubActionDefinition(actionDefinition)
5905
5906 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005907 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005908 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5909 xappConn2.ExpectRESTNotification(t, restSubId2)
5910 e2termConn1.SendSubsResp(t, crereq, cremsg)
5911 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5912
5913 deleteXapp1Subscription(t, &restSubId1)
5914 deleteXapp2Subscription(t, &restSubId2)
5915
5916 waitSubsCleanup(t, e2SubsId1, 10)
5917 waitSubsCleanup(t, e2SubsId2, 10)
5918
5919 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005920 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005921}
5922
5923func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5924 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5925
5926 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005927 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005928 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005929 Counter{cSubReqToE2, 2},
5930 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005931 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005932 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005933 Counter{cSubDelReqToE2, 2},
5934 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005935 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005936 })
5937
5938 // Req1
5939 var params *teststube2ap.RESTSubsReqParams = nil
5940
5941 //Subs Create
5942 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005943 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005944
5945 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5946
5947 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005948 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005949 params.SetMeid("RAN_NAME_1")
5950 params.SetTimeToWait("w200ms")
5951 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005952 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005953 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5954 xappConn2.ExpectRESTNotification(t, restSubId2)
5955 e2termConn1.SendSubsResp(t, crereq, cremsg)
5956 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5957
5958 deleteXapp1Subscription(t, &restSubId1)
5959 deleteXapp2Subscription(t, &restSubId2)
5960
5961 waitSubsCleanup(t, e2SubsId1, 10)
5962 waitSubsCleanup(t, e2SubsId2, 10)
5963
5964 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005965 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005966}
5967
Anssi Mannila51122392021-05-25 11:51:31 +03005968//-----------------------------------------------------------------------------
5969// TestRESTUnpackSubscriptionResponseDecodeFail
5970//
5971// stub stub
5972// +-------+ +---------+ +---------+
5973// | xapp | | submgr | | e2term |
5974// +-------+ +---------+ +---------+
5975// | | |
5976// | RestSubReq | |
5977// |---------------->| |
5978// | | |
5979// | RESTSubResp | |
5980// |<----------------| |
5981// | | |
5982// | | SubReq |
5983// | |------------->|
5984// | | |
5985// | | SubResp | ASN.1 decode fails
5986// | |<-------------|
5987// | | |
5988// | | SubReq |
5989// | |------------->|
5990// | | |
5991// | | SubFail | Duplicated action
5992// | |<-------------|
5993// | RESTNotif (fail)| |
5994// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03005995// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03005996//
5997//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005998
Anssi Mannila51122392021-05-25 11:51:31 +03005999func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006000 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
6001 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006002
6003 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006004 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006005 restSubId := xappConn1.SendRESTSubsReq(t, params)
6006
6007 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6008 // Decode of this response fails which will result resending original request
6009 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6010
6011 _, cremsg = e2termConn1.RecvSubsReq(t)
6012
Markku Virtanen55d2a282021-06-04 14:46:56 +03006013 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006014
6015 // Subscription already created in E2 Node.
6016 fparams := &teststube2ap.E2StubSubsFailParams{}
6017 fparams.Set(crereq)
6018 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6019 e2termConn1.SendSubsFail(t, fparams, cremsg)
6020
Anssi Mannila51122392021-05-25 11:51:31 +03006021 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006022 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006023
Anssi Mannilab43397e2021-11-16 12:06:16 +02006024 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6025
Anssi Mannila51122392021-05-25 11:51:31 +03006026 // Wait that subs is cleaned
6027 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6028
6029 xappConn1.TestMsgChanEmpty(t)
6030 e2termConn1.TestMsgChanEmpty(t)
6031 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006032 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006033}
6034
6035//-----------------------------------------------------------------------------
6036// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6037//
6038// stub stub
6039// +-------+ +---------+ +---------+
6040// | xapp | | submgr | | e2term |
6041// +-------+ +---------+ +---------+
6042// | | |
6043// | RestSubReq | |
6044// |---------------->| |
6045// | | |
6046// | RESTSubResp | |
6047// |<----------------| |
6048// | | |
6049// | | SubReq |
6050// | |------------->|
6051// | | |
6052// | | SubResp | Unknown instanceId
6053// | |<-------------|
6054// | | |
6055// | | SubReq |
6056// | |------------->|
6057// | | |
6058// | | SubFail | Duplicated action
6059// | |<-------------|
6060// | RESTNotif (fail)| |
6061// |<----------------| |
6062// | | SubDelReq |
6063// | |------------->|
6064// | | |
6065// | | SubDelResp |
6066// | |<-------------|
6067//
6068//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006069
Anssi Mannila51122392021-05-25 11:51:31 +03006070func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006071 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6072 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006073
6074 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006075 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006076 restSubId := xappConn1.SendRESTSubsReq(t, params)
6077
6078 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6079
6080 // Unknown instanceId in this response which will result resending original request
6081 orgInstanceId := crereq.RequestId.InstanceId
6082 crereq.RequestId.InstanceId = 0
6083 e2termConn1.SendSubsResp(t, crereq, cremsg)
6084
6085 _, cremsg = e2termConn1.RecvSubsReq(t)
6086
Markku Virtanen55d2a282021-06-04 14:46:56 +03006087 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006088
6089 // Subscription already created in E2 Node.
6090 fparams := &teststube2ap.E2StubSubsFailParams{}
6091 fparams.Set(crereq)
6092 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6093 e2termConn1.SendSubsFail(t, fparams, cremsg)
6094
6095 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6096 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6097
6098 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006099 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006100
Anssi Mannilab43397e2021-11-16 12:06:16 +02006101 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6102
Anssi Mannila51122392021-05-25 11:51:31 +03006103 // Wait that subs is cleaned
6104 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6105
6106 xappConn1.TestMsgChanEmpty(t)
6107 e2termConn1.TestMsgChanEmpty(t)
6108 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006109 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006110}
6111
6112//-----------------------------------------------------------------------------
6113// TestRESTUnpackSubscriptionResponseNoTransaction
6114//
6115// stub stub
6116// +-------+ +---------+ +---------+
6117// | xapp | | submgr | | e2term |
6118// +-------+ +---------+ +---------+
6119// | | |
6120// | RestSubReq | |
6121// |---------------->| |
6122// | | |
6123// | RESTSubResp | |
6124// |<----------------| |
6125// | | |
6126// | | SubReq |
6127// | |------------->|
6128// | | |
6129// | | SubResp | No transaction for the response
6130// | |<-------------|
6131// | | |
6132// | | SubReq |
6133// | |------------->|
6134// | | |
6135// | | SubFail | Duplicated action
6136// | |<-------------|
6137// | RESTNotif (fail)| |
6138// |<----------------| |
6139// | | SubDelReq |
6140// | |------------->|
6141// | | |
6142// | | SubDelResp |
6143// | |<-------------|
6144// | | |
6145// | | SubDelReq |
6146// | |------------->|
6147// | | |
6148// | | SubDelResp |
6149// | |<-------------|
6150//
6151//-----------------------------------------------------------------------------
6152func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006153 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6154 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006155
6156 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006157 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006158 restSubId := xappConn1.SendRESTSubsReq(t, params)
6159
6160 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6161
6162 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6163 // No transaction exist for this response which will result resending original request
6164 e2termConn1.SendSubsResp(t, crereq, cremsg)
6165
6166 _, cremsg = e2termConn1.RecvSubsReq(t)
6167
Markku Virtanen55d2a282021-06-04 14:46:56 +03006168 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006169
6170 // Subscription already created in E2 Node.
6171 fparams := &teststube2ap.E2StubSubsFailParams{}
6172 fparams.Set(crereq)
6173 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6174 e2termConn1.SendSubsFail(t, fparams, cremsg)
6175
6176 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6177 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6178
6179 // Resending happens because there no transaction
6180 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6181 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6182
6183 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006184 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006185
Anssi Mannilab43397e2021-11-16 12:06:16 +02006186 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6187
Anssi Mannila51122392021-05-25 11:51:31 +03006188 // Wait that subs is cleaned
6189 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6190
6191 xappConn1.TestMsgChanEmpty(t)
6192 e2termConn1.TestMsgChanEmpty(t)
6193 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006194 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006195}
6196
6197//-----------------------------------------------------------------------------
6198// TestRESTUnpackSubscriptionFailureDecodeFail
6199//
6200// stub stub
6201// +-------+ +---------+ +---------+
6202// | xapp | | submgr | | e2term |
6203// +-------+ +---------+ +---------+
6204// | | |
6205// | RestSubReq | |
6206// |---------------->| |
6207// | | |
6208// | RESTSubResp | |
6209// |<----------------| |
6210// | | |
6211// | | SubReq |
6212// | |------------->|
6213// | | |
6214// | | SubFail | ASN.1 decode fails
6215// | |<-------------|
6216// | | |
6217// | | SubReq |
6218// | |------------->|
6219// | | |
6220// | | SubFail | Duplicated action
6221// | |<-------------|
6222// | RESTNotif (fail)| |
6223// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006224// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006225//
6226//-----------------------------------------------------------------------------
6227func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006228 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6229 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006230
6231 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006232 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006233 restSubId := xappConn1.SendRESTSubsReq(t, params)
6234
6235 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6236
6237 // Decode of this response fails which will result resending original request
6238 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6239
6240 _, cremsg = e2termConn1.RecvSubsReq(t)
6241
Markku Virtanen55d2a282021-06-04 14:46:56 +03006242 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006243
6244 // Subscription already created in E2 Node.
6245 fparams := &teststube2ap.E2StubSubsFailParams{}
6246 fparams.Set(crereq)
6247 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6248 e2termConn1.SendSubsFail(t, fparams, cremsg)
6249
Anssi Mannila51122392021-05-25 11:51:31 +03006250 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006251 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006252
Anssi Mannilab43397e2021-11-16 12:06:16 +02006253 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6254
Anssi Mannila51122392021-05-25 11:51:31 +03006255 // Wait that subs is cleaned
6256 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6257
6258 xappConn1.TestMsgChanEmpty(t)
6259 e2termConn1.TestMsgChanEmpty(t)
6260 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006261 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006262}
6263
6264//-----------------------------------------------------------------------------
6265// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6266//
6267// stub stub
6268// +-------+ +---------+ +---------+
6269// | xapp | | submgr | | e2term |
6270// +-------+ +---------+ +---------+
6271// | | |
6272// | RestSubReq | |
6273// |---------------->| |
6274// | | |
6275// | RESTSubResp | |
6276// |<----------------| |
6277// | | |
6278// | | SubReq |
6279// | |------------->|
6280// | | |
6281// | | SubFail | Unknown instanceId
6282// | |<-------------|
6283// | | |
6284// | | SubReq |
6285// | |------------->|
6286// | | |
6287// | | SubFail | Duplicated action
6288// | |<-------------|
6289// | RESTNotif (fail)| |
6290// |<----------------| |
6291// | | SubDelReq |
6292// | |------------->|
6293// | | |
6294// | | SubDelResp |
6295// | |<-------------|
6296//
6297//-----------------------------------------------------------------------------
6298func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006299 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6300 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006301
6302 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006303 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006304 restSubId := xappConn1.SendRESTSubsReq(t, params)
6305
6306 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6307
6308 // Unknown instanceId in this response which will result resending original request
6309 fparams := &teststube2ap.E2StubSubsFailParams{}
6310 fparams.Set(crereq)
6311 fparams.Fail.RequestId.InstanceId = 0
6312 e2termConn1.SendSubsFail(t, fparams, cremsg)
6313
6314 _, cremsg = e2termConn1.RecvSubsReq(t)
6315
Markku Virtanen55d2a282021-06-04 14:46:56 +03006316 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006317
6318 // Subscription already created in E2 Node.
6319 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6320 e2termConn1.SendSubsFail(t, fparams, cremsg)
6321
6322 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6323 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6324
6325 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006326 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006327
Anssi Mannilab43397e2021-11-16 12:06:16 +02006328 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6329
Anssi Mannila51122392021-05-25 11:51:31 +03006330 // Wait that subs is cleaned
6331 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6332
6333 xappConn1.TestMsgChanEmpty(t)
6334 e2termConn1.TestMsgChanEmpty(t)
6335 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006336 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006337}
6338
6339//-----------------------------------------------------------------------------
6340// TestRESTUnpackSubscriptionFailureNoTransaction
6341//
6342// stub stub
6343// +-------+ +---------+ +---------+
6344// | xapp | | submgr | | e2term |
6345// +-------+ +---------+ +---------+
6346// | | |
6347// | RestSubReq | |
6348// |---------------->| |
6349// | | |
6350// | RESTSubResp | |
6351// |<----------------| |
6352// | | |
6353// | | SubReq |
6354// | |------------->|
6355// | | |
6356// | | SubFail | No transaction for the response
6357// | |<-------------|
6358// | | |
6359// | | SubReq |
6360// | |------------->|
6361// | | |
6362// | | SubFail | Duplicated action
6363// | |<-------------|
6364// | RESTNotif (fail)| |
6365// |<----------------| |
6366// | | SubDelReq |
6367// | |------------->|
6368// | | |
6369// | | SubDelResp |
6370// | |<-------------|
6371//
6372//-----------------------------------------------------------------------------
6373func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006374 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6375 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006376
6377 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006378 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006379 restSubId := xappConn1.SendRESTSubsReq(t, params)
6380
6381 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6382
6383 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6384
6385 // No transaction exist for this response which will result resending original request
6386 fparams := &teststube2ap.E2StubSubsFailParams{}
6387 fparams.Set(crereq)
6388 e2termConn1.SendSubsFail(t, fparams, cremsg)
6389
6390 _, cremsg = e2termConn1.RecvSubsReq(t)
6391
Markku Virtanen55d2a282021-06-04 14:46:56 +03006392 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006393
6394 // Subscription already created in E2 Node.
6395 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6396 e2termConn1.SendSubsFail(t, fparams, cremsg)
6397
6398 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6399 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6400
6401 // Resending happens because there no transaction
6402 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6403 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6404
6405 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006406 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006407
Anssi Mannilab43397e2021-11-16 12:06:16 +02006408 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6409
Anssi Mannila51122392021-05-25 11:51:31 +03006410 // Wait that subs is cleaned
6411 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6412
6413 xappConn1.TestMsgChanEmpty(t)
6414 e2termConn1.TestMsgChanEmpty(t)
6415 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006416 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006417}
6418
6419//-----------------------------------------------------------------------------
6420// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6421//
6422// stub stub
6423// +-------+ +---------+ +---------+
6424// | xapp | | submgr | | e2term |
6425// +-------+ +---------+ +---------+
6426// | | |
6427// | [SUBS CREATE] |
6428// | | |
6429// | | |
6430// | RESTSubDelReq | |
6431// |---------------->| |
6432// | | |
6433// | RESTSubDelResp | |
6434// |<----------------| |
6435// | | |
6436// | | SubDelReq |
6437// | |------------->|
6438// | | |
6439// | | SubDelResp | ASN.1 decode fails
6440// | |<-------------|
6441// | | |
6442// | | SubDelReq |
6443// | |------------->|
6444// | | |
6445// | | SubDelFail | Subscription does exist any more
6446// | |<-------------|
6447// | | |
6448//
6449//-----------------------------------------------------------------------------
6450func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006451 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006452
6453 // Req
6454 var params *teststube2ap.RESTSubsReqParams = nil
6455 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6456
6457 // Del
6458 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6459
6460 // E2t: Receive 1st SubsDelReq
6461 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6462
6463 // Decode of this response fails which will result resending original request
6464 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6465
6466 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6467 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6468
6469 // Subscription does not exist in in E2 Node.
6470 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6471
6472 // Wait that subs is cleaned
6473 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6474
6475 xappConn1.TestMsgChanEmpty(t)
6476 e2termConn1.TestMsgChanEmpty(t)
6477 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006478 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006479}
6480
6481//-----------------------------------------------------------------------------
6482// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6483//
6484// stub stub
6485// +-------+ +---------+ +---------+
6486// | xapp | | submgr | | e2term |
6487// +-------+ +---------+ +---------+
6488// | | |
6489// | [SUBS CREATE] |
6490// | | |
6491// | | |
6492// | RESTSubDelReq | |
6493// |---------------->| |
6494// | | |
6495// | RESTSubDelResp | |
6496// |<----------------| |
6497// | | |
6498// | | SubDelReq |
6499// | |------------->|
6500// | | |
6501// | | SubDelResp | Unknown instanceId
6502// | |<-------------|
6503// | | |
6504// | | SubDelReq |
6505// | |------------->|
6506// | | |
6507// | | SubDelFail | Subscription does exist any more
6508// | |<-------------|
6509//
6510//-----------------------------------------------------------------------------
6511func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006512 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006513
6514 // Req
6515 var params *teststube2ap.RESTSubsReqParams = nil
6516 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6517
6518 // Del
6519 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6520
6521 // E2t: Receive 1st SubsDelReq
6522 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6523
6524 // Unknown instanceId in this response which will result resending original request
6525 delreq.RequestId.InstanceId = 0
6526 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6527
6528 // E2t: Receive 2nd SubsDelReq
6529 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6530
6531 // Subscription does not exist in in E2 Node.
6532 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6533
6534 // Wait that subs is cleaned
6535 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6536
6537 xappConn1.TestMsgChanEmpty(t)
6538 e2termConn1.TestMsgChanEmpty(t)
6539 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006540 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006541}
6542
6543//-----------------------------------------------------------------------------
6544// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6545//
6546// stub stub
6547// +-------+ +---------+ +---------+
6548// | xapp | | submgr | | e2term |
6549// +-------+ +---------+ +---------+
6550// | | |
6551// | [SUBS CREATE] |
6552// | | |
6553// | | |
6554// | RESTSubDelReq | |
6555// |---------------->| |
6556// | | |
6557// | RESTSubDelResp | |
6558// |<----------------| |
6559// | | |
6560// | | SubDelReq |
6561// | |------------->|
6562// | | |
6563// | | SubDelResp | No transaction for the response
6564// | |<-------------|
6565// | | |
6566// | | SubDelReq |
6567// | |------------->|
6568// | | |
6569// | | SubDelFail | Subscription does exist any more
6570// | |<-------------|
6571//
6572//-----------------------------------------------------------------------------
6573func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006574 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006575
6576 // Req
6577 var params *teststube2ap.RESTSubsReqParams = nil
6578 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6579
6580 // Del
6581 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6582
6583 // E2t: Receive 1st SubsDelReq
6584 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6585
6586 mainCtrl.MakeTransactionNil(t, e2SubsId)
6587
6588 // No transaction exist for this response which will result resending original request
6589 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6590
6591 // E2t: Receive 2nd SubsDelReq
6592 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6593
6594 // Subscription does not exist in in E2 Node.
6595 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6596
6597 // Wait that subs is cleaned
6598 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6599
6600 xappConn1.TestMsgChanEmpty(t)
6601 e2termConn1.TestMsgChanEmpty(t)
6602 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006603 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006604}
6605
6606//-----------------------------------------------------------------------------
6607// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6608//
6609// stub stub
6610// +-------+ +---------+ +---------+
6611// | xapp | | submgr | | e2term |
6612// +-------+ +---------+ +---------+
6613// | | |
6614// | [SUBS CREATE] |
6615// | | |
6616// | | |
6617// | RESTSubDelReq | |
6618// |---------------->| |
6619// | | |
6620// | RESTSubDelResp | |
6621// |<----------------| |
6622// | | |
6623// | | SubDelReq |
6624// | |------------->|
6625// | | |
6626// | | SubDelFail | ASN.1 decode fails
6627// | |<-------------|
6628// | | |
6629// | | SubDelReq |
6630// | |------------->|
6631// | | |
6632// | | SubDelFail | Subscription does exist any more
6633// | |<-------------|
6634//
6635//-----------------------------------------------------------------------------
6636func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006637 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006638
6639 // Req
6640 var params *teststube2ap.RESTSubsReqParams = nil
6641 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6642
6643 // Del
6644 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6645
6646 // E2t: Receive 1st SubsDelReq
6647 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6648
6649 // Decode of this response fails which will result resending original request
6650 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6651
6652 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6653 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6654
6655 // Subscription does not exist in in E2 Node.
6656 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6657
6658 // Wait that subs is cleaned
6659 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6660
6661 xappConn1.TestMsgChanEmpty(t)
6662 e2termConn1.TestMsgChanEmpty(t)
6663 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006664 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006665}
6666
6667//-----------------------------------------------------------------------------
6668// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6669//
6670// stub stub
6671// +-------+ +---------+ +---------+
6672// | xapp | | submgr | | e2term |
6673// +-------+ +---------+ +---------+
6674// | | |
6675// | [SUBS CREATE] |
6676// | | |
6677// | | |
6678// | RESTSubDelReq | |
6679// |---------------->| |
6680// | | |
6681// | RESTSubDelResp | |
6682// |<----------------| |
6683// | | |
6684// | | SubDelReq |
6685// | |------------->|
6686// | | |
6687// | | SubDelFail | Unknown instanceId
6688// | |<-------------|
6689// | | |
6690// | | SubDelReq |
6691// | |------------->|
6692// | | |
6693// | | SubDelFail | Subscription does exist any more
6694// | |<-------------|
6695//
6696//-----------------------------------------------------------------------------
6697func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006698 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006699
6700 // Req
6701 var params *teststube2ap.RESTSubsReqParams = nil
6702 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6703
6704 // Del
6705 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6706
6707 // E2t: Receive 1st SubsDelReq
6708 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6709
6710 // Unknown instanceId in this response which will result resending original request
6711 delreq.RequestId.InstanceId = 0
6712 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6713
6714 // E2t: Receive 2nd SubsDelReq
6715 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6716
6717 // Subscription does not exist in in E2 Node.
6718 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6719
6720 // Wait that subs is cleaned
6721 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6722
6723 xappConn1.TestMsgChanEmpty(t)
6724 e2termConn1.TestMsgChanEmpty(t)
6725 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006726 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006727}
6728
6729//-----------------------------------------------------------------------------
6730// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6731//
6732// stub stub
6733// +-------+ +---------+ +---------+
6734// | xapp | | submgr | | e2term |
6735// +-------+ +---------+ +---------+
6736// | | |
6737// | [SUBS CREATE] |
6738// | | |
6739// | | |
6740// | RESTSubDelReq | |
6741// |---------------->| |
6742// | | |
6743// | RESTSubDelResp | |
6744// |<----------------| |
6745// | | |
6746// | | SubDelReq |
6747// | |------------->|
6748// | | |
6749// | | SubDelFail | No transaction for the response
6750// | |<-------------|
6751// | | |
6752// | | SubDelReq |
6753// | |------------->|
6754// | | |
6755// | | SubDelFail | Subscription does exist any more
6756// | |<-------------|
6757//
6758//-----------------------------------------------------------------------------
6759func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006760 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006761
6762 // Req
6763 var params *teststube2ap.RESTSubsReqParams = nil
6764 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6765
6766 // Del
6767 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6768
6769 // E2t: Receive 1st SubsDelReq
6770 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6771
6772 mainCtrl.MakeTransactionNil(t, e2SubsId)
6773
6774 // No transaction exist for this response which will result resending original request
6775 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6776
6777 // E2t: Receive 2nd SubsDelReq
6778 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6779
6780 // Subscription does not exist in in E2 Node.
6781 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6782
6783 // Wait that subs is cleaned
6784 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6785
6786 xappConn1.TestMsgChanEmpty(t)
6787 e2termConn1.TestMsgChanEmpty(t)
6788 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006789 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006790}
6791
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006792//-----------------------------------------------------------------------------
6793// TestRESTSubReqFailAsn1PackSubReqError
6794//
6795// stub stub
6796// +-------+ +---------+ +---------+
6797// | xapp | | submgr | | e2term |
6798// +-------+ +---------+ +---------+
6799// | | |
6800// | RESTSubReq | |
6801// |---------------->| |
6802// | | |
6803// | RESTSubResp | |
6804// |<----------------| |
6805// | | |
6806// | ASN.1 encode fails |
6807// | | |
6808// | | SubDelReq |
6809// | |------------->|
6810// | | |
6811// | | SubDelFail |
6812// | |<-------------|
6813// | | |
6814// | RESTNotif | |
6815// | unsuccess | |
6816// |<----------------| |
6817// | | |
6818// | [SUBS DELETE] |
6819// | | |
6820//
6821//-----------------------------------------------------------------------------
6822func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6823
6824 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006825 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006826 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006827 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006828 Counter{cRestSubDelReqFromXapp, 1},
6829 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006830 })
6831
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006832 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006833
6834 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006835 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006836 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6837
6838 // Req
6839 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006840 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006841
6842 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006843 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006844
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006845 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006846 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006847
6848 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006849
6850 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6851
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006852 // Wait that subs is cleaned
6853 waitSubsCleanup(t, e2SubsId, 10)
6854 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006855 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006856}
6857
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006858func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6859 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6860
6861 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6862 Counter{cRestSubReqFromXapp, 2},
6863 Counter{cRestSubRespToXapp, 2},
6864 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006865 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006866 Counter{cSubRespFromE2, 1},
6867 Counter{cRestSubNotifToXapp, 1},
6868 Counter{cRestSubFailNotifToXapp, 1},
6869 Counter{cRestSubDelReqFromXapp, 1},
6870 Counter{cSubDelReqToE2, 1},
6871 Counter{cSubDelRespFromE2, 1},
6872 Counter{cRestSubDelRespToXapp, 1},
6873 })
6874
6875 const e2Timeout int64 = 1
6876 const e2RetryCount int64 = 0
6877 const routingNeeded bool = false
6878
6879 // Req1
6880 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6881 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6882
6883 // Subs Create
6884 restSubId := xappConn1.SendRESTSubsReq(t, params)
6885 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6886
6887 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6888 xappConn1.ExpectRESTNotification(t, restSubId)
6889 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6890 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6891 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6892
6893 // Policy change
6894 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6895 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6896 params.SetSubscriptionID(&restSubId)
6897 params.SetTimeToWait("w200ms")
6898 restSubId = xappConn1.SendRESTSubsReq(t, params)
6899 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6900
6901 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6902 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006903 // SubsResp is missing, e2SubsId will be 0
6904 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6905 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006906
6907 // Del
6908 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6909 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6910 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6911
6912 waitSubsCleanup(t, e2SubsId, 10)
6913
6914 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006915 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006916}
6917
6918//-----------------------------------------------------------------------------
6919// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6920//
6921// stub stub
6922// +-------+ +---------+ +---------+
6923// | xapp | | submgr | | e2term |
6924// +-------+ +---------+ +---------+
6925// | | |
6926// | RESTSubReq | |
6927// |---------------->| |
6928// | | |
6929// | RESTSubResp | |
6930// |<----------------| |
6931// | | SubReq |
6932// | |------------->|
6933// | | |
6934// | | SubResp |
6935// | |<-------------|
6936// | | |
6937// | RESTNotif | |
6938// |<----------------| |
6939// | | |
6940// | RESTSubReq | |
6941// |---------------->| |
6942// | | |
6943// | RESTSubResp | |
6944// |<----------------| |
6945// | | SubReq |
6946// | |------------->|
6947// | |
6948// | Submgr restart |
6949// | | |
6950// | RESTSubDelReq | |
6951// |---------------->| |
6952// | | |
6953// | | SubDelReq |
6954// | |------------->|
6955// | | |
6956// | | SubDelResp |
6957// | |<-------------|
6958// | | |
6959// | RESTSubDelResp | |
6960// |<----------------| |
6961//
6962//-----------------------------------------------------------------------------
6963
6964func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6965 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6966
6967 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6968 Counter{cRestSubReqFromXapp, 2},
6969 Counter{cRestSubRespToXapp, 2},
6970 Counter{cSubReqToE2, 2},
6971 Counter{cSubRespFromE2, 1},
6972 Counter{cRestSubNotifToXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006973 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006974 Counter{cRestSubDelReqFromXapp, 1},
6975 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006976 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006977 Counter{cRestSubDelRespToXapp, 1},
6978 })
6979
6980 // Remove possible existing subscription
6981 mainCtrl.removeExistingSubscriptions(t)
6982
6983 const e2Timeout int64 = 1
6984 const e2RetryCount int64 = 0
6985 const routingNeeded bool = false
6986
6987 // Req1
6988 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6989 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6990 // Create subscription
6991 restSubId := xappConn1.SendRESTSubsReq(t, params)
6992 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6993
6994 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6995 xappConn1.ExpectRESTNotification(t, restSubId)
6996 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6997 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6998 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6999
7000 // Check subscription
7001 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7002
7003 // Policy change
7004 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7005 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7006 params.SetSubscriptionID(&restSubId)
7007 params.SetTimeToWait("w200ms")
7008 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7009 restSubId = xappConn1.SendRESTSubsReq(t, params)
7010 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7011
7012 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7013 mainCtrl.SetResetTestFlag(t, false)
7014
7015 // SubsResp is missing due to submgr restart
7016
7017 mainCtrl.SimulateRestart(t)
7018 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7019
7020 // Check subscription
7021 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7022
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007023 // Delete subscription
7024 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7025 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7026 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7027
7028 //Wait that subs is cleaned
7029 waitSubsCleanup(t, e2SubsId, 10)
7030
7031 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007032 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007033}
7034
archaggeafbf95f2021-04-14 08:54:05 +03007035////////////////////////////////////////////////////////////////////////////////////
7036// Services for UT cases
7037////////////////////////////////////////////////////////////////////////////////////
7038const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007039const host string = "localhost"
7040
7041func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7042 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007043 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007044 }
7045 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007046 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007047
7048 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7049 fromXappConn.ExpectRESTNotification(t, restSubId)
7050 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7051 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007052 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007053
7054 return restSubId, e2SubsId
7055}
7056
7057func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7058
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007059 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007060 if meid != "" {
7061 params.SetMeid(meid)
7062 }
7063 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7064 restSubId := xappConn2.SendRESTSubsReq(t, params)
7065 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007066 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007067 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007068 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007069
7070 return restSubId, e2SubsId
7071}
7072
7073func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007074
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007075 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007076 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007077 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007078
7079 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7080 xappConn1.ExpectRESTNotification(t, restSubId)
7081 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7082 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007083 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007084
7085 return restSubId, e2SubsId
7086}
7087
7088func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007089 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007090 restSubId := xappConn1.SendRESTSubsReq(t, params)
7091
7092 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7093 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7094 fparams1.Set(crereq1)
7095 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7096
7097 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7098 xappConn1.ExpectRESTNotification(t, restSubId)
7099 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7100 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007101 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007102
7103 return restSubId, e2SubsId
7104}
7105
7106func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7107 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7108 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7109 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7110}
7111
7112func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7113 xappConn1.SendRESTSubsDelReq(t, restSubId)
7114 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7115 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7116}
7117
7118func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7119 xappConn2.SendRESTSubsDelReq(t, restSubId)
7120 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7121 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7122}
7123
7124func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7125 resp, _ := xapp.Subscription.QuerySubscriptions()
7126 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
7127 assert.Equal(t, resp[0].Meid, meid)
7128 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
7129}
7130
7131func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7132 //Wait that subs is cleaned
7133 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7134
7135 xappConn1.TestMsgChanEmpty(t)
7136 xappConn2.TestMsgChanEmpty(t)
7137 e2termConn1.TestMsgChanEmpty(t)
7138 mainCtrl.wait_registry_empty(t, timeout)
7139}
7140
7141func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7142
7143 var e2SubsId []uint32
7144
7145 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007146 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007147 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7148 fromXappConn.ExpectRESTNotification(t, restSubId)
7149 toE2termConn.SendSubsResp(t, crereq, cremsg)
7150 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7151 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007152 xapp.Logger.Debug("TEST: %v", e2SubsId)
7153 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007154 <-time.After(100 * time.Millisecond)
7155 }
7156 return e2SubsId
7157}
7158
7159func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7160
7161 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007162 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007163 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7164 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7165 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007166 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007167 <-time.After(100 * time.Millisecond)
7168 }
7169
7170 // Wait that subs is cleaned
7171 for i := 0; i < len(e2SubsIds); i++ {
7172 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7173 }
7174
7175}