blob: 7d7f67bce947df9a87815b681b9d0ce2a37ce9dc [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030023 //"os"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000024 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020025 "testing"
26 "time"
27
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030030 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020031 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020032 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020034)
35
Markku Virtanenac8bde42021-05-25 09:54:42 +000036func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030037 // The effect of this call shall endure though the UT suite!
38 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000039 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000040 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
41
Anssi Mannila3d80b722021-11-12 13:17:15 +020042 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000043 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030044 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000045
Markku Virtanenac8bde42021-05-25 09:54:42 +000046}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030047func TestRanStatusChangeViaSDLNotification(t *testing.T) {
48
49 // Current UT test cases use these ran names
50 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
51 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
52 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
53
54 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
55 mainCtrl.c.e2IfState.SubscribeChannels()
56
57 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
58 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
59 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
60}
61
62//-----------------------------------------------------------------------------
63// TestRESTSubReqAfterE2ConnBreak
64//
65// stub stub
66// +-------+ +---------+ +---------+
67// | xapp | | submgr | | e2term |
68// +-------+ +---------+ +---------+
69// | | |
70// | [E2 Conn. DOWN] |
71// | | |
72// | RESTSubReq | |
73// |---------------->| |
74// | RESTSubFail | |
75// |<----------------| |
76// | | |
77//
78//-----------------------------------------------------------------------------
79
80func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
81 CaseBegin("TestRESTSubReqAfterE2ConnBreak")
82
83 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
84 Counter{cRestSubReqFromXapp, 1},
85 Counter{cRestReqRejDueE2Down, 1},
86 })
87
88 // E2 disconnect after E2term has received response
89 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
90 // Req
91 const subReqCount int = 1
92 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
93 xappConn1.SendRESTSubsReq(t, params)
94
95 // Restore E2 connection for following test cases
96 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
97
98 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +020099 mainCtrl.VerifyAllClean(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +0200100 //os.Exit(0)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300101}
102
103//-----------------------------------------------------------------------------
104// TestRESTSubReqE2ConnBreak
105//
106// stub stub
107// +-------+ +---------+ +---------+
108// | xapp | | submgr | | e2term |
109// +-------+ +---------+ +---------+
110// | | |
111// | RESTSubReq | |
112// |---------------->| |
113// | RESTSubResp | |
114// |<----------------| |
115// | | SubReq |
116// | |------------->|
117// | | SubResp |
118// | |<-------------|
119// | | |
120// | [E2 Conn. DOWN] |
121// | [Int. SUBS DELETE] |
122// | | |
123// | RESTNotif(unsuccessful) |
124// |<----------------| |
125// | | |
126// | | |
127//
128//-----------------------------------------------------------------------------
129func TestRESTSubReqE2ConnBreak(t *testing.T) {
130 CaseBegin("TestRESTSubReqE2ConnBreak")
131
132 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
133 Counter{cRestSubReqFromXapp, 1},
134 Counter{cRestSubRespToXapp, 1},
135 Counter{cSubReqToE2, 1},
136 Counter{cSubRespFromE2, 1},
137 Counter{cRestSubFailNotifToXapp, 1},
138 })
139
140 // Req
141 const subReqCount int = 1
142 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
143 restSubId := xappConn1.SendRESTSubsReq(t, params)
144
145 crereq, cremsg := e2termConn1.RecvSubsReq(t)
146 xappConn1.ExpectRESTNotification(t, restSubId)
147
148 // E2 disconnect after E2term has received response
149 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
150
151 e2termConn1.SendSubsResp(t, crereq, cremsg)
152 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
153
154 <-time.After(time.Second * 1)
155 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
156 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
157
158 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
159 if err != nil {
160 xapp.Logger.Error("%v", err)
161 } else {
162 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
163 assert.Equal(t, 0, len(register))
164 }
165
166 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
167 if err != nil {
168 xapp.Logger.Error("%v", err)
169 } else {
170 assert.Equal(t, 0, len(restSubscriptions))
171 }
172
173 // Restore E2 connection for following test cases
174 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
175
176 // Wait that subs is cleaned
177 waitSubsCleanup(t, e2SubsId, 10)
178 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200179 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300180}
181
182//-----------------------------------------------------------------------------
183// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
184//
185// stub stub
186// +-------+ +---------+ +---------+
187// | xapp | | submgr | | e2term |
188// +-------+ +---------+ +---------+
189// | | |
190// | [SUBS CREATE] |
191// | | |
192// | [E2 Conn. DOWN] |
193// | | |
194// | RESTSubDelReq | |
195// |---------------->| |
196// | | |
197// | RESTSubDelResp | |
198// |<----------------| |
199// | | |
200// | [No valid subscription found] |
201// | | |
202//
203//-----------------------------------------------------------------------------
204func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
205 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
206
207 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
208 Counter{cRestSubReqFromXapp, 1},
209 Counter{cRestSubRespToXapp, 1},
210 Counter{cSubReqToE2, 1},
211 Counter{cSubRespFromE2, 1},
212 Counter{cRestSubNotifToXapp, 1},
213 Counter{cRestSubDelReqFromXapp, 1},
214 Counter{cRestSubDelRespToXapp, 1},
215 })
216
217 // Req
218 var params *teststube2ap.RESTSubsReqParams = nil
219 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
220
221 // E2 disconnect after E2term has received response
222 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
223
224 // Del
225 xappConn1.SendRESTSubsDelReq(t, &restSubId)
226
227 <-time.After(time.Second * 1)
228 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
229 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
230
231 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
232 if err != nil {
233 xapp.Logger.Error("%v", err)
234 } else {
235 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
236 assert.Equal(t, 0, len(register))
237 }
238
239 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
240 if err != nil {
241 xapp.Logger.Error("%v", err)
242 } else {
243 assert.Equal(t, 0, len(restSubscriptions))
244 }
245
246 // Restore E2 connection for following test cases
247 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
248
249 // Wait that subs is cleaned
250 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
251
252 xappConn1.TestMsgChanEmpty(t)
253 e2termConn1.TestMsgChanEmpty(t)
254 mainCtrl.wait_registry_empty(t, 10)
255 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200256 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300257}
258
259//-----------------------------------------------------------------------------
260// TestRESTOtherE2ConnectionChanges
261//
262
263// stub stub
264// +-------+ +---------+ +---------+
265// | xapp | | submgr | | e2term |
266// +-------+ +---------+ +---------+
267// | | |
268// | [SUBS CREATE] |
269// | | |
270// | [E2 CONNECTED_SETUP_FAILED] |
271// | [E2 CONNECTING] |
272// | [E2 SHUTTING_DOWN] |
273// | [E2 SHUT_DOWN] |
274// | | |
275// | [SUBS DELETE] |
276// | | |
277//
278//-----------------------------------------------------------------------------
279func TestRESTOtherE2ConnectionChanges(t *testing.T) {
280 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
281
282 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
283 Counter{cRestSubReqFromXapp, 1},
284 Counter{cRestSubRespToXapp, 1},
285 Counter{cSubReqToE2, 1},
286 Counter{cSubRespFromE2, 1},
287 Counter{cRestSubNotifToXapp, 1},
288 Counter{cRestSubDelReqFromXapp, 1},
289 Counter{cSubDelReqToE2, 1},
290 Counter{cSubDelRespFromE2, 1},
291 Counter{cRestSubDelRespToXapp, 1},
292 })
293
294 // Req
295 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
296 restSubId := xappConn1.SendRESTSubsReq(t, params)
297
298 crereq, cremsg := e2termConn1.RecvSubsReq(t)
299 xappConn1.ExpectRESTNotification(t, restSubId)
300 e2termConn1.SendSubsResp(t, crereq, cremsg)
301 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
302
303 // Submgr should not react any other connection state changes than CONNECTED and DISCONNECTED
304 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
305 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
306 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
307 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
308
309 // Del
310 xappConn1.SendRESTSubsDelReq(t, &restSubId)
311 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
312 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
313
314 // Restore E2 connection for following test cases
315 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
316
317 // Wait that subs is cleaned
318 waitSubsCleanup(t, e2SubsId, 10)
319 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200320 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300321}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000322
323//-----------------------------------------------------------------------------
324// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
325//
326// stub stub stub
327// +-------+ +---------+ +---------+ +---------+
328// | xapp | | submgr | | e2term | | rtmgr |
329// +-------+ +---------+ +---------+ +---------+
330// | | | |
331// | RESTSubReq | | |
332// |---------------->| | |
333// | | RouteCreate | |
334// | |--------------------------->| // The order of these events may vary
335// | | | |
336// | RESTSubResp | | | // The order of these events may vary
337// |<----------------| | |
338// | | RouteResponse| |
339// | |<---------------------------| // The order of these events may vary
340// | | | |
341// | | SubReq | |
342// | |------------->| | // The order of these events may vary
343// | | | |
344// | | SubResp | |
345// | |<-------------| |
346// | RESTNotif1 | | |
347// |<----------------| | |
348// | | | |
349// | RESTSubDelReq | | |
350// |---------------->| | |
351// | | SubDelReq | |
352// | |------------->| |
353// | | | |
354// | RESTSubDelResp| | |
355// |<----------------| | |
356// | | | |
357// | | SubDelResp | |
358// | |<-------------| |
359// | | | |
360// | | | |
361//
362//-----------------------------------------------------------------------------
363func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000364
365 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
366
367 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
368
369 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200370 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000371}
372
Juha Hyttinenfa015662020-01-24 10:05:18 +0200373//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000374// TestRESTSubReqAndE1apDeleteReqPackingError
375//
376// stub stub stub
377// +-------+ +---------+ +---------+ +---------+
378// | xapp | | submgr | | e2term | | rtmgr |
379// +-------+ +---------+ +---------+ +---------+
380// | | | |
381// | RESTSubReq | | |
382// |---------------->| | |
383// | | RouteCreate | |
384// | |--------------------------->| // The order of these events may vary
385// | | | |
386// | RESTSubResp | | | // The order of these events may vary
387// |<----------------| | |
388// | | RouteResponse| |
389// | |<---------------------------| // The order of these events may vary
390// | | | |
391// | | SubReq | |
392// | |------------->| | // The order of these events may vary
393// | | | |
394// | | SubResp | |
395// | |<-------------| |
396// | RESTNotif1 | | |
397// |<----------------| | |
398// | | | |
399// | RESTSubDelReq | | |
400// |---------------->| | |
401// | | | |
402// | RESTSubDelResp| | |
403// |<----------------| | |
404// | | | |
405// | | | |
406//
407//-----------------------------------------------------------------------------
408func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
409
410 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
411
412 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
413 xappConn1.SendRESTSubsDelReq(t, &restSubId)
414 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
415
416 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200417 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000418}
419
420//-----------------------------------------------------------------------------
421// TestRESTSubReqAndE1apDeleteRespUnpackingError
422//
423// stub stub stub
424// +-------+ +---------+ +---------+ +---------+
425// | xapp | | submgr | | e2term | | rtmgr |
426// +-------+ +---------+ +---------+ +---------+
427// | | | |
428// | RESTSubReq | | |
429// |---------------->| | |
430// | | RouteCreate | |
431// | |--------------------------->| // The order of these events may vary
432// | | | |
433// | RESTSubResp | | | // The order of these events may vary
434// |<----------------| | |
435// | | RouteResponse| |
436// | |<---------------------------| // The order of these events may vary
437// | | | |
438// | | SubReq | |
439// | |------------->| | // The order of these events may vary
440// | | | |
441// | | SubResp | |
442// | |<-------------| |
443// | RESTNotif1 | | |
444// |<----------------| | |
445// | | | |
446// | RESTSubDelReq | | |
447// |---------------->| | |
448// | | SubDelReq | |
449// | |------------->| |
450// | | | |
451// | RESTSubDelResp| | |
452// |<----------------| | | // The order of these events may vary
453// | | | |
454// | | SubDelResp | |
455// | |<-------------| | // 1.st NOK
456// | | | |
457// | | SubDelReq | |
458// | |------------->| |
459// | | | |
460// | | SubDelResp | |
461// | |<-------------| | // 2.nd NOK
462//
463//-----------------------------------------------------------------------------
464
465func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
466
467 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
468
469 xappConn1.SendRESTSubsDelReq(t, &restSubId)
470 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
471 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
472 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
473
474 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
475 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
476
477 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
478
479 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200480 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000481}
482
483//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200484// TestSubReqAndRouteNok
485//
486// stub stub
487// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200488// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200489// +-------+ +---------+ +---------+
490// | | |
491// | SubReq | |
492// |------------->| |
493// | | |
494// | | RouteCreate |
495// | |------------->|
496// | | |
497// | | RouteCreate |
498// | | status:400 |
499// | |<-------------|
500// | | |
501// | [SUBS INT DELETE] |
502// | | |
503//
504//-----------------------------------------------------------------------------
505
506func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200507 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200508
Anssi Mannila4abf1802021-01-28 13:06:46 +0200509 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200510 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
511 Counter{cSubReqFromXapp, 1},
512 Counter{cRouteCreateFail, 1},
513 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200514
Juha Hyttinenfa015662020-01-24 10:05:18 +0200515 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300516 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200517 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200518 waiter.WaitResult(t)
519
520 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200521 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200522
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200523 xappConn1.TestMsgChanEmpty(t)
524 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200525 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200526 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200527
528 <-time.After(1 * time.Second)
529 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200530}
531
532//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200533// TestSubReqAndRouteUpdateNok
534
535// stub stub
536// +-------+ +-------+ +---------+ +---------+
537// | xapp2 | | xapp1 | | submgr | | rtmgr |
538// +-------+ +-------+ +---------+ +---------+
539// | | | |
540// | [SUBS CREATE] | |
541// | | | |
542// | | | |
543// | | | |
544// | SubReq (mergeable) | |
545// |--------------------------->| | |
546// | | | |
547// | | | RouteUpdate |
548// | | |------------->|
549// | | | |
550// | | | RouteUpdate |
551// | | | status:400 |
552// | | |<-------------|
553// | | | |
554// | [SUBS INT DELETE] | |
555// | | | |
556// | | | |
557// | [SUBS DELETE] | |
558// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300559
Anssi Mannila4abf1802021-01-28 13:06:46 +0200560func TestSubReqAndRouteUpdateNok(t *testing.T) {
561 CaseBegin("TestSubReqAndRouteUpdateNok")
562
563 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200564 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
565 Counter{cSubReqFromXapp, 2},
566 Counter{cSubReqToE2, 1},
567 Counter{cSubRespFromE2, 1},
568 Counter{cSubRespToXapp, 1},
569 Counter{cRouteCreateUpdateFail, 1},
570 Counter{cSubDelReqFromXapp, 1},
571 Counter{cSubDelReqToE2, 1},
572 Counter{cSubDelRespFromE2, 1},
573 Counter{cSubDelRespToXapp, 1},
574 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200575
576 cretrans := xappConn1.SendSubsReq(t, nil, nil)
577 crereq, cremsg := e2termConn1.RecvSubsReq(t)
578 e2termConn1.SendSubsResp(t, crereq, cremsg)
579 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
580
581 resp, _ := xapp.Subscription.QuerySubscriptions()
582 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
583 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300584 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200585
586 waiter := rtmgrHttp.AllocNextEvent(false)
587 newSubsId := mainCtrl.get_registry_next_subid(t)
588 xappConn2.SendSubsReq(t, nil, nil)
589 waiter.WaitResult(t)
590
591 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
592 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
593
594 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
595 xappConn1.RecvSubsDelResp(t, deltrans)
596
597 //Wait that subs is cleaned
598 mainCtrl.wait_subs_clean(t, newSubsId, 10)
599 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
600
601 xappConn1.TestMsgChanEmpty(t)
602 xappConn2.TestMsgChanEmpty(t)
603 e2termConn1.TestMsgChanEmpty(t)
604 mainCtrl.wait_registry_empty(t, 10)
605
606 mainCtrl.VerifyCounterValues(t)
607}
608
609//-----------------------------------------------------------------------------
610// TestSubDelReqAndRouteDeleteNok
611//
612// stub stub
613// +-------+ +---------+ +---------+ +---------+
614// | xapp | | submgr | | e2term | | rtmgr |
615// +-------+ +---------+ +---------+ +---------+
616// | | | |
617// | [SUBS CREATE] | |
618// | | | |
619// | | | |
620// | | | |
621// | SubDelReq | | |
622// |------------->| | |
623// | | SubDelReq | |
624// | |------------->| |
625// | | SubDelRsp | |
626// | |<-------------| |
627// | SubDelRsp | | |
628// |<-------------| | |
629// | | RouteDelete | |
630// | |---------------------------->|
631// | | | |
632// | | RouteDelete | |
633// | | status:400 | |
634// | |<----------------------------|
635// | | | |
636func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
637 CaseBegin("TestSubDelReqAndRouteDeleteNok")
638
639 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200640 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
641 Counter{cSubReqFromXapp, 1},
642 Counter{cSubReqToE2, 1},
643 Counter{cSubRespFromE2, 1},
644 Counter{cSubRespToXapp, 1},
645 Counter{cSubDelReqFromXapp, 1},
646 Counter{cRouteDeleteFail, 1},
647 Counter{cSubDelReqToE2, 1},
648 Counter{cSubDelRespFromE2, 1},
649 Counter{cSubDelRespToXapp, 1},
650 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200651
652 cretrans := xappConn1.SendSubsReq(t, nil, nil)
653 crereq, cremsg := e2termConn1.RecvSubsReq(t)
654 e2termConn1.SendSubsResp(t, crereq, cremsg)
655 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
656
657 resp, _ := xapp.Subscription.QuerySubscriptions()
658 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
659 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300660 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200661
662 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
663 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
664
665 waiter := rtmgrHttp.AllocNextEvent(false)
666 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
667 waiter.WaitResult(t)
668
669 xappConn1.RecvSubsDelResp(t, deltrans)
670
671 //Wait that subs is cleaned
672 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
673
674 xappConn1.TestMsgChanEmpty(t)
675 xappConn2.TestMsgChanEmpty(t)
676 e2termConn1.TestMsgChanEmpty(t)
677 mainCtrl.wait_registry_empty(t, 10)
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
Anssi Mannilac92b4212020-12-07 14:59:34 +02002378 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2379 xappConn1.SendSubsReq(t, nil, nil)
2380 e2termConn1.RecvSubsReq(t)
2381 mainCtrl.SetResetTestFlag(t, false)
2382
2383 resp, _ := xapp.Subscription.QuerySubscriptions()
2384 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002385 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002386 e2SubsId := uint32(resp[0].SubscriptionID)
2387 t.Logf("e2SubsId = %v", e2SubsId)
2388
archaggeafbf95f2021-04-14 08:54:05 +03002389 mainCtrl.SimulateRestart(t)
2390 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002391
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002392 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002393 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2394 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2395
2396 // Wait that subs is cleaned
2397 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2398
2399 xappConn1.TestMsgChanEmpty(t)
2400 xappConn2.TestMsgChanEmpty(t)
2401 e2termConn1.TestMsgChanEmpty(t)
2402 mainCtrl.wait_registry_empty(t, 10)
2403}
2404
2405//-----------------------------------------------------------------------------
2406// TestSubReqAndSubDelOkWithRestartInMiddle
2407//
2408// stub stub
2409// +-------+ +---------+ +---------+
2410// | xapp | | submgr | | e2term |
2411// +-------+ +---------+ +---------+
2412// | | |
2413// | SubReq | |
2414// |------------->| |
2415// | | |
2416// | | SubReq |
2417// | |------------->|
2418// | | |
2419// | | SubResp |
2420// | |<-------------|
2421// | | |
2422// | SubResp | |
2423// |<-------------| |
2424// | | |
2425// | |
2426// | Submgr restart |
2427// | |
2428// | SubDelReq | |
2429// |------------->| |
2430// | | |
2431// | | SubDelReq |
2432// | |------------->|
2433// | | |
2434// | | SubDelResp |
2435// | |<-------------|
2436// | | |
2437// | SubDelResp | |
2438// |<-------------| |
2439//
2440//-----------------------------------------------------------------------------
2441
2442func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2443 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2444
2445 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2446 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2447 e2termConn1.SendSubsResp(t, crereq, cremsg)
2448 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2449
2450 // Check subscription
2451 resp, _ := xapp.Subscription.QuerySubscriptions()
2452 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2453 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002454 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002455
2456 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002457 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002458
Anssi Mannila54838ed2021-11-19 11:25:01 +02002459 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2460 // That needs to be completed before successful subscription query is possible
2461 <-time.After(time.Second * 1)
2462
Anssi Mannilac92b4212020-12-07 14:59:34 +02002463 // Check that subscription is restored correctly after restart
2464 resp, _ = xapp.Subscription.QuerySubscriptions()
2465 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2466 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002467 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002468
2469 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2470 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2471 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2472 xappConn1.RecvSubsDelResp(t, deltrans)
2473
2474 //Wait that subs is cleaned
2475 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2476
2477 xappConn1.TestMsgChanEmpty(t)
2478 xappConn2.TestMsgChanEmpty(t)
2479 e2termConn1.TestMsgChanEmpty(t)
2480 mainCtrl.wait_registry_empty(t, 10)
2481}
2482
2483//-----------------------------------------------------------------------------
2484// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2485//
2486// stub stub
2487// +-------+ +-------+ +---------+ +---------+
2488// | xapp2 | | xapp1 | | submgr | | e2term |
2489// +-------+ +-------+ +---------+ +---------+
2490// | | | |
2491// | | | |
2492// | | | |
2493// | | SubReq1 | |
2494// | |------------->| |
2495// | | | |
2496// | | | SubReq1 |
2497// | | |------------->|
2498// | | | SubResp1 |
2499// | | |<-------------|
2500// | | SubResp1 | |
2501// | |<-------------| |
2502// | | | |
2503// | |
2504// | submgr restart |
2505// | |
2506// | | | |
2507// | | | |
2508// | SubReq2 | |
2509// |--------------------------->| |
2510// | | | |
2511// | SubResp2 | |
2512// |<---------------------------| |
2513// | | | |
2514// | | SubDelReq 1 | |
2515// | |------------->| |
2516// | | | |
2517// | | SubDelResp 1 | |
2518// | |<-------------| |
2519// | | | |
2520// | | | |
2521// | |
2522// | submgr restart |
2523// | |
2524// | | | |
2525// | SubDelReq 2 | |
2526// |--------------------------->| |
2527// | | | |
2528// | | | SubDelReq 2 |
2529// | | |------------->|
2530// | | | |
2531// | | | SubDelReq 2 |
2532// | | |------------->|
2533// | | | |
2534// | SubDelResp 2 | |
2535// |<---------------------------| |
2536//
2537//-----------------------------------------------------------------------------
2538
2539func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2540 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2541
2542 //Req1
2543 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2544 rparams1.Init()
2545 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2546 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2547 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2548 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2549
2550 //Req2
2551 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2552 rparams2.Init()
2553 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2554 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2555
2556 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002557 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002558 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2559 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002560 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002561
2562 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002563 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002564
Anssi Mannila54838ed2021-11-19 11:25:01 +02002565 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2566 // That needs to be completed before successful subscription query is possible
2567 <-time.After(time.Second * 1)
2568
Anssi Mannilac92b4212020-12-07 14:59:34 +02002569 // Check that subscription is restored correctly after restart
2570 resp, _ = xapp.Subscription.QuerySubscriptions()
2571 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2572 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002573 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002574
2575 //Del1
2576 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2577 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2578 xappConn1.RecvSubsDelResp(t, deltrans1)
2579 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2580
2581 mainCtrl.SimulateRestart(t)
2582 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2583
Anssi Mannila54838ed2021-11-19 11:25:01 +02002584 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2585 // Submgr need be ready before successful subscription deletion is possible
2586 <-time.After(time.Second * 1)
2587
Anssi Mannilac92b4212020-12-07 14:59:34 +02002588 //Del2
2589 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2590 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2591
2592 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2593 xappConn2.RecvSubsDelResp(t, deltrans2)
2594
2595 //Wait that subs is cleaned
2596 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2597
2598 xappConn1.TestMsgChanEmpty(t)
2599 xappConn2.TestMsgChanEmpty(t)
2600 e2termConn1.TestMsgChanEmpty(t)
2601 mainCtrl.wait_registry_empty(t, 10)
2602}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002603
archaggeafbf95f2021-04-14 08:54:05 +03002604//*****************************************************************************
2605// REST interface test cases
2606//*****************************************************************************
2607
Anssi Mannila47518ae2021-04-16 09:27:07 +03002608//-----------------------------------------------------------------------------
2609// Test debug GET and POST requests
2610//
2611// curl
2612// +-------+ +---------+
2613// | user | | submgr |
2614// +-------+ +---------+
2615// | |
2616// | GET/POST Req |
2617// |------------->|
2618// | Resp |
2619// |<-------------|
2620// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002621func TestGetSubscriptions(t *testing.T) {
2622
2623 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2624}
2625
2626func TestGetSymptomData(t *testing.T) {
2627
2628 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2629}
2630
2631func TestPostdeleteSubId(t *testing.T) {
2632
2633 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2634}
2635
2636func TestPostEmptyDb(t *testing.T) {
2637
2638 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2639}
archaggeafbf95f2021-04-14 08:54:05 +03002640
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002641func TestGetRestSubscriptions(t *testing.T) {
2642
2643 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2644}
2645
archaggeafbf95f2021-04-14 08:54:05 +03002646//-----------------------------------------------------------------------------
2647// TestRESTSubReqAndRouteNok
2648//
2649// stub stub
2650// +-------+ +---------+ +---------+
2651// | xapp | | submgr | | rtmgr |
2652// +-------+ +---------+ +---------+
2653// | | |
2654// | RESTSubReq | |
2655// |---------------->| |
2656// | | |
2657// | RESTSubResp | |
2658// |<----------------| |
2659// | | RouteCreate |
2660// | |------------->|
2661// | | |
2662// | | RouteCreate |
2663// | | status:400 |
2664// | |(Bad request) |
2665// | |<-------------|
2666// | RESTNotif | |
2667// |<----------------| |
2668// | | |
2669// | [SUBS INT DELETE] |
2670// | | |
2671// | RESTSubDelReq | |
2672// |---------------->| |
2673// | RESTSubDelResp | |
2674// |<----------------| |
2675//
2676//-----------------------------------------------------------------------------
2677func TestRESTSubReqAndRouteNok(t *testing.T) {
2678 CaseBegin("TestRESTSubReqAndRouteNok")
2679
2680 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002681 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002682 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002683 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002684 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002685 Counter{cRestSubDelReqFromXapp, 1},
2686 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002687 })
2688
2689 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002690
Markku Virtanenda34eec2021-05-20 08:22:04 +00002691 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2692 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002693 newSubsId := mainCtrl.get_registry_next_subid(t)
2694
2695 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002696 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002697 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002698 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002699 waiter.WaitResult(t)
2700
archaggeafbf95f2021-04-14 08:54:05 +03002701 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002702 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002703
2704 // Del
2705 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2706
2707 // Wait that subs is cleaned
2708 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2709 waitSubsCleanup(t, e2SubsId, 10)
2710 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002711 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002712}
2713
2714func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2715 CaseBegin("TestSubReqAndRouteUpdateNok")
2716
2717 //Init counter check
2718 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002719 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002720 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002721 Counter{cSubReqToE2, 1},
2722 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002723 Counter{cRestSubNotifToXapp, 1},
2724 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002725 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002726 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002727 Counter{cSubDelReqToE2, 1},
2728 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02002729 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002730 })
2731
2732 var params *teststube2ap.RESTSubsReqParams = nil
2733
2734 //Subs Create
2735 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2736
2737 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2738
2739 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2740 waiter := rtmgrHttp.AllocNextEvent(false)
2741 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002742 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002743 params.SetMeid("RAN_NAME_1")
2744 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002745 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002746 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002747 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03002748 xappConn2.WaitRESTNotification(t, restSubId2)
2749
2750 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2751
2752 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002753 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03002754
2755 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2756 //Wait that subs is cleaned
2757 waitSubsCleanup(t, e2SubsId, 10)
2758
2759 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002760 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002761}
2762
2763func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2764 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2765
2766 // Init counter check
2767 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002768 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002769 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002770 Counter{cSubReqToE2, 1},
2771 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002772 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002773 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002774 Counter{cRouteDeleteFail, 1},
2775 Counter{cSubDelReqToE2, 1},
2776 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002777 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002778 })
2779
2780 var params *teststube2ap.RESTSubsReqParams = nil
2781
2782 //Subs Create
2783 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2784
2785 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2786
2787 waiter := rtmgrHttp.AllocNextEvent(false)
2788 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2789 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2790 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2791 waiter.WaitResult(t)
2792
2793 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002794 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002795 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002796}
2797
2798func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2799 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2800
2801 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002802 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002803 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002804 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002805 Counter{cSubReqToE2, 1},
2806 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002807 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002808 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002809 Counter{cRouteDeleteUpdateFail, 1},
2810 Counter{cSubDelReqToE2, 1},
2811 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002812 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002813 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002814 })
2815
2816 var params *teststube2ap.RESTSubsReqParams = nil
2817
2818 //Subs Create
2819 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2820
2821 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2822 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2823
2824 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2825
2826 //Del1, this shall fail on rtmgr side
2827 waiter := rtmgrHttp.AllocNextEvent(false)
2828 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2829 waiter.WaitResult(t)
2830
2831 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2832
2833 //Del2
2834 deleteXapp2Subscription(t, &restSubId2)
2835
2836 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002837 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002838 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002839}
2840
2841//-----------------------------------------------------------------------------
2842// TestRESTSubReqRetransmission
2843//
2844// stub stub
2845// +-------+ +---------+ +---------+
2846// | xapp | | submgr | | e2term |
2847// +-------+ +---------+ +---------+
2848// | | |
2849// | RESTSubReq1 | |
2850// |---------------->| |
2851// | | |
2852// | RESTSubResp | |
2853// |<----------------| |
2854// | | SubReq1 |
2855// | |------------->|
2856// | | |
2857// | RESTSubReq2 | |
2858// | (retrans) | |
2859// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002860// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002861// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002862// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002863// | | SubResp1 |
2864// | |<-------------|
2865// | RESTNotif1 | |
2866// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002867// | | |
2868// | [SUBS DELETE] |
2869// | | |
2870//
2871//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002872
archaggeafbf95f2021-04-14 08:54:05 +03002873func TestRESTSubReqRetransmission(t *testing.T) {
2874 CaseBegin("TestRESTSubReqRetransmission")
2875
2876 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002877 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002878 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002879 Counter{cSubReqToE2, 1},
2880 Counter{cSubRespFromE2, 1},
2881 Counter{cRestSubNotifToXapp, 1},
2882 Counter{cRestSubDelReqFromXapp, 1},
2883 Counter{cSubDelReqToE2, 1},
2884 Counter{cSubDelRespFromE2, 1},
2885 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002886 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002887 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002888 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2889 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2890
2891 // Subs Create
2892 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002893
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002894 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002895 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002896
Anssi Mannilab43397e2021-11-16 12:06:16 +02002897 xappConn1.SendRESTSubsReq(t, params)
2898 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03002899
Anssi Mannilab43397e2021-11-16 12:06:16 +02002900 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03002901
2902 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02002903 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03002904 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2905 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002906
Anssi Mannilab43397e2021-11-16 12:06:16 +02002907 e2SubsId := <-xappConn1.ListedRESTNotifications
2908
2909 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002910
2911 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02002912 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002913 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2914 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2915
Anssi Mannilab43397e2021-11-16 12:06:16 +02002916 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002917
2918 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02002919 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03002920}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002921
Markku Virtanen42723e22021-06-15 10:09:23 +03002922//-----------------------------------------------------------------------------
2923// stub stub stub
2924// +-------+ +---------+ +---------+ +---------+
2925// | xapp | | submgr | | e2term | | rtmgr |
2926// +-------+ +---------+ +---------+ +---------+
2927// | | | |
2928// | RESTSubReq | | |
2929// |---------------->| | |
2930// | RESTSubResp | | |
2931// |<----------------| | |
2932// | | RouteCreate | |
2933// | |--------------------------->|
2934// | | RouteResponse| |
2935// | |<---------------------------| // The order of these events may vary
2936// | | SubReq | |
2937// | |------------->| | // The order of these events may vary
2938// | | SubResp | |
2939// | |<-------------| |
2940// | RESTNotif1 | | |
2941// |<----------------| | |
2942// | RESTSubReq | | |
2943// | [RETRANS1] | | |
2944// |---------------->| | |
2945// | RESTNotif1 | | |
2946// |<----------------| | |
2947// | RESTSubReq | | |
2948// | [RETRANS2] | | |
2949// |---------------->| | |
2950// | RESTNotif1 | | |
2951// |<----------------| | |
2952// | RESTSubDelReq | | |
2953// |---------------->| | |
2954// | | SubDelReq | |
2955// | |------------->| |
2956// | RESTSubDelResp| | |
2957// |<----------------| | |
2958// | | SubDelResp | |
2959// | |<-------------| |
2960// | | | |
2961//
2962//-----------------------------------------------------------------------------
2963
2964func TestRESTSubReqRetransmissionV2(t *testing.T) {
2965 CaseBegin("TestRESTSubReqRetransmissionV2")
2966
2967 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2968 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002969 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03002970 Counter{cRestSubRespToXapp, 3},
2971 Counter{cSubReqToE2, 1},
2972 Counter{cSubRespFromE2, 1},
2973 Counter{cRestSubNotifToXapp, 3},
2974 Counter{cRestSubDelReqFromXapp, 1},
2975 Counter{cSubDelReqToE2, 1},
2976 Counter{cSubDelRespFromE2, 1},
2977 Counter{cRestSubDelRespToXapp, 1},
2978 })
2979
2980 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2981
2982 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2983
2984 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2985
2986 //1.st resend
2987 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2988
2989 assert.Equal(t, restSubId_resend, restSubId)
2990
2991 <-time.After(100 * time.Millisecond)
2992
2993 //2.nd resend
2994 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2995
2996 assert.Equal(t, restSubId_resend2, restSubId)
2997
2998 <-time.After(100 * time.Millisecond)
2999
3000 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3001
3002 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003003 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003004 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003005}
3006
3007//-----------------------------------------------------------------------------
3008// stub stub stub
3009// +-------+ +---------+ +---------+ +---------+
3010// | xapp | | submgr | | e2term | | rtmgr |
3011// +-------+ +---------+ +---------+ +---------+
3012// | | | |
3013// | RESTSubReq | | |
3014// |---------------->| | |
3015// | RESTSubResp | | |
3016// |<----------------| | |
3017// | | RouteCreate | |
3018// | |--------------------------->|
3019// | | RouteResponse| |
3020// | |<---------------------------| // The order of these events may vary
3021// | | SubReq | |
3022// | |------------->| | // The order of these events may vary
3023// | | SubResp | |
3024// | |<-------------| |
3025// | RESTNotif1 | | |
3026// |<----------------| | |
3027// | RESTSubReq | | |
3028// | [RETRANS, with RESTsubsId] | |
3029// |---------------->| | |
3030// | RESTNotif1 | | |
3031// |<----------------| | |
3032// | RESTSubReq | | |
3033// | [RETRANS, without RESTsubsId] | |
3034// |---------------->| | |
3035// | RESTNotif1 | | |
3036// |<----------------| | |
3037// | RESTSubDelReq | | |
3038// |---------------->| | |
3039// | | SubDelReq | |
3040// | |------------->| |
3041// | RESTSubDelResp| | |
3042// |<----------------| | |
3043// | | SubDelResp | |
3044// | |<-------------| |
3045// | | | |
3046//
3047//-----------------------------------------------------------------------------
3048func TestRESTSubReqRetransmissionV3(t *testing.T) {
3049 CaseBegin("TestRESTSubReqRetransmissionV3")
3050
3051 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3052 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003053 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003054 Counter{cRestSubRespToXapp, 3},
3055 Counter{cSubReqToE2, 1},
3056 Counter{cSubRespFromE2, 1},
3057 Counter{cRestSubNotifToXapp, 3},
3058 Counter{cRestSubDelReqFromXapp, 1},
3059 Counter{cSubDelReqToE2, 1},
3060 Counter{cSubDelRespFromE2, 1},
3061 Counter{cRestSubDelRespToXapp, 1},
3062 })
3063
3064 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3065
3066 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3067
3068 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3069
3070 <-time.After(100 * time.Millisecond)
3071
3072 //1.st resend with subscription ID
3073 params.SetSubscriptionID(&restSubId)
3074 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3075
3076 assert.Equal(t, restSubId_resend, restSubId)
3077
3078 <-time.After(100 * time.Millisecond)
3079
3080 //2.nd resend without subscription ID (faking app restart)
3081 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3082 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3083
3084 assert.Equal(t, restSubId_resend2, restSubId)
3085
3086 <-time.After(100 * time.Millisecond)
3087
3088 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3089
3090 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003091 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003092 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003093}
3094
3095//-----------------------------------------------------------------------------
3096// stub stub stub
3097// +-------+ +---------+ +---------+ +---------+
3098// | xapp | | submgr | | e2term | | rtmgr |
3099// +-------+ +---------+ +---------+ +---------+
3100// | | | |
3101// | RESTSubReq | | |
3102// |---------------->| | |
3103// | RESTSubResp | | |
3104// |<----------------| | |
3105// | | RouteCreate | |
3106// | |--------------------------->|
3107// | | RouteResponse| |
3108// | |<---------------------------|
3109// | | SubReq | |
3110// | |------------->| |
3111// | | SubResp | |
3112// | |<-------------| |
3113// | RESTNotif1 | | |
3114// |<----------------| | |
3115// | RESTSubReq | | |
3116// | [with RestSUbsId + one additional e2 subDetail]
3117// |---------------->| | |
3118// | RESTNotif1 | | |
3119// | [for initial e2 subDetail] | |
3120// |<----------------| | |
3121// | | RouteCreate | |
3122// | |--------------------------->|
3123// | | RouteResponse| |
3124// | |<---------------------------|
3125// | | SubReq | |
3126// | |------------->| |
3127// | | SubResp | |
3128// | |<-------------| |
3129// | RESTNotif1 | | |
3130// |<----------------| | |
3131// | RESTSubReq | | |
3132// | [with RESTsubsId initial request] |
3133// |---------------->| | |
3134// | RESTNotif1 | | |
3135// |<----------------| | |
3136// | RESTSubDelReq | | |
3137// |---------------->| | |
3138// | RESTSubDelResp| | |
3139// |<----------------| | |
3140// | | SubDelReq | |
3141// | |------------->| |
3142// | | SubDelResp | |
3143// | |<-------------| |
3144// | | SubDelReq | |
3145// | |------------->| |
3146// | | SubDelResp | |
3147// | |<-------------| |
3148// | | | |
3149//
3150//-----------------------------------------------------------------------------
3151
3152func TestRESTSubReqRetransmissionV4(t *testing.T) {
3153 CaseBegin("TestRESTSubReqRetransmissionV4")
3154
3155 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3156 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003157 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003158 Counter{cRestSubRespToXapp, 3},
3159 Counter{cSubReqToE2, 2},
3160 Counter{cSubRespFromE2, 2},
3161 Counter{cRestSubNotifToXapp, 4},
3162 Counter{cRestSubDelReqFromXapp, 1},
3163 Counter{cSubDelReqToE2, 2},
3164 Counter{cSubDelRespFromE2, 2},
3165 Counter{cRestSubDelRespToXapp, 1},
3166 })
3167
3168 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3169
3170 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3171
3172 <-time.After(100 * time.Millisecond)
3173
3174 // Send modified requst, this time with e2 subscriptions.
3175 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3176 params2.SetSubscriptionID(&restSubId)
3177
3178 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003179 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003180 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3181 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003182 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3183 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003184
3185 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3186
Markku Virtanen2b512b62021-07-30 12:04:00 +00003187 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003188 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3189 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3190 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3191 assert.NotEqual(t, e2SubsId2, 0)
3192
3193 <-time.After(100 * time.Millisecond)
3194
3195 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3196 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3197 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003198 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003199 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3200 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3201 assert.Equal(t, restSubId_resend, restSubId_resend2)
3202
Markku Virtanen2b512b62021-07-30 12:04:00 +00003203 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3204 assert.Equal(t, e2SubsId, e2SubsId1)
3205
Markku Virtanen42723e22021-06-15 10:09:23 +03003206 // Delete both e2 subscriptions
3207 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3208 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3209 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3210
3211 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003212 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003213 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003214}
3215
3216//-----------------------------------------------------------------------------
3217// stub stub stub
3218// +-------+ +---------+ +---------+ +---------+
3219// | xapp | | submgr | | e2term | | rtmgr |
3220// +-------+ +---------+ +---------+ +---------+
3221// | | | |
3222// | RESTSubReq | | |
3223// |---------------->| | |
3224// | RESTSubResp | | |
3225// |<----------------| | |
3226// | | RouteCreate | |
3227// | |--------------------------->|
3228// | | RouteResponse| |
3229// | |<---------------------------|
3230// | | SubReq | |
3231// | |------------->| |
3232// | | SubResp | |
3233// | |<-------------| |
3234// | RESTNotif1 | | |
3235// |<----------------| | |
3236// | RESTSubReq | | |
3237// | [with RestSUbsId + one additional e2 subDetail]
3238// |---------------->| | |
3239// | RESTNotif1 | | |
3240// | [for initial e2 subDetail] | |
3241// |<----------------| | |
3242// | | RouteCreate | |
3243// | |--------------------------->|
3244// | | RouteResponse| |
3245// | |<---------------------------|
3246// | | SubReq | |
3247// | |------------->| |
3248// | | SubResp | |
3249// | |<-------------| |
3250// | RESTNotif1 | | |
3251// |<----------------| | |
3252// | RESTSubReq | | |
3253// | [without RESTsubsId initial request] |
3254// |---------------->| | |
3255// | RESTNotif1 | | |
3256// |<----------------| | |
3257// | RESTSubDelReq | | |
3258// |---------------->| | |
3259// | RESTSubDelResp| | |
3260// |<----------------| | |
3261// | | SubDelReq | |
3262// | |------------->| |
3263// | | SubDelResp | |
3264// | |<-------------| |
3265// | | SubDelReq | |
3266// | |------------->| |
3267// | | SubDelResp | |
3268// | |<-------------| |
3269// | | | |
3270//
3271//-----------------------------------------------------------------------------
3272
3273func TestRESTSubReqRetransmissionV5(t *testing.T) {
3274 CaseBegin("TestRESTSubReqRetransmissionV5")
3275
3276 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3277 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003278 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003279 Counter{cRestSubRespToXapp, 3},
3280 Counter{cSubReqToE2, 2},
3281 Counter{cSubRespFromE2, 2},
3282 Counter{cRestSubNotifToXapp, 4},
3283 Counter{cRestSubDelReqFromXapp, 1},
3284 Counter{cSubDelReqToE2, 2},
3285 Counter{cSubDelRespFromE2, 2},
3286 Counter{cRestSubDelRespToXapp, 1},
3287 })
3288
3289 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3290
3291 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3292
3293 <-time.After(100 * time.Millisecond)
3294
3295 // Send modified requst, this time with e2 subscriptions.
3296 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3297 params2.SetSubscriptionID(&restSubId)
3298
3299 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003300 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003301 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3302 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3303
Markku Virtanen2b512b62021-07-30 12:04:00 +00003304 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3305 assert.Equal(t, e2SubsId, e2SubsId1)
3306 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3307 xappConn1.DecrementRequestCount()
3308
Markku Virtanen42723e22021-06-15 10:09:23 +03003309 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3310
3311 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3312 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3313 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3314 assert.NotEqual(t, e2SubsId2, 0)
3315
3316 <-time.After(100 * time.Millisecond)
3317
3318 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3319 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003320 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003321 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3322 // md5sum shall find the original request
3323 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3324 assert.Equal(t, restSubId_resend, restSubId_resend2)
3325
Markku Virtanen2b512b62021-07-30 12:04:00 +00003326 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3327 assert.Equal(t, e2SubsId, e2SubsId1)
3328
Markku Virtanen42723e22021-06-15 10:09:23 +03003329 // Delete both e2 subscriptions
3330 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3331 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3332 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3333
3334 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003335 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003336 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003337}
3338
3339//-----------------------------------------------------------------------------
3340// stub stub stub
3341// +-------+ +---------+ +---------+ +---------+
3342// | xapp | | submgr | | e2term | | rtmgr |
3343// +-------+ +---------+ +---------+ +---------+
3344// | | | |
3345// | RESTSubReq | | |
3346// |---------------->| | |
3347// | RESTSubResp | | |
3348// |<----------------| | |
3349// | | RouteCreate | |
3350// | |--------------------------->|
3351// | | RouteResponse| |
3352// | |<---------------------------|
3353// | | SubReq | |
3354// | |------------->| |
3355// | | SubResp | |
3356// | |<-------------| |
3357// | RESTNotif1 | | |
3358// |<----------------| | |
3359// | RESTSubReq | | |
3360// | [with RestSUbsId + one additional e2 subDetail]
3361// |---------------->| | |
3362// | RESTNotif1 | | |
3363// | [for initial e2 subDetail] | |
3364// |<----------------| | |
3365// | | RouteCreate | |
3366// | |--------------------------->|
3367// | | RouteResponse| |
3368// | |<---------------------------|
3369// | | SubReq | |
3370// | |------------->| |
3371// | | SubResp | |
3372// | |<-------------| |
3373// | RESTNotif1 | | |
3374// |<----------------| | |
3375// | RESTSubDelReq | | |
3376// |---------------->| | |
3377// | RESTSubDelResp| | |
3378// |<----------------| | |
3379// | | SubDelReq | |
3380// | |------------->| |
3381// | | SubDelResp | |
3382// | |<-------------| |
3383// | | SubDelReq | |
3384// | |------------->| |
3385// | | SubDelResp | |
3386// | |<-------------| |
3387// | RESTSubReq | | |
3388// | [with RESTsubsId initial request] |
3389// |---------------->| | |
3390// | RESTSubResp | | |
3391// |<----------------| | |
3392// | | RouteCreate | |
3393// | |--------------------------->|
3394// | | RouteResponse| |
3395// | |<---------------------------|
3396// | | SubReq | |
3397// | |------------->| |
3398// | | SubResp | |
3399// | |<-------------| |
3400// | RESTNotif1 | | |
3401// |<----------------| | |
3402// | | | |
3403//
3404//-----------------------------------------------------------------------------
3405func TestRESTSubReqRetransmissionV6(t *testing.T) {
3406 CaseBegin("TestRESTSubReqRetransmissionV6")
3407
3408 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3409 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003410 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003411 Counter{cRestSubRespToXapp, 3},
3412 Counter{cSubReqToE2, 3},
3413 Counter{cSubRespFromE2, 3},
3414 Counter{cRestSubNotifToXapp, 4},
3415 Counter{cRestSubDelReqFromXapp, 2},
3416 Counter{cSubDelReqToE2, 3},
3417 Counter{cSubDelRespFromE2, 3},
3418 Counter{cRestSubDelRespToXapp, 2},
3419 })
3420
3421 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3422
3423 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3424
3425 <-time.After(100 * time.Millisecond)
3426
3427 // Send modified requst, this time with e2 subscriptions.
3428 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3429 params2.SetSubscriptionID(&restSubId)
3430
3431 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003432 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003433 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3434 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3435
Markku Virtanen2b512b62021-07-30 12:04:00 +00003436 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3437 assert.Equal(t, e2SubsId, e2SubsId1)
3438
Markku Virtanen42723e22021-06-15 10:09:23 +03003439 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3440
3441 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3442 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3443 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3444 assert.NotEqual(t, e2SubsId2, 0)
3445
3446 <-time.After(100 * time.Millisecond)
3447
3448 // Delete both e2 subscriptions
3449 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3450 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3451 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3452
3453 waitSubsCleanup(t, e2SubsId, 10)
3454
3455 // Resend the original request, we shall find it's previous md5sum/restsubs
3456 // but the restsubscription has been already removed. This shall trigger a
3457 // fresh create.
3458 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3459
3460 <-time.After(100 * time.Millisecond)
3461
3462 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3463
3464 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003465 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003466 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003467}
3468
archaggeafbf95f2021-04-14 08:54:05 +03003469func TestRESTSubDelReqRetransmission(t *testing.T) {
3470 CaseBegin("TestRESTSubDelReqRetransmission")
3471
3472 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003473 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003474 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003475 Counter{cSubReqToE2, 1},
3476 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003477 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003478 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003479 Counter{cSubDelReqToE2, 1},
3480 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003481 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003482 })
3483
3484 var params *teststube2ap.RESTSubsReqParams = nil
3485
3486 //Subs Create
3487 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3488
3489 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3490
3491 //Subs Delete
3492 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3493 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3494
3495 seqBef := mainCtrl.get_msgcounter(t)
3496 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3497 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3498
3499 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3500
3501 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003502 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003503 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003504}
3505
3506//-----------------------------------------------------------------------------
3507// TestRESTSubReqDelReq
3508//
3509// stub stub
3510// +-------+ +---------+ +---------+
3511// | xapp | | submgr | | e2term |
3512// +-------+ +---------+ +---------+
3513// | | |
3514// | RESTSubReq | |
3515// |---------------->| |
3516// | | |
3517// | RESTSubResp | |
3518// |<----------------| |
3519// | | SubReq |
3520// | |------------->|
3521// | RESTSubDelReq | |
3522// |---------------->| |
3523// | RESTSubDelResp | |
3524// | unsuccess | |
3525// |<----------------| |
3526// | | SubResp |
3527// | |<-------------|
3528// | RESTNotif1 | |
3529// |<----------------| |
3530// | | |
3531// | [SUBS DELETE] |
3532// | | |
3533//
3534//-----------------------------------------------------------------------------
3535func TestRESTSubReqDelReq(t *testing.T) {
3536 CaseBegin("TestRESTSubReqDelReq")
3537
3538 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003539 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003540 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003541 Counter{cSubReqToE2, 1},
3542 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003543 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003544 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003545 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003546 Counter{cSubDelReqToE2, 1},
3547 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003548 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003549 })
3550
3551 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003552
3553 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003554 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003555 restSubId := xappConn1.SendRESTSubsReq(t, params)
3556
3557 // Del. This will fail as processing of the subscription
3558 // is still ongoing in submgr. Deletion is not allowed before
3559 // subscription creation has been completed.
3560 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3561 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3562 xappConn1.ExpectRESTNotification(t, restSubId)
3563 e2termConn1.SendSubsResp(t, crereq, cremsg)
3564 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3565
3566 // Retry del
3567 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3568
3569 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3570 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3571
3572 // Wait that subs is cleaned
3573 waitSubsCleanup(t, e2SubsId, 10)
3574 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003575 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003576}
3577
3578func TestRESTSubDelReqCollision(t *testing.T) {
3579 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3580}
3581
3582func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3583 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3584
3585 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003586 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003587 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003588 Counter{cSubReqToE2, 2},
3589 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003590 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003591 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003592 Counter{cSubDelReqToE2, 2},
3593 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003594 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003595 })
3596
3597 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003598 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003599 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003600 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003601
3602 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003603 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003604 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003605 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003606
3607 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3608 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3609
3610 //XappConn1 receives both of the responses
3611 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3612
3613 //Resp1
3614 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3615 //Resp2
3616 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3617
3618 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003619 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003620 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003621 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003622
3623 //Del1
3624 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3625 //Del2
3626 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3627
3628 //Wait that subs is cleaned
3629 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3630 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3631
3632 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003633 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003634}
3635
3636func TestRESTSameSubsDiffRan(t *testing.T) {
3637 CaseBegin("TestRESTSameSubsDiffRan")
3638
3639 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003640 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003641 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003642 Counter{cSubReqToE2, 2},
3643 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003644 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003645 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003646 Counter{cSubDelReqToE2, 2},
3647 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003648 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003649 })
3650
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003651 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003652 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003653 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003654
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003655 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003656 params.SetMeid("RAN_NAME_2")
3657 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003658 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003659
3660 //Del1
3661 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3662 //Del2
3663 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3664
3665 //Wait that subs is cleaned
3666 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3667 waitSubsCleanup(t, e2SubsId2, 10)
3668
3669 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003670 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003671}
3672
3673func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3674 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3675
3676 // Init counter check
3677 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003678 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003679 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003680 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003681 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003682 Counter{cSubReReqToE2, 1},
3683 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003684 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003685 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003686 Counter{cSubDelReqToE2, 1},
3687 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003688 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003689 })
3690
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003691 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003692 restSubId := xappConn1.SendRESTSubsReq(t, params)
3693
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003694 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003695
3696 // Catch the first message and ignore it
3697 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003698 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003699
3700 // The second request is being handled normally
3701 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3702 xappConn1.ExpectRESTNotification(t, restSubId)
3703 e2termConn1.SendSubsResp(t, crereq, cremsg)
3704 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3705
3706 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3707
3708 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3709
3710 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3711 //Wait that subs is cleaned
3712 waitSubsCleanup(t, e2SubsId, 10)
3713
3714 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003715 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003716}
3717
3718//-----------------------------------------------------------------------------
3719// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3720//
3721// stub stub
3722// +-------+ +---------+ +---------+
3723// | xapp | | submgr | | e2term |
3724// +-------+ +---------+ +---------+
3725// | | |
3726// | RESTSubReq | |
3727// |---------------->| |
3728// | | |
3729// | RESTSubResp | |
3730// |<----------------| |
3731// | | SubReq |
3732// | |------------->|
3733// | | |
3734// | | |
3735// | | SubReq |
3736// | |------------->|
3737// | | |
3738// | | SubDelReq |
3739// | |------------->|
3740// | | |
3741// | | |
3742// | | SubDelReq |
3743// | |------------->|
3744// | | |
3745// | | |
3746// | | SubDelResp |
3747// | |<-------------|
3748// | RESTNotif | |
3749// | unsuccess | |
3750// |<----------------| |
3751// | | |
3752// | [SUBS DELETE] |
3753// | | |
3754//
3755//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003756
archaggeafbf95f2021-04-14 08:54:05 +03003757func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3758 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3759
3760 // Init counter check
3761 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003762 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003763 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003764 Counter{cSubReqToE2, 1},
3765 Counter{cSubReReqToE2, 1},
3766 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003767 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003768 Counter{cSubDelReqToE2, 1},
3769 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003770 Counter{cRestSubDelReqFromXapp, 1},
3771 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003772 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003773
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003774 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003775 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003776 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003777
3778 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003779 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003780
3781 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003782 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003783
3784 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003785 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003786 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003787 xappConn1.WaitRESTNotification(t, restSubId)
3788
Anssi Mannilab43397e2021-11-16 12:06:16 +02003789 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3790
archaggeafbf95f2021-04-14 08:54:05 +03003791 // Wait that subs is cleaned
3792 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003793 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003794 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003795}
3796
3797func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3798 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3799
3800 // Init counter check
3801 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003802 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003803 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003804 Counter{cSubReqToE2, 1},
3805 Counter{cSubReReqToE2, 1},
3806 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003807 Counter{cSubDelReReqToE2, 1},
3808 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003809 Counter{cSubDelReqToE2, 1},
3810 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003811 Counter{cRestSubDelReqFromXapp, 1},
3812 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003813 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003814
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003815 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003816 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003817 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003818
3819 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003820 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003821
3822 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003823 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003824
3825 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003826 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003827
Markku Virtanen55d2a282021-06-04 14:46:56 +03003828 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003829 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003830 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003831
3832 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3833
Anssi Mannilab43397e2021-11-16 12:06:16 +02003834 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003835
Anssi Mannilab43397e2021-11-16 12:06:16 +02003836 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003837 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003838 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003839}
3840
3841//-----------------------------------------------------------------------------
3842// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3843//
3844// stub stub
3845// +-------+ +---------+ +---------+
3846// | xapp | | submgr | | e2term |
3847// +-------+ +---------+ +---------+
3848// | | |
3849// | RESTSubReq | |
3850// |---------------->| |
3851// | | |
3852// | RESTSubResp | |
3853// |<----------------| |
3854// | | SubReq |
3855// | |------------->|
3856// | | |
3857// | | |
3858// | | SubReq |
3859// | |------------->|
3860// | | |
3861// | | SubDelReq |
3862// | |------------->|
3863// | | |
3864// | | |
3865// | | SubDelReq |
3866// | |------------->|
3867// | | |
3868// | | |
3869// | | SubDelResp |
3870// | |<-------------|
3871// | RESTNotif | |
3872// | unsuccess | |
3873// |<----------------| |
3874// | | |
3875// | [SUBS DELETE] |
3876// | | |
3877//
3878//-----------------------------------------------------------------------------
3879func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3880 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3881
3882 // Init counter check
3883 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003884 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003885 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003886 Counter{cSubReqToE2, 1},
3887 Counter{cSubReReqToE2, 1},
3888 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003889 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003890 Counter{cSubDelReqToE2, 1},
3891 Counter{cSubDelReReqToE2, 1},
3892 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003893 Counter{cRestSubDelReqFromXapp, 1},
3894 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003895 })
3896
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003897 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003898 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003899 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003900
3901 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003902 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003903
3904 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003905 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003906
3907 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003908 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003909
Markku Virtanen55d2a282021-06-04 14:46:56 +03003910 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003911 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003912 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003913
3914 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3915
Anssi Mannilab43397e2021-11-16 12:06:16 +02003916 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003917
Anssi Mannilab43397e2021-11-16 12:06:16 +02003918 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003919 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003920 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003921}
3922
3923//-----------------------------------------------------------------------------
3924// TestRESTSubReqSubFailRespInSubmgr
3925//
3926// stub stub
3927// +-------+ +---------+ +---------+
3928// | xapp | | submgr | | e2term |
3929// +-------+ +---------+ +---------+
3930// | | |
3931// | RESTSubReq | |
3932// |---------------->| |
3933// | | |
3934// | RESTSubResp | |
3935// |<----------------| |
3936// | | SubReq |
3937// | |------------->|
3938// | | |
3939// | | SubFail |
3940// | |<-------------|
3941// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003942// | RESTNotif | |
3943// | unsuccess | |
3944// |<----------------| |
3945// | | |
3946// | [SUBS DELETE] |
3947// | | |
3948//
3949//-----------------------------------------------------------------------------
3950func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3951 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3952
3953 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003954 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003955 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003956 Counter{cSubReqToE2, 1},
3957 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003958 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003959 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003960 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003961 })
3962
3963 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003964 const e2Timeout int64 = 2
3965 const e2RetryCount int64 = 1
3966 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003967
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003968 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003969 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003970 restSubId := xappConn1.SendRESTSubsReq(t, params)
3971
3972 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3973 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3974 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003975 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003976 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3977
archaggeafbf95f2021-04-14 08:54:05 +03003978 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003979 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003980
3981 // REST subscription sill there to be deleted
3982 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3983
3984 // Wait that subs is cleaned
3985 waitSubsCleanup(t, e2SubsId, 10)
3986
3987 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003988 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003989}
3990
3991//-----------------------------------------------------------------------------
3992// TestRESTSubDelReqRetryInSubmgr
3993//
3994// stub stub
3995// +-------+ +---------+ +---------+
3996// | xapp | | submgr | | e2term |
3997// +-------+ +---------+ +---------+
3998// | | |
3999// | [SUBS CREATE] |
4000// | | |
4001// | | |
4002// | RESTSubDelReq | |
4003// |---------------->| |
4004// | | |
4005// | RESTSubDelResp | |
4006// |<----------------| |
4007// | | SubDelReq |
4008// | |------------->|
4009// | | |
4010// | | SubDelReq |
4011// | |------------->|
4012// | | |
4013// | | SubDelResp |
4014// | |<-------------|
4015// | | |
4016//
4017//-----------------------------------------------------------------------------
4018func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4019 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4020
4021 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004022 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004023 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004024 Counter{cSubReqToE2, 1},
4025 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004026 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004027 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004028 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004029 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004030 Counter{cSubDelReReqToE2, 1},
4031 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004032 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004033 })
4034 // Req
4035 var params *teststube2ap.RESTSubsReqParams = nil
4036 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4037
4038 // Del
4039 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4040
4041 // E2t: Receive 1st SubsDelReq
4042 e2termConn1.RecvSubsDelReq(t)
4043
4044 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4045 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4046 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4047
4048 //Wait that subs is cleaned
4049 waitSubsCleanup(t, e2SubsId, 10)
4050
4051 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004052 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004053}
4054
4055//-----------------------------------------------------------------------------
4056// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4057//
4058// stub stub
4059// +-------+ +---------+ +---------+
4060// | xapp | | submgr | | e2term |
4061// +-------+ +---------+ +---------+
4062// | | |
4063// | [SUBS CREATE] |
4064// | | |
4065// | | |
4066// | RESTSubDelReq | |
4067// |---------------->| |
4068// | | |
4069// | RESTSubDelResp | |
4070// |<----------------| |
4071// | | SubDelReq |
4072// | |------------->|
4073// | | |
4074// | | SubDelReq |
4075// | |------------->|
4076// | | |
4077// | | |
4078//
4079//-----------------------------------------------------------------------------
4080func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4081 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4082
4083 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004084 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004085 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004086 Counter{cSubReqToE2, 1},
4087 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004088 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004089 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004090 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004091 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004092 Counter{cSubDelReReqToE2, 1},
4093 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004094 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004095 })
4096
4097 // Req
4098 var params *teststube2ap.RESTSubsReqParams = nil
4099 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4100
4101 // Del
4102 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4103
4104 // E2t: Receive 1st SubsDelReq
4105 e2termConn1.RecvSubsDelReq(t)
4106
4107 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4108 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4109 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4110
4111 //Wait that subs is cleaned
4112 waitSubsCleanup(t, e2SubsId, 10)
4113
4114 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004115 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004116}
4117
4118//-----------------------------------------------------------------------------
4119// TestRESTSubDelReqSubDelFailRespInSubmgr
4120//
4121// stub stub
4122// +-------+ +---------+ +---------+
4123// | xapp | | submgr | | e2term |
4124// +-------+ +---------+ +---------+
4125// | | |
4126// | [SUBS CREATE] |
4127// | | |
4128// | | |
4129// | RESTSubDelReq | |
4130// |---------------->| |
4131// | | |
4132// | RESTSubDelResp | |
4133// |<----------------| |
4134// | | SubDelReq |
4135// | |------------->|
4136// | | |
4137// | | SubDelFail |
4138// | |<-------------|
4139// | | |
4140//
4141//-----------------------------------------------------------------------------
4142func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4143 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4144
4145 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004146 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004147 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004148 Counter{cSubReqToE2, 1},
4149 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004150 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004151 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004152 Counter{cSubDelReqToE2, 1},
4153 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004154 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004155 })
4156
4157 // Req
4158 var params *teststube2ap.RESTSubsReqParams = nil
4159 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4160
4161 // Del
4162 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4163
4164 // E2t: Send receive SubsDelReq and send SubsDelFail
4165 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4166 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4167
4168 //Wait that subs is cleaned
4169 waitSubsCleanup(t, e2SubsId, 10)
4170
4171 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004172 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004173}
4174
4175//-----------------------------------------------------------------------------
4176// TestRESTSubReqAndSubDelOkSameAction
4177//
4178// stub stub
4179// +-------+ +-------+ +---------+ +---------+
4180// | xapp2 | | xapp1 | | submgr | | e2term |
4181// +-------+ +-------+ +---------+ +---------+
4182// | | | |
4183// | | RESTSubReq1 | |
4184// | |---------------->| |
4185// | | | |
4186// | | RESTSubResp1 | |
4187// | |<----------------| |
4188// | | | |
4189// | | | SubReq1 |
4190// | | |------------->|
4191// | | | SubResp1 |
4192// | | |<-------------|
4193// | | RESTNotif1 | |
4194// | |<----------------| |
4195// | | | |
4196// | RESTSubReq2 | |
4197// |------------------------------>| |
4198// | | | |
4199// | RESTSubResp2 | |
4200// |<------------------------------| |
4201// | | | |
4202// | | RESTNotif2 | |
4203// |<------------------------------| |
4204// | | | |
4205// | | RESTSubDelReq1 | |
4206// | |---------------->| |
4207// | | | |
4208// | | RESTSubDelResp1 | |
4209// | |<----------------| |
4210// | | | |
4211// | RESTSubDelReq2 | |
4212// |------------------------------>| |
4213// | | | |
4214// | RESTSubDelResp2 | |
4215// |<------------------------------| |
4216// | | | |
4217// | | | SubDelReq2 |
4218// | | |------------->|
4219// | | | |
4220// | | | SubDelResp2 |
4221// | | |<-------------|
4222// | | | |
4223//
4224//-----------------------------------------------------------------------------
4225func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4226 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4227
4228 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004229 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004230 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004231 Counter{cSubReqToE2, 1},
4232 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004233 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004234 Counter{cMergedSubscriptions, 1},
4235 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004236 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004237 Counter{cSubDelReqToE2, 1},
4238 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004239 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004240 })
4241
4242 // Req1
4243 var params *teststube2ap.RESTSubsReqParams = nil
4244
4245 //Subs Create
4246 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4247 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4248
4249 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004250 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004251 params.SetMeid("RAN_NAME_1")
4252
4253 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004254 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004255 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004256 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004257 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004258 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004259 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004260 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004261
4262 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4263
4264 // Del1
4265 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4266
4267 // Del2
4268 deleteXapp2Subscription(t, &restSubId2)
4269
4270 //Wait that subs is cleaned
4271 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004272 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004273 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004274}
4275
4276//-----------------------------------------------------------------------------
4277// TestSubReqAndSubDelOkSameActionParallel
4278//
4279// stub stub stub
4280// +-------+ +-------+ +---------+ +---------+
4281// | xapp2 | | xapp1 | | submgr | | e2term |
4282// +-------+ +-------+ +---------+ +---------+
4283// | | | |
4284// | | | |
4285// | | | |
4286// | | SubReq1 | |
4287// | |------------->| |
4288// | | | |
4289// | | | SubReq1 |
4290// | | |------------->|
4291// | SubReq2 | |
4292// |--------------------------->| |
4293// | | | SubResp1 |
4294// | | |<-------------|
4295// | | SubResp1 | |
4296// | |<-------------| |
4297// | | | SubReq2 |
4298// | | |------------->|
4299// | | | |
4300// | | | SubResp2 |
4301// | | |<-------------|
4302// | SubResp2 | |
4303// |<---------------------------| |
4304// | | | |
4305// | | SubDelReq 1 | |
4306// | |------------->| |
4307// | | | |
4308// | | SubDelResp 1 | |
4309// | |<-------------| |
4310// | | | |
4311// | SubDelReq 2 | |
4312// |--------------------------->| |
4313// | | | |
4314// | | | SubDelReq 2 |
4315// | | |------------->|
4316// | | | |
4317// | | | SubDelReq 2 |
4318// | | |------------->|
4319// | | | |
4320// | SubDelResp 2 | |
4321// |<---------------------------| |
4322//
4323func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4324 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4325
4326 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004327 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004328 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004329 Counter{cSubReqToE2, 2},
4330 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004331 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004332 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004333 Counter{cSubDelReqToE2, 2},
4334 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004335 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004336 })
4337
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004338 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004339 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4340 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4341
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004342 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004343 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4344
4345 xappConn1.ExpectRESTNotification(t, restSubId1)
4346 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4347 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4348
4349 xappConn2.ExpectRESTNotification(t, restSubId2)
4350 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4351 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4352 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4353
4354 // Del1
4355 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4356 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4357 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4358 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4359
4360 // Del2
4361 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4362 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4363 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4364
4365 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004366 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004367 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004368}
4369
4370//-----------------------------------------------------------------------------
4371// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4372//
4373// stub stub stub
4374// +-------+ +-------+ +---------+ +---------+
4375// | xapp2 | | xapp1 | | submgr | | e2term |
4376// +-------+ +-------+ +---------+ +---------+
4377// | | | |
4378// | | | |
4379// | | | |
4380// | | RESTSubReq1 | |
4381// | |---------------->| |
4382// | | | |
4383// | | RESTSubResp1 | |
4384// | |<----------------| |
4385// | | | SubReq1 |
4386// | | |------------->|
4387// | RESTSubReq2 | |
4388// |------------------------------>| |
4389// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004390// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004391// |<------------------------------| |
4392// | | | SubReq1 |
4393// | | |------------->|
4394// | | | |
4395// | | | |
4396// | | | SubDelReq |
4397// | | |------------->|
4398// | | | |
4399// | | | SubDelResp |
4400// | | |<-------------|
4401// | | RESTNotif1 | |
4402// | | unsuccess | |
4403// | |<----------------| |
4404// | RESTNotif2 | |
4405// | | unsuccess | |
4406// |<------------------------------| |
4407// | | | |
4408// | | RESTSubDelReq1 | |
4409// | |---------------->| |
4410// | | | |
4411// | | RESTSubDelResp1 | |
4412// | |<----------------| |
4413// | | | |
4414// | RESTSubDelReq2 | |
4415// |------------------------------>| |
4416// | | | |
4417// | RESTSubDelResp2 | |
4418// |<------------------------------| |
4419//
4420//-----------------------------------------------------------------------------
4421func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4422 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4423
4424 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004425 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004426 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004427 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004428 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004429 Counter{cSubReqTimerExpiry, 2},
4430 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004431 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004432 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004433 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004434 Counter{cSubDelReqToE2, 1},
4435 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004436 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004437 })
archaggeafbf95f2021-04-14 08:54:05 +03004438 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004439
4440 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004441 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004442 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4443 crereq1, _ := e2termConn1.RecvSubsReq(t)
4444
4445 // Req2
4446 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004447 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004448 params2.SetMeid("RAN_NAME_1")
4449 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4450 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4451
4452 //Req1 (retransmitted)
4453 e2termConn1.RecvSubsReq(t)
4454
4455 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004456
4457 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004458 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4459
Markku Virtanenda34eec2021-05-20 08:22:04 +00004460 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004461 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004462 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004463 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004464
4465 // Del1
4466 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4467
4468 // Del2
4469 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4470
Markku Virtanenda34eec2021-05-20 08:22:04 +00004471 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4472
archaggeafbf95f2021-04-14 08:54:05 +03004473 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004474 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004475 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004476 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004477}
4478
4479//-----------------------------------------------------------------------------
4480// TestRESTSubReqAndSubDelNokSameActionParallel
4481//
4482// stub stub stub
4483// +-------+ +-------+ +---------+ +---------+
4484// | xapp2 | | xapp1 | | submgr | | e2term |
4485// +-------+ +-------+ +---------+ +---------+
4486// | | | |
4487// | | | |
4488// | | | |
4489// | | RESTSubReq1 | |
4490// | |---------------->| |
4491// | | | |
4492// | | RESTSubResp1 | |
4493// | |<----------------| |
4494// | | | SubReq1 |
4495// | | |------------->|
4496// | RESTSubReq2 | |
4497// |------------------------------>| |
4498// | | | |
4499// | RESTSubDelResp2 | |
4500// |<------------------------------| |
4501// | | | SubFail1 |
4502// | | |<-------------|
4503// | | | |
4504// | | RESTNotif1 | |
4505// | | unsuccess | |
4506// | |<----------------| |
4507// | RESTNotif2 | |
4508// | | unsuccess | |
4509// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004510// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004511// | | 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 +03004512// | |---------------->| |
4513// | | | |
4514// | | RESTSubDelResp1 | |
4515// | |<----------------| |
4516// | | | |
4517// | RESTSubDelReq2 | |
4518// |------------------------------>| |
4519// | | | |
4520// | RESTSubDelResp2 | |
4521// |<------------------------------| |
4522//
4523//-----------------------------------------------------------------------------
4524func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4525 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4526
4527 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004528 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004529 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004530 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004531 Counter{cSubReqToE2, 1},
4532 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004533 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004534 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004535 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004536 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004537 })
4538
4539 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004540
4541 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004542 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004543 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4544 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4545
4546 // Req2
4547 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004548 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004549 params2.SetMeid("RAN_NAME_1")
4550 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4551 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4552
4553 // E2t: send SubsFail (first)
4554 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4555 fparams1.Set(crereq1)
4556 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4557
archaggeafbf95f2021-04-14 08:54:05 +03004558 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004559 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004560 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004561 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004562 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004563
4564 // Del1
4565 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4566
4567 // Del2
4568 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4569
4570 //Wait that subs is cleaned
4571 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4572 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004573 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004574 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004575}
Anssi Mannila54838ed2021-11-19 11:25:01 +02004576
archaggeafbf95f2021-04-14 08:54:05 +03004577func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4578 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4579
4580 // Init counter check
4581 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004582 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004583 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004584 Counter{cSubReqToE2, 1},
4585 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004586 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004587 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004588 Counter{cSubDelReqToE2, 1},
4589 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004590 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004591 })
4592
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004593 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004594 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004595 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004596
4597 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4598 xappConn1.ExpectRESTNotification(t, restSubId)
4599 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4600 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004601 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004602
4603 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4604 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4605 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4606
4607 // Wait that subs is cleaned
4608 waitSubsCleanup(t, e2SubsId, 10)
4609 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004610 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004611}
4612
4613//-----------------------------------------------------------------------------
4614// TestRESTSubReqPolicyChangeAndSubDelOk
4615//
4616// stub stub
4617// +-------+ +---------+ +---------+
4618// | xapp | | submgr | | e2term |
4619// +-------+ +---------+ +---------+
4620// | | |
4621// | RESTSubReq | |
4622// |---------------->| |
4623// | | |
4624// | RESTSubResp | |
4625// |<----------------| |
4626// | | SubReq |
4627// | |------------->|
4628// | | |
4629// | | SubResp |
4630// | |<-------------|
4631// | | |
4632// | RESTNotif | |
4633// |<----------------| |
4634// | | |
4635// | RESTSubReq | |
4636// |---------------->| |
4637// | | |
4638// | RESTSubResp | |
4639// |<----------------| |
4640// | | SubReq |
4641// | |------------->|
4642// | | |
4643// | | SubResp |
4644// | |<-------------|
4645// | | |
4646// | RESTNotif | |
4647// |<----------------| |
4648// | | |
4649// | RESTSubDelReq | |
4650// |---------------->| |
4651// | | |
4652// | | SubDelReq |
4653// | |------------->|
4654// | | |
4655// | | SubDelResp |
4656// | |<-------------|
4657// | | |
4658// | RESTSubDelResp | |
4659// |<----------------| |
4660//
4661//-----------------------------------------------------------------------------
4662func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4663 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4664
4665 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004666 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004667 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004668 Counter{cSubReqToE2, 2},
4669 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004670 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004671 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004672 Counter{cSubDelReqToE2, 1},
4673 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004674 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004675 })
4676
4677 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004678 const e2Timeout int64 = 1
4679 const e2RetryCount int64 = 0
4680 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004681
4682 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004683 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004684 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004685 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4686
4687 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004688 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004689
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004690 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004691 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004692 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004693 params.SetTimeToWait("w200ms")
4694 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4695
4696 // Del
4697 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4698
4699 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4700 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4701
4702 // Wait that subs is cleaned
4703 waitSubsCleanup(t, e2SubsId, 10)
4704 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004705 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004706}
4707
4708//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004709// TestRESTSubReqPolicyChangeNOk
4710//
4711// stub stub
4712// +-------+ +---------+ +---------+
4713// | xapp | | submgr | | e2term |
4714// +-------+ +---------+ +---------+
4715// | | |
4716// | RESTSubReq | |
4717// |---------------->| |
4718// | | |
4719// | RESTSubResp | |
4720// |<----------------| |
4721// | | SubReq |
4722// | |------------->|
4723// | | |
4724// | | SubResp |
4725// | |<-------------|
4726// | | |
4727// | RESTNotif | |
4728// |<----------------| |
4729// | | |
4730// | RESTSubReq | |
4731// |---------------->| |
4732// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004733// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004734// | | |
4735// | RESTSubDelReq | |
4736// |---------------->| |
4737// | | |
4738// | | SubDelReq |
4739// | |------------->|
4740// | | |
4741// | | SubDelResp |
4742// | |<-------------|
4743// | | |
4744// | RESTSubDelResp | |
4745// |<----------------| |
4746//
4747//-----------------------------------------------------------------------------
4748func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4749 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4750
4751 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4752 Counter{cRestSubReqFromXapp, 2},
4753 Counter{cRestSubRespToXapp, 1},
4754 Counter{cSubReqToE2, 1},
4755 Counter{cSubRespFromE2, 1},
4756 Counter{cRestSubNotifToXapp, 1},
4757 Counter{cRestSubFailToXapp, 1},
4758 Counter{cRestSubDelReqFromXapp, 1},
4759 Counter{cSubDelReqToE2, 1},
4760 Counter{cSubDelRespFromE2, 1},
4761 Counter{cRestSubDelRespToXapp, 1},
4762 })
4763
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004764 // Req
4765 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4766 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4767
4768 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004769 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4770
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004771 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004772 params.SetSubscriptionID(&restSubIdUpd)
4773 params.SetTimeToWait("w200ms")
4774
4775 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4776 assert.Equal(t, restSubId2, "")
4777
4778 // Del
4779 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4780
4781 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4782 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4783
4784 // Wait that subs is cleaned
4785 waitSubsCleanup(t, e2SubsId, 10)
4786 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004787 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004788}
4789
4790//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004791// TestRESTSubReqAndSubDelOkTwoE2termParallel
4792//
4793// stub stub stub
4794// +-------+ +---------+ +---------+ +---------+
4795// | xapp | | submgr | | e2term1 | | e2term2 |
4796// +-------+ +---------+ +---------+ +---------+
4797// | | | |
4798// | | | |
4799// | | | |
4800// | RESTSubReq1 | | |
4801// |---------------->| | |
4802// | | | |
4803// | RESTSubResp1 | | |
4804// |<----------------| | |
4805// | | SubReq1 | |
4806// | |------------->| |
4807// | | | |
4808// | RESTSubReq2 | | |
4809// |---------------->| | |
4810// | | | |
4811// | RESTSubResp2 | | |
4812// |<----------------| | |
4813// | | SubReq2 | |
4814// | |---------------------------->|
4815// | | | |
4816// | | SubResp1 | |
4817// | |<-------------| |
4818// | RESTNotif1 | | |
4819// |<----------------| | |
4820// | | SubResp2 | |
4821// | |<----------------------------|
4822// | RESTNotif2 | | |
4823// |<----------------| | |
4824// | | | |
4825// | [SUBS 1 DELETE] | |
4826// | | | |
4827// | [SUBS 2 DELETE] | |
4828// | | | |
4829//
4830//-----------------------------------------------------------------------------
4831func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4832 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4833
4834 // Init counter check
4835 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004836 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004837 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004838 Counter{cSubReqToE2, 2},
4839 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004840 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004841 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004842 Counter{cSubDelReqToE2, 2},
4843 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004844 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004845 })
4846
4847 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004848
4849 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004850 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004851 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4852 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4853
4854 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004855 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004856 params.SetMeid("RAN_NAME_11")
4857 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4858 // would not work as notification would not be received
4859 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4860 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4861
4862 // Resp1
4863 xappConn1.ExpectRESTNotification(t, restSubId1)
4864 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4865 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004866 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004867
4868 // Resp2
4869 xappConn2.ExpectRESTNotification(t, restSubId2)
4870 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4871 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004872 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004873
4874 // Delete1
4875 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4876 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4877 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4878
4879 // Wait that subs is cleaned
4880 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4881
4882 // Delete2
4883 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4884 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4885 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4886
4887 // Wait that subs is cleaned
4888 waitSubsCleanup(t, e2SubsId2, 10)
4889
4890 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004891 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004892}
4893
4894//-----------------------------------------------------------------------------
4895// TestRESTSubReqAsn1EncodeFail
4896//
4897// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4898// stub stub
4899// +-------+ +---------+ +---------+
4900// | xapp | | submgr | | e2term |
4901// +-------+ +---------+ +---------+
4902// | | |
4903// | RESTSubReq | |
4904// |---------------->| |
4905// | | |
4906// | RESTSubResp | |
4907// |<----------------| |
4908// | RESTSubDelReq | |
4909// |---------------->| |
4910// | RESTSubDelResp | |
4911// | unsuccess | |
4912// |<----------------| |
4913// | | |
4914//
4915//-----------------------------------------------------------------------------
4916func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4917 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4918
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004919 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004920
4921}
4922
4923//-----------------------------------------------------------------------------
4924// TestRESTSubReqInsertAndSubDelOk
4925//
4926// stub stub
4927// +-------+ +---------+ +---------+
4928// | xapp | | submgr | | e2term |
4929// +-------+ +---------+ +---------+
4930// | | |
4931// | RestSubReq | |
4932// |---------------->| |
4933// | | |
4934// | RESTSubResp | |
4935// |<----------------| |
4936// | | |
4937// | | SubReq |
4938// | |------------->|
4939// | | |
4940// | | SubResp |
4941// | |<-------------|
4942// | RESTNotif | |
4943// |<----------------| |
4944// | ... | ... |
4945// | | |
4946// | RESTSubDelReq | |
4947// |---------------->| |
4948// | | |
4949// | | SubDelReq |
4950// | |------------->|
4951// | | |
4952// | | SubDelResp |
4953// | |<-------------|
4954// | | |
4955// | RESTSubDelResp| |
4956// |<----------------| |
4957//
4958//-----------------------------------------------------------------------------
4959func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4960 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4961
4962 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004963 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004964 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004965 Counter{cSubReqToE2, 1},
4966 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004967 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004968 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004969 Counter{cSubDelReqToE2, 1},
4970 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004971 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004972 })
4973
4974 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004975
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004976 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004977 params.SetSubActionTypes("insert")
4978
4979 // Req
4980 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4981
4982 // Del
4983 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4984
4985 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4986 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4987
4988 // Wait that subs is cleaned
4989 waitSubsCleanup(t, e2SubsId, 10)
4990 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004991 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004992}
4993
4994//-----------------------------------------------------------------------------
4995// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4996//
4997// stub stub
4998// +-------+ +---------+ +---------+
4999// | xapp | | submgr | | e2term |
5000// +-------+ +---------+ +---------+
5001// | | |
5002// | RESTSubReq | |
5003// |------------->| |
5004// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005005// | RESTSubResp | |
5006// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005007// | | SubReq |
5008// | |------------->|
5009// | | |
5010// | | SubResp |
5011// | <----|
5012// | |
5013// | Submgr restart |
5014// | |
5015// | | |
5016// | | SubDelReq |
5017// | |------------->|
5018// | | |
5019// | | SubDelResp |
5020// | |<-------------|
5021// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005022// | RESTNotif | |
5023// | unsuccess | |
5024// |<-------------| |
5025// | | |
5026// | RESTSubDelReq| |
5027// |------------->| |
5028// | | |
5029// |RESTSubDelResp| |
5030// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005031//
5032//-----------------------------------------------------------------------------
5033func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5034 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5035
5036 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005037 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005038 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005039 Counter{cSubReqToE2, 1},
5040 Counter{cSubDelReqFromXapp, 1},
5041 Counter{cSubDelReqToE2, 1},
5042 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005043 Counter{cRestSubDelReqFromXapp, 1},
5044 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005045 })
5046
5047 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005048
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005049 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005050
5051 //Req
5052 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5053 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005054 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005055
5056 e2termConn1.RecvSubsReq(t)
5057
5058 mainCtrl.SetResetTestFlag(t, false)
5059
5060 mainCtrl.SimulateRestart(t)
5061 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5062
Anssi Mannilab43397e2021-11-16 12:06:16 +02005063 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005064 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5065 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5066
Anssi Mannilab43397e2021-11-16 12:06:16 +02005067 //Del
5068 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5069
archaggeafbf95f2021-04-14 08:54:05 +03005070 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005071 e2termConn1.TestMsgChanEmpty(t)
5072 mainCtrl.wait_registry_empty(t, 10)
5073
5074 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005075 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005076}
5077
5078//-----------------------------------------------------------------------------
5079// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5080//
5081// stub stub
5082// +-------+ +---------+ +---------+
5083// | xapp | | submgr | | e2term |
5084// +-------+ +---------+ +---------+
5085// | | |
5086// | RESTSubReq | |
5087// |---------------->| |
5088// | | |
5089// | RESTSubResp | |
5090// |<----------------| |
5091// | | SubReq |
5092// | |------------->|
5093// | | |
5094// | | SubResp |
5095// | |<-------------|
5096// | | |
5097// | RESTNotif | |
5098// |<----------------| |
5099// | | |
5100// | |
5101// | Submgr restart |
5102// | | |
5103// | RESTSubDelReq | |
5104// |---------------->| |
5105// | | |
5106// | | SubDelReq |
5107// | |------------->|
5108// | | |
5109// | | SubDelResp |
5110// | |<-------------|
5111// | | |
5112// | RESTSubDelResp | |
5113// |<----------------| |
5114//
5115//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005116
archaggeafbf95f2021-04-14 08:54:05 +03005117func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5118 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5119
5120 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005121 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005122 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005123 Counter{cSubReqToE2, 1},
5124 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005125 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005126 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005127 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005128 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005129 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005130 })
archaggeafbf95f2021-04-14 08:54:05 +03005131
5132 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005133 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005134 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005135 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005136
5137 // Check subscription
5138 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5139
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005140 mainCtrl.SimulateRestart(t)
5141 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005142
Anssi Mannila54838ed2021-11-19 11:25:01 +02005143 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5144 // That needs to be completed before successful subscription query is possible
5145 <-time.After(time.Second * 1)
5146
archaggeafbf95f2021-04-14 08:54:05 +03005147 // Check subscription
5148 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5149
5150 // Delete subscription
5151 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5152
5153 //Wait that subs is cleaned
5154 waitSubsCleanup(t, e2SubsId, 10)
5155
5156 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005157 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005158}
5159
5160//-----------------------------------------------------------------------------
5161// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5162//
5163// stub stub
5164// +-------+ +-------+ +---------+ +---------+
5165// | xapp2 | | xapp1 | | submgr | | e2term |
5166// +-------+ +-------+ +---------+ +---------+
5167// | | | |
5168// | | RESTSubReq1 | |
5169// | |---------------->| |
5170// | | | |
5171// | | RESTSubResp1 | |
5172// | |<----------------| |
5173// | | | |
5174// | | | SubReq1 |
5175// | | |------------->|
5176// | | | SubResp1 |
5177// | | |<-------------|
5178// | | RESTNotif1 | |
5179// | |<----------------| |
5180// | | | |
5181// | RESTSubReq2 | |
5182// |------------------------------>| |
5183// | | | |
5184// | RESTSubResp2 | |
5185// |<------------------------------| |
5186// | | | |
5187// | | RESTNotif2 | |
5188// |<------------------------------| |
5189// | | | |
5190// | | Submgr restart |
5191// | | | |
5192// | | RESTSubDelReq1 | |
5193// | |---------------->| |
5194// | | | |
5195// | | RESTSubDelResp1 | |
5196// | |<----------------| |
5197// | | | |
5198// | | Submgr restart |
5199// | | | |
5200// | RESTSubDelReq2 | |
5201// |------------------------------>| |
5202// | | | |
5203// | RESTSubDelResp2 | |
5204// |<------------------------------| |
5205// | | | |
5206// | | | SubDelReq2 |
5207// | | |------------->|
5208// | | | |
5209// | | | SubDelResp2 |
5210// | | |<-------------|
5211// | | | |
5212//
5213//-----------------------------------------------------------------------------
5214func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5215 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5216
5217 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005218 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005219 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005220 Counter{cSubReqToE2, 1},
5221 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005222 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005223 Counter{cMergedSubscriptions, 1},
5224 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005225 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005226 Counter{cSubDelReqToE2, 1},
5227 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005228 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005229 })
5230
archaggeafbf95f2021-04-14 08:54:05 +03005231 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005232 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005233 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005234 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005235
5236 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005237 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005238 params.SetMeid("RAN_NAME_1")
5239 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005240 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005241 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005242 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005243 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005244 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005245
5246 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5247
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005248 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005249 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5250
5251 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5252 // That needs to be completed before successful subscription delete is possible
5253 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005254
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005255 // Delete subscription 1, and wait until it has removed the first endpoint
5256 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005257 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005258 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005259
Anssi Mannila54838ed2021-11-19 11:25:01 +02005260 // Above wait does not work correctly anymore as this delay makes this test case work
5261 //<-time.After(time.Second * 1)
5262
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005263 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005264 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5265
5266 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5267 // That needs to be completed before successful subscription query is possible
5268 <-time.After(time.Second * 1)
5269
archaggeafbf95f2021-04-14 08:54:05 +03005270 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5271
5272 // Delete subscription 2
5273 deleteXapp2Subscription(t, &restSubId2)
5274
5275 //Wait that subs is cleaned
5276 waitSubsCleanup(t, e2SubsId2, 10)
5277
5278 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005279 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005280}
5281
5282//-----------------------------------------------------------------------------
5283// TestRESTReportSubReqAndSubDelOk
5284//
5285// stub stub
5286// +-------+ +---------+ +---------+
5287// | xapp | | submgr | | e2term |
5288// +-------+ +---------+ +---------+
5289// | | |
5290// | RestSubReq | |
5291// |---------------->| |
5292// | | |
5293// | RESTSubResp | |
5294// |<----------------| |
5295// | | |
5296// | | SubReq |
5297// | |------------->|
5298// | | |
5299// | | SubResp |
5300// | |<-------------|
5301// | RESTNotif | |
5302// |<----------------| |
5303// | | SubReq |
5304// | |------------->|
5305// | | |
5306// | | SubResp |
5307// | |<-------------|
5308// | RESTNotif | |
5309// |<----------------| |
5310// | ... | ... |
5311// | | |
5312// | | |
5313// | RESTSubDelReq | |
5314// |---------------->| |
5315// | | |
5316// | | SubDelReq |
5317// | |------------->|
5318// | | |
5319// | | SubDelResp |
5320// | |<-------------|
5321// | | |
5322// | RESTSubDelResp| |
5323// |<----------------| |
5324//
5325//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005326
archaggeafbf95f2021-04-14 08:54:05 +03005327func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5328 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005329 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005330 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005331 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005332}
5333
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005334func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005335 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005336
5337 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005338 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005339 restSubId := xappConn1.SendRESTSubsReq(t, params)
5340
5341 var e2SubsId []uint32
5342 for i := 0; i < subReqCount; i++ {
5343 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5344 xappConn1.ExpectRESTNotification(t, restSubId)
5345
5346 e2termConn1.SendSubsResp(t, crereq, cremsg)
5347 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005348 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005349 e2SubsId = append(e2SubsId, instanceId)
5350 resp, _ := xapp.Subscription.QuerySubscriptions()
5351 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5352 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5353 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5354
5355 }
5356
5357 // Del
5358 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5359
5360 for i := 0; i < subReqCount; i++ {
5361 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5362 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5363 }
5364
5365 // Wait that subs is cleaned
5366 for i := 0; i < subReqCount; i++ {
5367 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5368 }
5369
5370 xappConn1.TestMsgChanEmpty(t)
5371 e2termConn1.TestMsgChanEmpty(t)
5372 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005373 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005374}
5375
5376/*
Anssi Mannila54838ed2021-11-19 11:25:01 +02005377func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { was in comments already
archaggeafbf95f2021-04-14 08:54:05 +03005378 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5379
5380 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005381 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005382 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005383
5384 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005385 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005386 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005387}
5388*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005389func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005390 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005391
5392 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005393 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005394 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005395
5396 var e2SubsId []uint32
5397 for i := 0; i < subReqCount; i++ {
5398 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5399 xappConn1.ExpectRESTNotification(t, restSubId)
5400 e2termConn1.SendSubsResp(t, crereq, cremsg)
5401 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005402 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005403 e2SubsId = append(e2SubsId, instanceId)
5404 }
5405
5406 // Del
5407 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5408
5409 for i := 0; i < subReqCount; i++ {
5410 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5411 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5412 }
5413
5414 // Wait that subs is cleaned
5415 for i := 0; i < subReqCount; i++ {
5416 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5417 }
5418 xappConn1.TestMsgChanEmpty(t)
5419 e2termConn1.TestMsgChanEmpty(t)
5420 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005421 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005422}
5423
archaggeafbf95f2021-04-14 08:54:05 +03005424func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5425
archaggeafbf95f2021-04-14 08:54:05 +03005426 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005427 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005428 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005429 Counter{cSubReqToE2, 2},
5430 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005431 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005432 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005433 Counter{cSubDelReqToE2, 2},
5434 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005435 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005436 })
5437
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005438 const subReqCount int = 2
5439
archaggeafbf95f2021-04-14 08:54:05 +03005440 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005441 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005442 restSubId := xappConn1.SendRESTSubsReq(t, params)
5443 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5444
5445 assert.Equal(t, len(e2SubsIds), 2)
5446
5447 // Del
5448 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5449 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5450
5451 xappConn1.TestMsgChanEmpty(t)
5452 e2termConn1.TestMsgChanEmpty(t)
5453 mainCtrl.wait_registry_empty(t, 10)
5454
5455 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005456 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005457}
archaggeafbf95f2021-04-14 08:54:05 +03005458func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5459
archaggeafbf95f2021-04-14 08:54:05 +03005460 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005461 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005462 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005463 Counter{cSubReqToE2, 19},
5464 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005465 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005466 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005467 Counter{cSubDelReqToE2, 19},
5468 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005469 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005470 })
5471
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005472 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005473 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005474 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005475 restSubId := xappConn1.SendRESTSubsReq(t, params)
5476 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5477
5478 assert.Equal(t, len(e2SubsIds), 19)
5479
5480 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5481 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5482
5483 xappConn1.TestMsgChanEmpty(t)
5484 e2termConn1.TestMsgChanEmpty(t)
5485 mainCtrl.wait_registry_empty(t, 10)
5486
5487 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005488 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005489}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005490
archaggeafbf95f2021-04-14 08:54:05 +03005491func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5492
5493 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005494
5495 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005496 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005497 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005498 Counter{cSubReqToE2, uint64(subReqCount)},
5499 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005500 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005501 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005502 Counter{cSubDelReqToE2, uint64(subReqCount)},
5503 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005504 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005505 })
5506
5507 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005508 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005509 restSubId := xappConn1.SendRESTSubsReq(t, params)
5510 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5511
5512 assert.Equal(t, len(e2SubsIds), subReqCount)
5513
5514 // Del
5515 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5516 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5517
5518 xappConn1.TestMsgChanEmpty(t)
5519 e2termConn1.TestMsgChanEmpty(t)
5520 mainCtrl.wait_registry_empty(t, 10)
5521
5522 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005523 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005524}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005525
archaggeafbf95f2021-04-14 08:54:05 +03005526func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5527
5528 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005529
5530 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005531 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005532 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005533 Counter{cSubReqToE2, uint64(subReqCount)},
5534 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005535 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005536 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005537 Counter{cSubDelReqToE2, uint64(subReqCount)},
5538 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005539 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005540 })
5541
5542 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005543 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005544 restSubId := xappConn1.SendRESTSubsReq(t, params)
5545 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5546
5547 assert.Equal(t, len(e2SubsIds), subReqCount)
5548
5549 // Del
5550 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5551 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5552
5553 xappConn1.TestMsgChanEmpty(t)
5554 e2termConn1.TestMsgChanEmpty(t)
5555 mainCtrl.wait_registry_empty(t, 10)
5556
5557 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005558 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005559}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005560
archaggeafbf95f2021-04-14 08:54:05 +03005561func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5562
5563 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005564
5565 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005566 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005567 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005568 Counter{cSubReqToE2, uint64(subReqCount)},
5569 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005570 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005571 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005572 Counter{cSubDelReqToE2, uint64(subReqCount)},
5573 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005574 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005575 })
5576
5577 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005578 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005579 restSubId := xappConn1.SendRESTSubsReq(t, params)
5580 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5581
5582 assert.Equal(t, len(e2SubsIds), subReqCount)
5583
5584 // Del
5585 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5586 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5587
5588 xappConn1.TestMsgChanEmpty(t)
5589 e2termConn1.TestMsgChanEmpty(t)
5590 mainCtrl.wait_registry_empty(t, 10)
5591
5592 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005593 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005594}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005595
5596func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5597 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5598
5599 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005600 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005601 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005602 Counter{cSubReqToE2, 2},
5603 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005604 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005605 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005606 Counter{cSubDelReqToE2, 2},
5607 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005608 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005609 })
5610
5611 // Req1
5612 var params *teststube2ap.RESTSubsReqParams = nil
5613
5614 //Subs Create
5615 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005616 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005617
5618 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5619
5620 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005621 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005622 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005623 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005624 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5625
5626 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005627 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005628 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5629 xappConn2.ExpectRESTNotification(t, restSubId2)
5630 e2termConn1.SendSubsResp(t, crereq, cremsg)
5631 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5632
5633 deleteXapp1Subscription(t, &restSubId1)
5634 deleteXapp2Subscription(t, &restSubId2)
5635
5636 waitSubsCleanup(t, e2SubsId1, 10)
5637 waitSubsCleanup(t, e2SubsId2, 10)
5638
5639 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005640 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005641}
5642
5643func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5644 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5645
5646 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005647 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005648 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005649 Counter{cSubReqToE2, 2},
5650 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005651 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005652 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005653 Counter{cSubDelReqToE2, 2},
5654 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005655 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005656 })
5657
5658 // Req1
5659 var params *teststube2ap.RESTSubsReqParams = nil
5660
5661 //Subs Create
5662 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005663 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005664
5665 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5666
5667 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005668 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005669 params.SetMeid("RAN_NAME_1")
5670
5671 actionId := int64(1)
5672 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005673 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005674 subsequestActionType := "continue"
5675 timeToWait := "w10ms"
5676 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5677
5678 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005679 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005680 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5681 xappConn2.ExpectRESTNotification(t, restSubId2)
5682 e2termConn1.SendSubsResp(t, crereq, cremsg)
5683 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5684
5685 deleteXapp1Subscription(t, &restSubId1)
5686 deleteXapp2Subscription(t, &restSubId2)
5687
5688 waitSubsCleanup(t, e2SubsId1, 10)
5689 waitSubsCleanup(t, e2SubsId2, 10)
5690
5691 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005692 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005693}
5694
5695func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5696 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5697
5698 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005699 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005700 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005701 Counter{cSubReqToE2, 2},
5702 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005703 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005704 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005705 Counter{cSubDelReqToE2, 2},
5706 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005707 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005708 })
5709
5710 // Req1
5711 var params *teststube2ap.RESTSubsReqParams = nil
5712
5713 //Subs Create
5714 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005715 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005716
5717 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5718
5719 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005720 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005721 params.SetMeid("RAN_NAME_1")
5722 params.SetSubActionIDs(int64(2))
5723
5724 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005725 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005726 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5727 xappConn2.ExpectRESTNotification(t, restSubId2)
5728 e2termConn1.SendSubsResp(t, crereq, cremsg)
5729 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5730
5731 deleteXapp1Subscription(t, &restSubId1)
5732 deleteXapp2Subscription(t, &restSubId2)
5733
5734 waitSubsCleanup(t, e2SubsId1, 10)
5735 waitSubsCleanup(t, e2SubsId2, 10)
5736
5737 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005738 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005739}
5740
5741func TestRESTSubReqDiffActionType(t *testing.T) {
5742 CaseBegin("TestRESTSubReqDiffActionType")
5743
5744 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005745 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005746 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005747 Counter{cSubReqToE2, 2},
5748 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005749 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005750 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005751 Counter{cSubDelReqToE2, 2},
5752 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005753 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005754 })
5755
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005756 const e2Timeout int64 = 2
5757 const e2RetryCount int64 = 2
5758 const routingNeeded bool = true
5759
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005760 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005761 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005762 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005763
5764 //Subs Create
5765 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005766 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005767
5768 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5769
5770 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005771 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005772 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005773 params.SetMeid("RAN_NAME_1")
5774
5775 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005776 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005777 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5778 xappConn2.ExpectRESTNotification(t, restSubId2)
5779 e2termConn1.SendSubsResp(t, crereq, cremsg)
5780 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5781
5782 deleteXapp1Subscription(t, &restSubId1)
5783 deleteXapp2Subscription(t, &restSubId2)
5784
5785 waitSubsCleanup(t, e2SubsId1, 10)
5786 waitSubsCleanup(t, e2SubsId2, 10)
5787
5788 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005789 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005790}
5791
5792func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5793 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5794
5795 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005796 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005797 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005798 Counter{cSubReqToE2, 2},
5799 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005800 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005801 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005802 Counter{cSubDelReqToE2, 2},
5803 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005804 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005805 })
5806
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005807 const e2Timeout int64 = 2
5808 const e2RetryCount int64 = 2
5809 const routingNeeded bool = true
5810
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005811 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005812 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005813 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005814
5815 //Subs Create
5816 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005817 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005818
5819 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5820
5821 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005822 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005823 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005824 params.SetMeid("RAN_NAME_1")
5825
5826 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005827 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005828 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5829 xappConn2.ExpectRESTNotification(t, restSubId2)
5830 e2termConn1.SendSubsResp(t, crereq, cremsg)
5831 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5832
5833 deleteXapp1Subscription(t, &restSubId1)
5834 deleteXapp2Subscription(t, &restSubId2)
5835
5836 waitSubsCleanup(t, e2SubsId1, 10)
5837 waitSubsCleanup(t, e2SubsId2, 10)
5838
5839 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005840 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005841}
5842
5843func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5844 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5845
5846 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005847 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005848 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005849 Counter{cSubReqToE2, 2},
5850 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005851 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005852 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005853 Counter{cSubDelReqToE2, 2},
5854 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005855 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005856 })
5857
5858 // Req1
5859 var params *teststube2ap.RESTSubsReqParams = nil
5860
5861 //Subs Create
5862 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005863 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005864
5865 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5866
5867 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005868 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005869 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005870 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005871 params.SetSubActionDefinition(actionDefinition)
5872
5873 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005874 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005875 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5876 xappConn2.ExpectRESTNotification(t, restSubId2)
5877 e2termConn1.SendSubsResp(t, crereq, cremsg)
5878 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5879
5880 deleteXapp1Subscription(t, &restSubId1)
5881 deleteXapp2Subscription(t, &restSubId2)
5882
5883 waitSubsCleanup(t, e2SubsId1, 10)
5884 waitSubsCleanup(t, e2SubsId2, 10)
5885
5886 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005887 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005888}
5889
5890func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5891 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5892
5893 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005894 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005895 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005896 Counter{cSubReqToE2, 2},
5897 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005898 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005899 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005900 Counter{cSubDelReqToE2, 2},
5901 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005902 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005903 })
5904
5905 // Req1
5906 var params *teststube2ap.RESTSubsReqParams = nil
5907
5908 //Subs Create
5909 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005910 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005911
5912 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5913
5914 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005915 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005916 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005917 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005918 params.SetSubActionDefinition(actionDefinition)
5919
5920 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005921 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005922 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5923 xappConn2.ExpectRESTNotification(t, restSubId2)
5924 e2termConn1.SendSubsResp(t, crereq, cremsg)
5925 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5926
5927 deleteXapp1Subscription(t, &restSubId1)
5928 deleteXapp2Subscription(t, &restSubId2)
5929
5930 waitSubsCleanup(t, e2SubsId1, 10)
5931 waitSubsCleanup(t, e2SubsId2, 10)
5932
5933 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005934 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005935}
5936
5937func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5938 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5939
5940 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005941 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005942 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005943 Counter{cSubReqToE2, 2},
5944 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005945 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005946 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005947 Counter{cSubDelReqToE2, 2},
5948 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005949 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005950 })
5951
5952 // Req1
5953 var params *teststube2ap.RESTSubsReqParams = nil
5954
5955 //Subs Create
5956 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005957 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005958
5959 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5960
5961 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005962 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005963 params.SetMeid("RAN_NAME_1")
5964 params.SetTimeToWait("w200ms")
5965 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005966 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005967 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5968 xappConn2.ExpectRESTNotification(t, restSubId2)
5969 e2termConn1.SendSubsResp(t, crereq, cremsg)
5970 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5971
5972 deleteXapp1Subscription(t, &restSubId1)
5973 deleteXapp2Subscription(t, &restSubId2)
5974
5975 waitSubsCleanup(t, e2SubsId1, 10)
5976 waitSubsCleanup(t, e2SubsId2, 10)
5977
5978 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005979 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005980}
5981
Anssi Mannila51122392021-05-25 11:51:31 +03005982//-----------------------------------------------------------------------------
5983// TestRESTUnpackSubscriptionResponseDecodeFail
5984//
5985// stub stub
5986// +-------+ +---------+ +---------+
5987// | xapp | | submgr | | e2term |
5988// +-------+ +---------+ +---------+
5989// | | |
5990// | RestSubReq | |
5991// |---------------->| |
5992// | | |
5993// | RESTSubResp | |
5994// |<----------------| |
5995// | | |
5996// | | SubReq |
5997// | |------------->|
5998// | | |
5999// | | SubResp | ASN.1 decode fails
6000// | |<-------------|
6001// | | |
6002// | | SubReq |
6003// | |------------->|
6004// | | |
6005// | | SubFail | Duplicated action
6006// | |<-------------|
6007// | RESTNotif (fail)| |
6008// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006009// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006010//
6011//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006012
Anssi Mannila51122392021-05-25 11:51:31 +03006013func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006014 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
6015 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006016
6017 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006018 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006019 restSubId := xappConn1.SendRESTSubsReq(t, params)
6020
6021 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6022 // Decode of this response fails which will result resending original request
6023 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6024
6025 _, cremsg = e2termConn1.RecvSubsReq(t)
6026
Markku Virtanen55d2a282021-06-04 14:46:56 +03006027 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006028
6029 // Subscription already created in E2 Node.
6030 fparams := &teststube2ap.E2StubSubsFailParams{}
6031 fparams.Set(crereq)
6032 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6033 e2termConn1.SendSubsFail(t, fparams, cremsg)
6034
Anssi Mannila51122392021-05-25 11:51:31 +03006035 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006036 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006037
Anssi Mannilab43397e2021-11-16 12:06:16 +02006038 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6039
Anssi Mannila51122392021-05-25 11:51:31 +03006040 // Wait that subs is cleaned
6041 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6042
6043 xappConn1.TestMsgChanEmpty(t)
6044 e2termConn1.TestMsgChanEmpty(t)
6045 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006046 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006047}
6048
6049//-----------------------------------------------------------------------------
6050// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6051//
6052// stub stub
6053// +-------+ +---------+ +---------+
6054// | xapp | | submgr | | e2term |
6055// +-------+ +---------+ +---------+
6056// | | |
6057// | RestSubReq | |
6058// |---------------->| |
6059// | | |
6060// | RESTSubResp | |
6061// |<----------------| |
6062// | | |
6063// | | SubReq |
6064// | |------------->|
6065// | | |
6066// | | SubResp | Unknown instanceId
6067// | |<-------------|
6068// | | |
6069// | | SubReq |
6070// | |------------->|
6071// | | |
6072// | | SubFail | Duplicated action
6073// | |<-------------|
6074// | RESTNotif (fail)| |
6075// |<----------------| |
6076// | | SubDelReq |
6077// | |------------->|
6078// | | |
6079// | | SubDelResp |
6080// | |<-------------|
6081//
6082//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006083
Anssi Mannila51122392021-05-25 11:51:31 +03006084func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006085 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6086 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006087
6088 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006089 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006090 restSubId := xappConn1.SendRESTSubsReq(t, params)
6091
6092 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6093
6094 // Unknown instanceId in this response which will result resending original request
6095 orgInstanceId := crereq.RequestId.InstanceId
6096 crereq.RequestId.InstanceId = 0
6097 e2termConn1.SendSubsResp(t, crereq, cremsg)
6098
6099 _, cremsg = e2termConn1.RecvSubsReq(t)
6100
Markku Virtanen55d2a282021-06-04 14:46:56 +03006101 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006102
6103 // Subscription already created in E2 Node.
6104 fparams := &teststube2ap.E2StubSubsFailParams{}
6105 fparams.Set(crereq)
6106 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6107 e2termConn1.SendSubsFail(t, fparams, cremsg)
6108
6109 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6110 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6111
6112 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006113 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006114
Anssi Mannilab43397e2021-11-16 12:06:16 +02006115 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6116
Anssi Mannila51122392021-05-25 11:51:31 +03006117 // Wait that subs is cleaned
6118 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6119
6120 xappConn1.TestMsgChanEmpty(t)
6121 e2termConn1.TestMsgChanEmpty(t)
6122 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006123 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006124}
6125
6126//-----------------------------------------------------------------------------
6127// TestRESTUnpackSubscriptionResponseNoTransaction
6128//
6129// stub stub
6130// +-------+ +---------+ +---------+
6131// | xapp | | submgr | | e2term |
6132// +-------+ +---------+ +---------+
6133// | | |
6134// | RestSubReq | |
6135// |---------------->| |
6136// | | |
6137// | RESTSubResp | |
6138// |<----------------| |
6139// | | |
6140// | | SubReq |
6141// | |------------->|
6142// | | |
6143// | | SubResp | No transaction for the response
6144// | |<-------------|
6145// | | |
6146// | | SubReq |
6147// | |------------->|
6148// | | |
6149// | | SubFail | Duplicated action
6150// | |<-------------|
6151// | RESTNotif (fail)| |
6152// |<----------------| |
6153// | | SubDelReq |
6154// | |------------->|
6155// | | |
6156// | | SubDelResp |
6157// | |<-------------|
6158// | | |
6159// | | SubDelReq |
6160// | |------------->|
6161// | | |
6162// | | SubDelResp |
6163// | |<-------------|
6164//
6165//-----------------------------------------------------------------------------
6166func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006167 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6168 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006169
6170 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006171 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006172 restSubId := xappConn1.SendRESTSubsReq(t, params)
6173
6174 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6175
6176 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6177 // No transaction exist for this response which will result resending original request
6178 e2termConn1.SendSubsResp(t, crereq, cremsg)
6179
6180 _, cremsg = e2termConn1.RecvSubsReq(t)
6181
Markku Virtanen55d2a282021-06-04 14:46:56 +03006182 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006183
6184 // Subscription already created in E2 Node.
6185 fparams := &teststube2ap.E2StubSubsFailParams{}
6186 fparams.Set(crereq)
6187 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6188 e2termConn1.SendSubsFail(t, fparams, cremsg)
6189
6190 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6191 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6192
6193 // Resending happens because there no transaction
6194 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6195 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6196
6197 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006198 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006199
Anssi Mannilab43397e2021-11-16 12:06:16 +02006200 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6201
Anssi Mannila51122392021-05-25 11:51:31 +03006202 // Wait that subs is cleaned
6203 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6204
6205 xappConn1.TestMsgChanEmpty(t)
6206 e2termConn1.TestMsgChanEmpty(t)
6207 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006208 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006209}
6210
6211//-----------------------------------------------------------------------------
6212// TestRESTUnpackSubscriptionFailureDecodeFail
6213//
6214// stub stub
6215// +-------+ +---------+ +---------+
6216// | xapp | | submgr | | e2term |
6217// +-------+ +---------+ +---------+
6218// | | |
6219// | RestSubReq | |
6220// |---------------->| |
6221// | | |
6222// | RESTSubResp | |
6223// |<----------------| |
6224// | | |
6225// | | SubReq |
6226// | |------------->|
6227// | | |
6228// | | SubFail | ASN.1 decode fails
6229// | |<-------------|
6230// | | |
6231// | | SubReq |
6232// | |------------->|
6233// | | |
6234// | | SubFail | Duplicated action
6235// | |<-------------|
6236// | RESTNotif (fail)| |
6237// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006238// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006239//
6240//-----------------------------------------------------------------------------
6241func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006242 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6243 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006244
6245 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006246 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006247 restSubId := xappConn1.SendRESTSubsReq(t, params)
6248
6249 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6250
6251 // Decode of this response fails which will result resending original request
6252 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6253
6254 _, cremsg = e2termConn1.RecvSubsReq(t)
6255
Markku Virtanen55d2a282021-06-04 14:46:56 +03006256 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006257
6258 // Subscription already created in E2 Node.
6259 fparams := &teststube2ap.E2StubSubsFailParams{}
6260 fparams.Set(crereq)
6261 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6262 e2termConn1.SendSubsFail(t, fparams, cremsg)
6263
Anssi Mannila51122392021-05-25 11:51:31 +03006264 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006265 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006266
Anssi Mannilab43397e2021-11-16 12:06:16 +02006267 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6268
Anssi Mannila51122392021-05-25 11:51:31 +03006269 // Wait that subs is cleaned
6270 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6271
6272 xappConn1.TestMsgChanEmpty(t)
6273 e2termConn1.TestMsgChanEmpty(t)
6274 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006275 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006276}
6277
6278//-----------------------------------------------------------------------------
6279// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6280//
6281// stub stub
6282// +-------+ +---------+ +---------+
6283// | xapp | | submgr | | e2term |
6284// +-------+ +---------+ +---------+
6285// | | |
6286// | RestSubReq | |
6287// |---------------->| |
6288// | | |
6289// | RESTSubResp | |
6290// |<----------------| |
6291// | | |
6292// | | SubReq |
6293// | |------------->|
6294// | | |
6295// | | SubFail | Unknown instanceId
6296// | |<-------------|
6297// | | |
6298// | | SubReq |
6299// | |------------->|
6300// | | |
6301// | | SubFail | Duplicated action
6302// | |<-------------|
6303// | RESTNotif (fail)| |
6304// |<----------------| |
6305// | | SubDelReq |
6306// | |------------->|
6307// | | |
6308// | | SubDelResp |
6309// | |<-------------|
6310//
6311//-----------------------------------------------------------------------------
6312func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006313 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6314 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006315
6316 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006317 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006318 restSubId := xappConn1.SendRESTSubsReq(t, params)
6319
6320 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6321
6322 // Unknown instanceId in this response which will result resending original request
6323 fparams := &teststube2ap.E2StubSubsFailParams{}
6324 fparams.Set(crereq)
6325 fparams.Fail.RequestId.InstanceId = 0
6326 e2termConn1.SendSubsFail(t, fparams, cremsg)
6327
6328 _, cremsg = e2termConn1.RecvSubsReq(t)
6329
Markku Virtanen55d2a282021-06-04 14:46:56 +03006330 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006331
6332 // Subscription already created in E2 Node.
6333 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6334 e2termConn1.SendSubsFail(t, fparams, cremsg)
6335
6336 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6337 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6338
6339 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006340 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006341
Anssi Mannilab43397e2021-11-16 12:06:16 +02006342 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6343
Anssi Mannila51122392021-05-25 11:51:31 +03006344 // Wait that subs is cleaned
6345 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6346
6347 xappConn1.TestMsgChanEmpty(t)
6348 e2termConn1.TestMsgChanEmpty(t)
6349 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006350 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006351}
6352
6353//-----------------------------------------------------------------------------
6354// TestRESTUnpackSubscriptionFailureNoTransaction
6355//
6356// stub stub
6357// +-------+ +---------+ +---------+
6358// | xapp | | submgr | | e2term |
6359// +-------+ +---------+ +---------+
6360// | | |
6361// | RestSubReq | |
6362// |---------------->| |
6363// | | |
6364// | RESTSubResp | |
6365// |<----------------| |
6366// | | |
6367// | | SubReq |
6368// | |------------->|
6369// | | |
6370// | | SubFail | No transaction for the response
6371// | |<-------------|
6372// | | |
6373// | | SubReq |
6374// | |------------->|
6375// | | |
6376// | | SubFail | Duplicated action
6377// | |<-------------|
6378// | RESTNotif (fail)| |
6379// |<----------------| |
6380// | | SubDelReq |
6381// | |------------->|
6382// | | |
6383// | | SubDelResp |
6384// | |<-------------|
6385//
6386//-----------------------------------------------------------------------------
6387func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006388 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6389 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006390
6391 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006392 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006393 restSubId := xappConn1.SendRESTSubsReq(t, params)
6394
6395 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6396
6397 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6398
6399 // No transaction exist for this response which will result resending original request
6400 fparams := &teststube2ap.E2StubSubsFailParams{}
6401 fparams.Set(crereq)
6402 e2termConn1.SendSubsFail(t, fparams, cremsg)
6403
6404 _, cremsg = e2termConn1.RecvSubsReq(t)
6405
Markku Virtanen55d2a282021-06-04 14:46:56 +03006406 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006407
6408 // Subscription already created in E2 Node.
6409 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6410 e2termConn1.SendSubsFail(t, fparams, cremsg)
6411
6412 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6413 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6414
6415 // Resending happens because there no transaction
6416 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6417 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6418
6419 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006420 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006421
Anssi Mannilab43397e2021-11-16 12:06:16 +02006422 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6423
Anssi Mannila51122392021-05-25 11:51:31 +03006424 // Wait that subs is cleaned
6425 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6426
6427 xappConn1.TestMsgChanEmpty(t)
6428 e2termConn1.TestMsgChanEmpty(t)
6429 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006430 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006431}
6432
6433//-----------------------------------------------------------------------------
6434// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6435//
6436// stub stub
6437// +-------+ +---------+ +---------+
6438// | xapp | | submgr | | e2term |
6439// +-------+ +---------+ +---------+
6440// | | |
6441// | [SUBS CREATE] |
6442// | | |
6443// | | |
6444// | RESTSubDelReq | |
6445// |---------------->| |
6446// | | |
6447// | RESTSubDelResp | |
6448// |<----------------| |
6449// | | |
6450// | | SubDelReq |
6451// | |------------->|
6452// | | |
6453// | | SubDelResp | ASN.1 decode fails
6454// | |<-------------|
6455// | | |
6456// | | SubDelReq |
6457// | |------------->|
6458// | | |
6459// | | SubDelFail | Subscription does exist any more
6460// | |<-------------|
6461// | | |
6462//
6463//-----------------------------------------------------------------------------
6464func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006465 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006466
6467 // Req
6468 var params *teststube2ap.RESTSubsReqParams = nil
6469 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6470
6471 // Del
6472 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6473
6474 // E2t: Receive 1st SubsDelReq
6475 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6476
6477 // Decode of this response fails which will result resending original request
6478 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6479
6480 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6481 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6482
6483 // Subscription does not exist in in E2 Node.
6484 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6485
6486 // Wait that subs is cleaned
6487 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6488
6489 xappConn1.TestMsgChanEmpty(t)
6490 e2termConn1.TestMsgChanEmpty(t)
6491 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006492 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006493}
6494
6495//-----------------------------------------------------------------------------
6496// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6497//
6498// stub stub
6499// +-------+ +---------+ +---------+
6500// | xapp | | submgr | | e2term |
6501// +-------+ +---------+ +---------+
6502// | | |
6503// | [SUBS CREATE] |
6504// | | |
6505// | | |
6506// | RESTSubDelReq | |
6507// |---------------->| |
6508// | | |
6509// | RESTSubDelResp | |
6510// |<----------------| |
6511// | | |
6512// | | SubDelReq |
6513// | |------------->|
6514// | | |
6515// | | SubDelResp | Unknown instanceId
6516// | |<-------------|
6517// | | |
6518// | | SubDelReq |
6519// | |------------->|
6520// | | |
6521// | | SubDelFail | Subscription does exist any more
6522// | |<-------------|
6523//
6524//-----------------------------------------------------------------------------
6525func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006526 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006527
6528 // Req
6529 var params *teststube2ap.RESTSubsReqParams = nil
6530 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6531
6532 // Del
6533 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6534
6535 // E2t: Receive 1st SubsDelReq
6536 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6537
6538 // Unknown instanceId in this response which will result resending original request
6539 delreq.RequestId.InstanceId = 0
6540 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6541
6542 // E2t: Receive 2nd SubsDelReq
6543 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6544
6545 // Subscription does not exist in in E2 Node.
6546 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6547
6548 // Wait that subs is cleaned
6549 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6550
6551 xappConn1.TestMsgChanEmpty(t)
6552 e2termConn1.TestMsgChanEmpty(t)
6553 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006554 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006555}
6556
6557//-----------------------------------------------------------------------------
6558// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6559//
6560// stub stub
6561// +-------+ +---------+ +---------+
6562// | xapp | | submgr | | e2term |
6563// +-------+ +---------+ +---------+
6564// | | |
6565// | [SUBS CREATE] |
6566// | | |
6567// | | |
6568// | RESTSubDelReq | |
6569// |---------------->| |
6570// | | |
6571// | RESTSubDelResp | |
6572// |<----------------| |
6573// | | |
6574// | | SubDelReq |
6575// | |------------->|
6576// | | |
6577// | | SubDelResp | No transaction for the response
6578// | |<-------------|
6579// | | |
6580// | | SubDelReq |
6581// | |------------->|
6582// | | |
6583// | | SubDelFail | Subscription does exist any more
6584// | |<-------------|
6585//
6586//-----------------------------------------------------------------------------
6587func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006588 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006589
6590 // Req
6591 var params *teststube2ap.RESTSubsReqParams = nil
6592 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6593
6594 // Del
6595 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6596
6597 // E2t: Receive 1st SubsDelReq
6598 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6599
6600 mainCtrl.MakeTransactionNil(t, e2SubsId)
6601
6602 // No transaction exist for this response which will result resending original request
6603 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6604
6605 // E2t: Receive 2nd SubsDelReq
6606 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6607
6608 // Subscription does not exist in in E2 Node.
6609 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6610
6611 // Wait that subs is cleaned
6612 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6613
6614 xappConn1.TestMsgChanEmpty(t)
6615 e2termConn1.TestMsgChanEmpty(t)
6616 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006617 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006618}
6619
6620//-----------------------------------------------------------------------------
6621// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6622//
6623// stub stub
6624// +-------+ +---------+ +---------+
6625// | xapp | | submgr | | e2term |
6626// +-------+ +---------+ +---------+
6627// | | |
6628// | [SUBS CREATE] |
6629// | | |
6630// | | |
6631// | RESTSubDelReq | |
6632// |---------------->| |
6633// | | |
6634// | RESTSubDelResp | |
6635// |<----------------| |
6636// | | |
6637// | | SubDelReq |
6638// | |------------->|
6639// | | |
6640// | | SubDelFail | ASN.1 decode fails
6641// | |<-------------|
6642// | | |
6643// | | SubDelReq |
6644// | |------------->|
6645// | | |
6646// | | SubDelFail | Subscription does exist any more
6647// | |<-------------|
6648//
6649//-----------------------------------------------------------------------------
6650func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006651 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006652
6653 // Req
6654 var params *teststube2ap.RESTSubsReqParams = nil
6655 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6656
6657 // Del
6658 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6659
6660 // E2t: Receive 1st SubsDelReq
6661 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6662
6663 // Decode of this response fails which will result resending original request
6664 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6665
6666 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6667 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6668
6669 // Subscription does not exist in in E2 Node.
6670 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6671
6672 // Wait that subs is cleaned
6673 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6674
6675 xappConn1.TestMsgChanEmpty(t)
6676 e2termConn1.TestMsgChanEmpty(t)
6677 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006678 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006679}
6680
6681//-----------------------------------------------------------------------------
6682// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6683//
6684// stub stub
6685// +-------+ +---------+ +---------+
6686// | xapp | | submgr | | e2term |
6687// +-------+ +---------+ +---------+
6688// | | |
6689// | [SUBS CREATE] |
6690// | | |
6691// | | |
6692// | RESTSubDelReq | |
6693// |---------------->| |
6694// | | |
6695// | RESTSubDelResp | |
6696// |<----------------| |
6697// | | |
6698// | | SubDelReq |
6699// | |------------->|
6700// | | |
6701// | | SubDelFail | Unknown instanceId
6702// | |<-------------|
6703// | | |
6704// | | SubDelReq |
6705// | |------------->|
6706// | | |
6707// | | SubDelFail | Subscription does exist any more
6708// | |<-------------|
6709//
6710//-----------------------------------------------------------------------------
6711func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006712 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006713
6714 // Req
6715 var params *teststube2ap.RESTSubsReqParams = nil
6716 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6717
6718 // Del
6719 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6720
6721 // E2t: Receive 1st SubsDelReq
6722 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6723
6724 // Unknown instanceId in this response which will result resending original request
6725 delreq.RequestId.InstanceId = 0
6726 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6727
6728 // E2t: Receive 2nd SubsDelReq
6729 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6730
6731 // Subscription does not exist in in E2 Node.
6732 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6733
6734 // Wait that subs is cleaned
6735 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6736
6737 xappConn1.TestMsgChanEmpty(t)
6738 e2termConn1.TestMsgChanEmpty(t)
6739 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006740 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006741}
6742
6743//-----------------------------------------------------------------------------
6744// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6745//
6746// stub stub
6747// +-------+ +---------+ +---------+
6748// | xapp | | submgr | | e2term |
6749// +-------+ +---------+ +---------+
6750// | | |
6751// | [SUBS CREATE] |
6752// | | |
6753// | | |
6754// | RESTSubDelReq | |
6755// |---------------->| |
6756// | | |
6757// | RESTSubDelResp | |
6758// |<----------------| |
6759// | | |
6760// | | SubDelReq |
6761// | |------------->|
6762// | | |
6763// | | SubDelFail | No transaction for the response
6764// | |<-------------|
6765// | | |
6766// | | SubDelReq |
6767// | |------------->|
6768// | | |
6769// | | SubDelFail | Subscription does exist any more
6770// | |<-------------|
6771//
6772//-----------------------------------------------------------------------------
6773func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006774 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006775
6776 // Req
6777 var params *teststube2ap.RESTSubsReqParams = nil
6778 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6779
6780 // Del
6781 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6782
6783 // E2t: Receive 1st SubsDelReq
6784 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6785
6786 mainCtrl.MakeTransactionNil(t, e2SubsId)
6787
6788 // No transaction exist for this response which will result resending original request
6789 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6790
6791 // E2t: Receive 2nd SubsDelReq
6792 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6793
6794 // Subscription does not exist in in E2 Node.
6795 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6796
6797 // Wait that subs is cleaned
6798 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6799
6800 xappConn1.TestMsgChanEmpty(t)
6801 e2termConn1.TestMsgChanEmpty(t)
6802 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006803 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006804}
6805
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006806//-----------------------------------------------------------------------------
6807// TestRESTSubReqFailAsn1PackSubReqError
6808//
6809// stub stub
6810// +-------+ +---------+ +---------+
6811// | xapp | | submgr | | e2term |
6812// +-------+ +---------+ +---------+
6813// | | |
6814// | RESTSubReq | |
6815// |---------------->| |
6816// | | |
6817// | RESTSubResp | |
6818// |<----------------| |
6819// | | |
6820// | ASN.1 encode fails |
6821// | | |
6822// | | SubDelReq |
6823// | |------------->|
6824// | | |
6825// | | SubDelFail |
6826// | |<-------------|
6827// | | |
6828// | RESTNotif | |
6829// | unsuccess | |
6830// |<----------------| |
6831// | | |
6832// | [SUBS DELETE] |
6833// | | |
6834//
6835//-----------------------------------------------------------------------------
6836func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6837
6838 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006839 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006840 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006841 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006842 Counter{cRestSubDelReqFromXapp, 1},
6843 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006844 })
6845
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006846 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006847
6848 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006849 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006850 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6851
6852 // Req
6853 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006854 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006855
6856 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006857 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006858
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006859 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006860 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006861
6862 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006863
6864 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6865
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006866 // Wait that subs is cleaned
6867 waitSubsCleanup(t, e2SubsId, 10)
6868 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006869 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006870}
6871
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006872func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6873 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6874
6875 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6876 Counter{cRestSubReqFromXapp, 2},
6877 Counter{cRestSubRespToXapp, 2},
6878 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006879 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006880 Counter{cSubRespFromE2, 1},
6881 Counter{cRestSubNotifToXapp, 1},
6882 Counter{cRestSubFailNotifToXapp, 1},
6883 Counter{cRestSubDelReqFromXapp, 1},
6884 Counter{cSubDelReqToE2, 1},
6885 Counter{cSubDelRespFromE2, 1},
6886 Counter{cRestSubDelRespToXapp, 1},
6887 })
6888
6889 const e2Timeout int64 = 1
6890 const e2RetryCount int64 = 0
6891 const routingNeeded bool = false
6892
6893 // Req1
6894 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6895 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6896
6897 // Subs Create
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)
6903 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6904 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6905 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6906
6907 // Policy change
6908 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6909 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6910 params.SetSubscriptionID(&restSubId)
6911 params.SetTimeToWait("w200ms")
6912 restSubId = xappConn1.SendRESTSubsReq(t, params)
6913 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6914
6915 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6916 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006917 // SubsResp is missing, e2SubsId will be 0
6918 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6919 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006920
6921 // Del
6922 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6923 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6924 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6925
6926 waitSubsCleanup(t, e2SubsId, 10)
6927
6928 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006929 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006930}
6931
6932//-----------------------------------------------------------------------------
6933// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6934//
6935// stub stub
6936// +-------+ +---------+ +---------+
6937// | xapp | | submgr | | e2term |
6938// +-------+ +---------+ +---------+
6939// | | |
6940// | RESTSubReq | |
6941// |---------------->| |
6942// | | |
6943// | RESTSubResp | |
6944// |<----------------| |
6945// | | SubReq |
6946// | |------------->|
6947// | | |
6948// | | SubResp |
6949// | |<-------------|
6950// | | |
6951// | RESTNotif | |
6952// |<----------------| |
6953// | | |
6954// | RESTSubReq | |
6955// |---------------->| |
6956// | | |
6957// | RESTSubResp | |
6958// |<----------------| |
6959// | | SubReq |
6960// | |------------->|
6961// | |
6962// | Submgr restart |
6963// | | |
6964// | RESTSubDelReq | |
6965// |---------------->| |
6966// | | |
6967// | | SubDelReq |
6968// | |------------->|
6969// | | |
6970// | | SubDelResp |
6971// | |<-------------|
6972// | | |
6973// | RESTSubDelResp | |
6974// |<----------------| |
6975//
6976//-----------------------------------------------------------------------------
6977
6978func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6979 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6980
6981 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6982 Counter{cRestSubReqFromXapp, 2},
6983 Counter{cRestSubRespToXapp, 2},
6984 Counter{cSubReqToE2, 2},
6985 Counter{cSubRespFromE2, 1},
6986 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006987 Counter{cRestSubDelReqFromXapp, 1},
6988 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006989 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006990 Counter{cRestSubDelRespToXapp, 1},
6991 })
6992
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006993 const e2Timeout int64 = 1
6994 const e2RetryCount int64 = 0
6995 const routingNeeded bool = false
6996
6997 // Req1
6998 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6999 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7000 // Create subscription
7001 restSubId := xappConn1.SendRESTSubsReq(t, params)
7002 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7003
7004 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7005 xappConn1.ExpectRESTNotification(t, restSubId)
7006 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7007 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7008 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7009
7010 // Check subscription
7011 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7012
7013 // Policy change
7014 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7015 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7016 params.SetSubscriptionID(&restSubId)
7017 params.SetTimeToWait("w200ms")
7018 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7019 restSubId = xappConn1.SendRESTSubsReq(t, params)
7020 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7021
7022 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7023 mainCtrl.SetResetTestFlag(t, false)
7024
7025 // SubsResp is missing due to submgr restart
7026
7027 mainCtrl.SimulateRestart(t)
7028 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7029
Anssi Mannila54838ed2021-11-19 11:25:01 +02007030 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
7031 // That needs to be completed before successful subscription query is possible
7032 <-time.After(time.Second * 1)
7033
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007034 // Check subscription
7035 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7036
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007037 // Delete subscription
7038 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7039 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7040 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7041
7042 //Wait that subs is cleaned
7043 waitSubsCleanup(t, e2SubsId, 10)
7044
7045 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007046 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007047}
7048
archaggeafbf95f2021-04-14 08:54:05 +03007049////////////////////////////////////////////////////////////////////////////////////
7050// Services for UT cases
7051////////////////////////////////////////////////////////////////////////////////////
7052const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007053const host string = "localhost"
7054
7055func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7056 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007057 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007058 }
7059 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007060 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007061
7062 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7063 fromXappConn.ExpectRESTNotification(t, restSubId)
7064 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7065 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007066 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007067
7068 return restSubId, e2SubsId
7069}
7070
7071func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7072
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007073 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007074 if meid != "" {
7075 params.SetMeid(meid)
7076 }
7077 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7078 restSubId := xappConn2.SendRESTSubsReq(t, params)
7079 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007080 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007081 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007082 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007083
7084 return restSubId, e2SubsId
7085}
7086
7087func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007088
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007089 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007090 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007091 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007092
7093 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7094 xappConn1.ExpectRESTNotification(t, restSubId)
7095 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7096 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007097 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007098
7099 return restSubId, e2SubsId
7100}
7101
7102func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007103 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007104 restSubId := xappConn1.SendRESTSubsReq(t, params)
7105
7106 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7107 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7108 fparams1.Set(crereq1)
7109 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7110
7111 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7112 xappConn1.ExpectRESTNotification(t, restSubId)
7113 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7114 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007115 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007116
7117 return restSubId, e2SubsId
7118}
7119
7120func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7121 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7122 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7123 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7124}
7125
7126func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7127 xappConn1.SendRESTSubsDelReq(t, restSubId)
7128 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7129 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7130}
7131
7132func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7133 xappConn2.SendRESTSubsDelReq(t, restSubId)
7134 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7135 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7136}
7137
7138func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7139 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02007140 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
7141 assert.Equal(t, meid, resp[0].Meid)
7142 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03007143}
7144
7145func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7146 //Wait that subs is cleaned
7147 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7148
7149 xappConn1.TestMsgChanEmpty(t)
7150 xappConn2.TestMsgChanEmpty(t)
7151 e2termConn1.TestMsgChanEmpty(t)
7152 mainCtrl.wait_registry_empty(t, timeout)
7153}
7154
7155func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7156
7157 var e2SubsId []uint32
7158
7159 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007160 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007161 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7162 fromXappConn.ExpectRESTNotification(t, restSubId)
7163 toE2termConn.SendSubsResp(t, crereq, cremsg)
7164 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7165 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007166 xapp.Logger.Debug("TEST: %v", e2SubsId)
7167 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007168 <-time.After(100 * time.Millisecond)
7169 }
7170 return e2SubsId
7171}
7172
7173func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7174
7175 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007176 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007177 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7178 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7179 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007180 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007181 <-time.After(100 * time.Millisecond)
7182 }
7183
7184 // Wait that subs is cleaned
7185 for i := 0; i < len(e2SubsIds); i++ {
7186 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7187 }
7188
7189}