blob: 10e10b71c19b8f57ac880734185d5ab4605b5795 [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
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02002986 mainCtrl.WaitOngoingRequestMapEmpty()
2987
Markku Virtanen42723e22021-06-15 10:09:23 +03002988 //1.st resend
2989 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2990
2991 assert.Equal(t, restSubId_resend, restSubId)
2992
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02002993 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03002994
2995 //2.nd resend
2996 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2997
2998 assert.Equal(t, restSubId_resend2, restSubId)
2999
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003000 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003001
3002 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3003
3004 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003005 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003006 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003007}
3008
3009//-----------------------------------------------------------------------------
3010// stub stub stub
3011// +-------+ +---------+ +---------+ +---------+
3012// | xapp | | submgr | | e2term | | rtmgr |
3013// +-------+ +---------+ +---------+ +---------+
3014// | | | |
3015// | RESTSubReq | | |
3016// |---------------->| | |
3017// | RESTSubResp | | |
3018// |<----------------| | |
3019// | | RouteCreate | |
3020// | |--------------------------->|
3021// | | RouteResponse| |
3022// | |<---------------------------| // The order of these events may vary
3023// | | SubReq | |
3024// | |------------->| | // The order of these events may vary
3025// | | SubResp | |
3026// | |<-------------| |
3027// | RESTNotif1 | | |
3028// |<----------------| | |
3029// | RESTSubReq | | |
3030// | [RETRANS, with RESTsubsId] | |
3031// |---------------->| | |
3032// | RESTNotif1 | | |
3033// |<----------------| | |
3034// | RESTSubReq | | |
3035// | [RETRANS, without RESTsubsId] | |
3036// |---------------->| | |
3037// | RESTNotif1 | | |
3038// |<----------------| | |
3039// | RESTSubDelReq | | |
3040// |---------------->| | |
3041// | | SubDelReq | |
3042// | |------------->| |
3043// | RESTSubDelResp| | |
3044// |<----------------| | |
3045// | | SubDelResp | |
3046// | |<-------------| |
3047// | | | |
3048//
3049//-----------------------------------------------------------------------------
3050func TestRESTSubReqRetransmissionV3(t *testing.T) {
3051 CaseBegin("TestRESTSubReqRetransmissionV3")
3052
3053 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3054 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003055 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003056 Counter{cRestSubRespToXapp, 3},
3057 Counter{cSubReqToE2, 1},
3058 Counter{cSubRespFromE2, 1},
3059 Counter{cRestSubNotifToXapp, 3},
3060 Counter{cRestSubDelReqFromXapp, 1},
3061 Counter{cSubDelReqToE2, 1},
3062 Counter{cSubDelRespFromE2, 1},
3063 Counter{cRestSubDelRespToXapp, 1},
3064 })
3065
3066 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3067
3068 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3069
3070 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3071
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003072 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003073
3074 //1.st resend with subscription ID
3075 params.SetSubscriptionID(&restSubId)
3076 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3077
3078 assert.Equal(t, restSubId_resend, restSubId)
3079
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003080 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003081
3082 //2.nd resend without subscription ID (faking app restart)
3083 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3084 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3085
3086 assert.Equal(t, restSubId_resend2, restSubId)
3087
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003088 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003089
3090 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3091
3092 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003093 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003094 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003095}
3096
3097//-----------------------------------------------------------------------------
3098// stub stub stub
3099// +-------+ +---------+ +---------+ +---------+
3100// | xapp | | submgr | | e2term | | rtmgr |
3101// +-------+ +---------+ +---------+ +---------+
3102// | | | |
3103// | RESTSubReq | | |
3104// |---------------->| | |
3105// | RESTSubResp | | |
3106// |<----------------| | |
3107// | | RouteCreate | |
3108// | |--------------------------->|
3109// | | RouteResponse| |
3110// | |<---------------------------|
3111// | | SubReq | |
3112// | |------------->| |
3113// | | SubResp | |
3114// | |<-------------| |
3115// | RESTNotif1 | | |
3116// |<----------------| | |
3117// | RESTSubReq | | |
3118// | [with RestSUbsId + one additional e2 subDetail]
3119// |---------------->| | |
3120// | RESTNotif1 | | |
3121// | [for initial e2 subDetail] | |
3122// |<----------------| | |
3123// | | RouteCreate | |
3124// | |--------------------------->|
3125// | | RouteResponse| |
3126// | |<---------------------------|
3127// | | SubReq | |
3128// | |------------->| |
3129// | | SubResp | |
3130// | |<-------------| |
3131// | RESTNotif1 | | |
3132// |<----------------| | |
3133// | RESTSubReq | | |
3134// | [with RESTsubsId initial request] |
3135// |---------------->| | |
3136// | RESTNotif1 | | |
3137// |<----------------| | |
3138// | RESTSubDelReq | | |
3139// |---------------->| | |
3140// | RESTSubDelResp| | |
3141// |<----------------| | |
3142// | | SubDelReq | |
3143// | |------------->| |
3144// | | SubDelResp | |
3145// | |<-------------| |
3146// | | SubDelReq | |
3147// | |------------->| |
3148// | | SubDelResp | |
3149// | |<-------------| |
3150// | | | |
3151//
3152//-----------------------------------------------------------------------------
3153
3154func TestRESTSubReqRetransmissionV4(t *testing.T) {
3155 CaseBegin("TestRESTSubReqRetransmissionV4")
3156
3157 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3158 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003159 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003160 Counter{cRestSubRespToXapp, 3},
3161 Counter{cSubReqToE2, 2},
3162 Counter{cSubRespFromE2, 2},
3163 Counter{cRestSubNotifToXapp, 4},
3164 Counter{cRestSubDelReqFromXapp, 1},
3165 Counter{cSubDelReqToE2, 2},
3166 Counter{cSubDelRespFromE2, 2},
3167 Counter{cRestSubDelRespToXapp, 1},
3168 })
3169
3170 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3171
3172 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3173
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003174 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003175
3176 // Send modified requst, this time with e2 subscriptions.
3177 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3178 params2.SetSubscriptionID(&restSubId)
3179
3180 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003181 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003182 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3183 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003184 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3185 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003186
3187 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3188
Markku Virtanen2b512b62021-07-30 12:04:00 +00003189 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003190 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3191 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3192 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3193 assert.NotEqual(t, e2SubsId2, 0)
3194
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003195 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003196
3197 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3198 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3199 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003200 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003201 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3202 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3203 assert.Equal(t, restSubId_resend, restSubId_resend2)
3204
Markku Virtanen2b512b62021-07-30 12:04:00 +00003205 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3206 assert.Equal(t, e2SubsId, e2SubsId1)
3207
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003208 mainCtrl.WaitOngoingRequestMapEmpty()
3209
Markku Virtanen42723e22021-06-15 10:09:23 +03003210 // Delete both e2 subscriptions
3211 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3212 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3213 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3214
3215 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003216 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003217 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003218}
3219
3220//-----------------------------------------------------------------------------
3221// stub stub stub
3222// +-------+ +---------+ +---------+ +---------+
3223// | xapp | | submgr | | e2term | | rtmgr |
3224// +-------+ +---------+ +---------+ +---------+
3225// | | | |
3226// | RESTSubReq | | |
3227// |---------------->| | |
3228// | RESTSubResp | | |
3229// |<----------------| | |
3230// | | RouteCreate | |
3231// | |--------------------------->|
3232// | | RouteResponse| |
3233// | |<---------------------------|
3234// | | SubReq | |
3235// | |------------->| |
3236// | | SubResp | |
3237// | |<-------------| |
3238// | RESTNotif1 | | |
3239// |<----------------| | |
3240// | RESTSubReq | | |
3241// | [with RestSUbsId + one additional e2 subDetail]
3242// |---------------->| | |
3243// | RESTNotif1 | | |
3244// | [for initial e2 subDetail] | |
3245// |<----------------| | |
3246// | | RouteCreate | |
3247// | |--------------------------->|
3248// | | RouteResponse| |
3249// | |<---------------------------|
3250// | | SubReq | |
3251// | |------------->| |
3252// | | SubResp | |
3253// | |<-------------| |
3254// | RESTNotif1 | | |
3255// |<----------------| | |
3256// | RESTSubReq | | |
3257// | [without RESTsubsId initial request] |
3258// |---------------->| | |
3259// | RESTNotif1 | | |
3260// |<----------------| | |
3261// | RESTSubDelReq | | |
3262// |---------------->| | |
3263// | RESTSubDelResp| | |
3264// |<----------------| | |
3265// | | SubDelReq | |
3266// | |------------->| |
3267// | | SubDelResp | |
3268// | |<-------------| |
3269// | | SubDelReq | |
3270// | |------------->| |
3271// | | SubDelResp | |
3272// | |<-------------| |
3273// | | | |
3274//
3275//-----------------------------------------------------------------------------
3276
3277func TestRESTSubReqRetransmissionV5(t *testing.T) {
3278 CaseBegin("TestRESTSubReqRetransmissionV5")
3279
3280 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3281 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003282 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003283 Counter{cRestSubRespToXapp, 3},
3284 Counter{cSubReqToE2, 2},
3285 Counter{cSubRespFromE2, 2},
3286 Counter{cRestSubNotifToXapp, 4},
3287 Counter{cRestSubDelReqFromXapp, 1},
3288 Counter{cSubDelReqToE2, 2},
3289 Counter{cSubDelRespFromE2, 2},
3290 Counter{cRestSubDelRespToXapp, 1},
3291 })
3292
3293 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3294
3295 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3296
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003297 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003298
3299 // Send modified requst, this time with e2 subscriptions.
3300 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3301 params2.SetSubscriptionID(&restSubId)
3302
3303 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003304 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003305 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3306 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3307
Markku Virtanen2b512b62021-07-30 12:04:00 +00003308 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3309 assert.Equal(t, e2SubsId, e2SubsId1)
3310 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3311 xappConn1.DecrementRequestCount()
3312
Markku Virtanen42723e22021-06-15 10:09:23 +03003313 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3314
3315 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3316 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3317 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3318 assert.NotEqual(t, e2SubsId2, 0)
3319
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003320 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003321
3322 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3323 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003324 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003325 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3326 // md5sum shall find the original request
3327 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3328 assert.Equal(t, restSubId_resend, restSubId_resend2)
3329
Markku Virtanen2b512b62021-07-30 12:04:00 +00003330 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3331 assert.Equal(t, e2SubsId, e2SubsId1)
3332
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003333 mainCtrl.WaitOngoingRequestMapEmpty()
3334
Markku Virtanen42723e22021-06-15 10:09:23 +03003335 // Delete both e2 subscriptions
3336 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3337 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3338 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3339
3340 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003341 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003342 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003343}
3344
3345//-----------------------------------------------------------------------------
3346// stub stub stub
3347// +-------+ +---------+ +---------+ +---------+
3348// | xapp | | submgr | | e2term | | rtmgr |
3349// +-------+ +---------+ +---------+ +---------+
3350// | | | |
3351// | RESTSubReq | | |
3352// |---------------->| | |
3353// | RESTSubResp | | |
3354// |<----------------| | |
3355// | | RouteCreate | |
3356// | |--------------------------->|
3357// | | RouteResponse| |
3358// | |<---------------------------|
3359// | | SubReq | |
3360// | |------------->| |
3361// | | SubResp | |
3362// | |<-------------| |
3363// | RESTNotif1 | | |
3364// |<----------------| | |
3365// | RESTSubReq | | |
3366// | [with RestSUbsId + one additional e2 subDetail]
3367// |---------------->| | |
3368// | RESTNotif1 | | |
3369// | [for initial e2 subDetail] | |
3370// |<----------------| | |
3371// | | RouteCreate | |
3372// | |--------------------------->|
3373// | | RouteResponse| |
3374// | |<---------------------------|
3375// | | SubReq | |
3376// | |------------->| |
3377// | | SubResp | |
3378// | |<-------------| |
3379// | RESTNotif1 | | |
3380// |<----------------| | |
3381// | RESTSubDelReq | | |
3382// |---------------->| | |
3383// | RESTSubDelResp| | |
3384// |<----------------| | |
3385// | | SubDelReq | |
3386// | |------------->| |
3387// | | SubDelResp | |
3388// | |<-------------| |
3389// | | SubDelReq | |
3390// | |------------->| |
3391// | | SubDelResp | |
3392// | |<-------------| |
3393// | RESTSubReq | | |
3394// | [with RESTsubsId initial request] |
3395// |---------------->| | |
3396// | RESTSubResp | | |
3397// |<----------------| | |
3398// | | RouteCreate | |
3399// | |--------------------------->|
3400// | | RouteResponse| |
3401// | |<---------------------------|
3402// | | SubReq | |
3403// | |------------->| |
3404// | | SubResp | |
3405// | |<-------------| |
3406// | RESTNotif1 | | |
3407// |<----------------| | |
3408// | | | |
3409//
3410//-----------------------------------------------------------------------------
3411func TestRESTSubReqRetransmissionV6(t *testing.T) {
3412 CaseBegin("TestRESTSubReqRetransmissionV6")
3413
3414 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3415 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003416 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003417 Counter{cRestSubRespToXapp, 3},
3418 Counter{cSubReqToE2, 3},
3419 Counter{cSubRespFromE2, 3},
3420 Counter{cRestSubNotifToXapp, 4},
3421 Counter{cRestSubDelReqFromXapp, 2},
3422 Counter{cSubDelReqToE2, 3},
3423 Counter{cSubDelRespFromE2, 3},
3424 Counter{cRestSubDelRespToXapp, 2},
3425 })
3426
3427 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3428
3429 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3430
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003431 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003432
3433 // Send modified requst, this time with e2 subscriptions.
3434 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3435 params2.SetSubscriptionID(&restSubId)
3436
3437 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003438 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003439 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3440 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3441
Markku Virtanen2b512b62021-07-30 12:04:00 +00003442 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3443 assert.Equal(t, e2SubsId, e2SubsId1)
3444
Markku Virtanen42723e22021-06-15 10:09:23 +03003445 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3446
3447 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3448 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3449 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3450 assert.NotEqual(t, e2SubsId2, 0)
3451
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003452 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003453
3454 // Delete both e2 subscriptions
3455 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3456 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3457 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3458
3459 waitSubsCleanup(t, e2SubsId, 10)
3460
3461 // Resend the original request, we shall find it's previous md5sum/restsubs
3462 // but the restsubscription has been already removed. This shall trigger a
3463 // fresh create.
3464 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3465
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003466 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003467
3468 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3469
3470 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003471 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003472 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003473}
3474
archaggeafbf95f2021-04-14 08:54:05 +03003475func TestRESTSubDelReqRetransmission(t *testing.T) {
3476 CaseBegin("TestRESTSubDelReqRetransmission")
3477
3478 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003479 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003480 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003481 Counter{cSubReqToE2, 1},
3482 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003483 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003484 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003485 Counter{cSubDelReqToE2, 1},
3486 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003487 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003488 })
3489
3490 var params *teststube2ap.RESTSubsReqParams = nil
3491
3492 //Subs Create
3493 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3494
3495 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3496
3497 //Subs Delete
3498 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3499 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3500
3501 seqBef := mainCtrl.get_msgcounter(t)
3502 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3503 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3504
3505 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3506
3507 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003508 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003509 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003510}
3511
3512//-----------------------------------------------------------------------------
3513// TestRESTSubReqDelReq
3514//
3515// stub stub
3516// +-------+ +---------+ +---------+
3517// | xapp | | submgr | | e2term |
3518// +-------+ +---------+ +---------+
3519// | | |
3520// | RESTSubReq | |
3521// |---------------->| |
3522// | | |
3523// | RESTSubResp | |
3524// |<----------------| |
3525// | | SubReq |
3526// | |------------->|
3527// | RESTSubDelReq | |
3528// |---------------->| |
3529// | RESTSubDelResp | |
3530// | unsuccess | |
3531// |<----------------| |
3532// | | SubResp |
3533// | |<-------------|
3534// | RESTNotif1 | |
3535// |<----------------| |
3536// | | |
3537// | [SUBS DELETE] |
3538// | | |
3539//
3540//-----------------------------------------------------------------------------
3541func TestRESTSubReqDelReq(t *testing.T) {
3542 CaseBegin("TestRESTSubReqDelReq")
3543
3544 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003545 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003546 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003547 Counter{cSubReqToE2, 1},
3548 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003549 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003550 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003551 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003552 Counter{cSubDelReqToE2, 1},
3553 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003554 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003555 })
3556
3557 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003558
3559 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003560 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003561 restSubId := xappConn1.SendRESTSubsReq(t, params)
3562
3563 // Del. This will fail as processing of the subscription
3564 // is still ongoing in submgr. Deletion is not allowed before
3565 // subscription creation has been completed.
3566 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3567 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3568 xappConn1.ExpectRESTNotification(t, restSubId)
3569 e2termConn1.SendSubsResp(t, crereq, cremsg)
3570 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3571
3572 // Retry del
3573 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3574
3575 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3576 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3577
3578 // Wait that subs is cleaned
3579 waitSubsCleanup(t, e2SubsId, 10)
3580 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003581 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003582}
3583
3584func TestRESTSubDelReqCollision(t *testing.T) {
3585 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3586}
3587
3588func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3589 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3590
3591 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003592 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003593 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003594 Counter{cSubReqToE2, 2},
3595 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003596 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003597 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003598 Counter{cSubDelReqToE2, 2},
3599 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003600 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003601 })
3602
3603 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003604 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003605 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003606 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003607
3608 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003609 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003610 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003611 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003612
3613 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3614 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3615
3616 //XappConn1 receives both of the responses
3617 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3618
3619 //Resp1
3620 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3621 //Resp2
3622 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3623
3624 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003625 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003626 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003627 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003628
3629 //Del1
3630 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3631 //Del2
3632 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3633
3634 //Wait that subs is cleaned
3635 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3636 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3637
3638 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003639 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003640}
3641
3642func TestRESTSameSubsDiffRan(t *testing.T) {
3643 CaseBegin("TestRESTSameSubsDiffRan")
3644
3645 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003646 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003647 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003648 Counter{cSubReqToE2, 2},
3649 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003650 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003651 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003652 Counter{cSubDelReqToE2, 2},
3653 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003654 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003655 })
3656
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003657 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003658 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003659 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003660
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003661 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003662 params.SetMeid("RAN_NAME_2")
3663 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003664 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003665
3666 //Del1
3667 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3668 //Del2
3669 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3670
3671 //Wait that subs is cleaned
3672 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3673 waitSubsCleanup(t, e2SubsId2, 10)
3674
3675 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003676 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003677}
3678
3679func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3680 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3681
3682 // Init counter check
3683 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003684 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003685 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003686 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003687 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003688 Counter{cSubReReqToE2, 1},
3689 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003690 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003691 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003692 Counter{cSubDelReqToE2, 1},
3693 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003694 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003695 })
3696
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003697 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003698 restSubId := xappConn1.SendRESTSubsReq(t, params)
3699
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003700 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003701
3702 // Catch the first message and ignore it
3703 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003704 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003705
3706 // The second request is being handled normally
3707 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3708 xappConn1.ExpectRESTNotification(t, restSubId)
3709 e2termConn1.SendSubsResp(t, crereq, cremsg)
3710 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3711
3712 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3713
3714 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3715
3716 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3717 //Wait that subs is cleaned
3718 waitSubsCleanup(t, e2SubsId, 10)
3719
3720 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003721 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003722}
3723
3724//-----------------------------------------------------------------------------
3725// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3726//
3727// stub stub
3728// +-------+ +---------+ +---------+
3729// | xapp | | submgr | | e2term |
3730// +-------+ +---------+ +---------+
3731// | | |
3732// | RESTSubReq | |
3733// |---------------->| |
3734// | | |
3735// | RESTSubResp | |
3736// |<----------------| |
3737// | | SubReq |
3738// | |------------->|
3739// | | |
3740// | | |
3741// | | SubReq |
3742// | |------------->|
3743// | | |
3744// | | SubDelReq |
3745// | |------------->|
3746// | | |
3747// | | |
3748// | | SubDelReq |
3749// | |------------->|
3750// | | |
3751// | | |
3752// | | SubDelResp |
3753// | |<-------------|
3754// | RESTNotif | |
3755// | unsuccess | |
3756// |<----------------| |
3757// | | |
3758// | [SUBS DELETE] |
3759// | | |
3760//
3761//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003762
archaggeafbf95f2021-04-14 08:54:05 +03003763func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3764 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3765
3766 // Init counter check
3767 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003768 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003769 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003770 Counter{cSubReqToE2, 1},
3771 Counter{cSubReReqToE2, 1},
3772 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003773 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003774 Counter{cSubDelReqToE2, 1},
3775 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003776 Counter{cRestSubDelReqFromXapp, 1},
3777 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003778 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003779
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003780 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003781 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003782 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003783
3784 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003785 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003786
3787 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003788 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003789
3790 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003791 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003792 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003793 xappConn1.WaitRESTNotification(t, restSubId)
3794
Anssi Mannilab43397e2021-11-16 12:06:16 +02003795 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3796
archaggeafbf95f2021-04-14 08:54:05 +03003797 // Wait that subs is cleaned
3798 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003799 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003800 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003801}
3802
3803func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3804 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3805
3806 // Init counter check
3807 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003808 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003809 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003810 Counter{cSubReqToE2, 1},
3811 Counter{cSubReReqToE2, 1},
3812 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003813 Counter{cSubDelReReqToE2, 1},
3814 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003815 Counter{cSubDelReqToE2, 1},
3816 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003817 Counter{cRestSubDelReqFromXapp, 1},
3818 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003819 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02003820
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003821 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003822 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003823 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003824
3825 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003826 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003827
3828 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003829 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003830
3831 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003832 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003833
Markku Virtanen55d2a282021-06-04 14:46:56 +03003834 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003835 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003836 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003837
3838 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3839
Anssi Mannilab43397e2021-11-16 12:06:16 +02003840 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003841
Anssi Mannilab43397e2021-11-16 12:06:16 +02003842 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003843 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003844 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003845}
3846
3847//-----------------------------------------------------------------------------
3848// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3849//
3850// stub stub
3851// +-------+ +---------+ +---------+
3852// | xapp | | submgr | | e2term |
3853// +-------+ +---------+ +---------+
3854// | | |
3855// | RESTSubReq | |
3856// |---------------->| |
3857// | | |
3858// | RESTSubResp | |
3859// |<----------------| |
3860// | | SubReq |
3861// | |------------->|
3862// | | |
3863// | | |
3864// | | SubReq |
3865// | |------------->|
3866// | | |
3867// | | SubDelReq |
3868// | |------------->|
3869// | | |
3870// | | |
3871// | | SubDelReq |
3872// | |------------->|
3873// | | |
3874// | | |
3875// | | SubDelResp |
3876// | |<-------------|
3877// | RESTNotif | |
3878// | unsuccess | |
3879// |<----------------| |
3880// | | |
3881// | [SUBS DELETE] |
3882// | | |
3883//
3884//-----------------------------------------------------------------------------
3885func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3886 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3887
3888 // Init counter check
3889 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003890 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003891 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003892 Counter{cSubReqToE2, 1},
3893 Counter{cSubReReqToE2, 1},
3894 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003895 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003896 Counter{cSubDelReqToE2, 1},
3897 Counter{cSubDelReReqToE2, 1},
3898 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003899 Counter{cRestSubDelReqFromXapp, 1},
3900 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003901 })
3902
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003903 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003904 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003905 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003906
3907 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003908 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003909
3910 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003911 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003912
3913 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003914 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003915
Markku Virtanen55d2a282021-06-04 14:46:56 +03003916 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003917 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003918 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003919
3920 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3921
Anssi Mannilab43397e2021-11-16 12:06:16 +02003922 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003923
Anssi Mannilab43397e2021-11-16 12:06:16 +02003924 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003925 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003926 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003927}
3928
3929//-----------------------------------------------------------------------------
3930// TestRESTSubReqSubFailRespInSubmgr
3931//
3932// stub stub
3933// +-------+ +---------+ +---------+
3934// | xapp | | submgr | | e2term |
3935// +-------+ +---------+ +---------+
3936// | | |
3937// | RESTSubReq | |
3938// |---------------->| |
3939// | | |
3940// | RESTSubResp | |
3941// |<----------------| |
3942// | | SubReq |
3943// | |------------->|
3944// | | |
3945// | | SubFail |
3946// | |<-------------|
3947// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003948// | RESTNotif | |
3949// | unsuccess | |
3950// |<----------------| |
3951// | | |
3952// | [SUBS DELETE] |
3953// | | |
3954//
3955//-----------------------------------------------------------------------------
3956func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3957 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3958
3959 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003960 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003961 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003962 Counter{cSubReqToE2, 1},
3963 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003964 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003965 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003966 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003967 })
3968
3969 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003970 const e2Timeout int64 = 2
3971 const e2RetryCount int64 = 1
3972 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003973
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003974 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003975 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003976 restSubId := xappConn1.SendRESTSubsReq(t, params)
3977
3978 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3979 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3980 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003981 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003982 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3983
archaggeafbf95f2021-04-14 08:54:05 +03003984 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003985 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003986
3987 // REST subscription sill there to be deleted
3988 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3989
3990 // Wait that subs is cleaned
3991 waitSubsCleanup(t, e2SubsId, 10)
3992
3993 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003994 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003995}
3996
3997//-----------------------------------------------------------------------------
3998// TestRESTSubDelReqRetryInSubmgr
3999//
4000// stub stub
4001// +-------+ +---------+ +---------+
4002// | xapp | | submgr | | e2term |
4003// +-------+ +---------+ +---------+
4004// | | |
4005// | [SUBS CREATE] |
4006// | | |
4007// | | |
4008// | RESTSubDelReq | |
4009// |---------------->| |
4010// | | |
4011// | RESTSubDelResp | |
4012// |<----------------| |
4013// | | SubDelReq |
4014// | |------------->|
4015// | | |
4016// | | SubDelReq |
4017// | |------------->|
4018// | | |
4019// | | SubDelResp |
4020// | |<-------------|
4021// | | |
4022//
4023//-----------------------------------------------------------------------------
4024func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4025 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4026
4027 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004028 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004029 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004030 Counter{cSubReqToE2, 1},
4031 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004032 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004033 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004034 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004035 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004036 Counter{cSubDelReReqToE2, 1},
4037 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004038 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004039 })
4040 // Req
4041 var params *teststube2ap.RESTSubsReqParams = nil
4042 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4043
4044 // Del
4045 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4046
4047 // E2t: Receive 1st SubsDelReq
4048 e2termConn1.RecvSubsDelReq(t)
4049
4050 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4051 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4052 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4053
4054 //Wait that subs is cleaned
4055 waitSubsCleanup(t, e2SubsId, 10)
4056
4057 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004058 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004059}
4060
4061//-----------------------------------------------------------------------------
4062// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4063//
4064// stub stub
4065// +-------+ +---------+ +---------+
4066// | xapp | | submgr | | e2term |
4067// +-------+ +---------+ +---------+
4068// | | |
4069// | [SUBS CREATE] |
4070// | | |
4071// | | |
4072// | RESTSubDelReq | |
4073// |---------------->| |
4074// | | |
4075// | RESTSubDelResp | |
4076// |<----------------| |
4077// | | SubDelReq |
4078// | |------------->|
4079// | | |
4080// | | SubDelReq |
4081// | |------------->|
4082// | | |
4083// | | |
4084//
4085//-----------------------------------------------------------------------------
4086func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4087 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4088
4089 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004090 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004091 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004092 Counter{cSubReqToE2, 1},
4093 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004094 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004095 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004096 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004097 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004098 Counter{cSubDelReReqToE2, 1},
4099 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004100 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004101 })
4102
4103 // Req
4104 var params *teststube2ap.RESTSubsReqParams = nil
4105 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4106
4107 // Del
4108 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4109
4110 // E2t: Receive 1st SubsDelReq
4111 e2termConn1.RecvSubsDelReq(t)
4112
4113 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4114 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4115 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4116
4117 //Wait that subs is cleaned
4118 waitSubsCleanup(t, e2SubsId, 10)
4119
4120 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004121 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004122}
4123
4124//-----------------------------------------------------------------------------
4125// TestRESTSubDelReqSubDelFailRespInSubmgr
4126//
4127// stub stub
4128// +-------+ +---------+ +---------+
4129// | xapp | | submgr | | e2term |
4130// +-------+ +---------+ +---------+
4131// | | |
4132// | [SUBS CREATE] |
4133// | | |
4134// | | |
4135// | RESTSubDelReq | |
4136// |---------------->| |
4137// | | |
4138// | RESTSubDelResp | |
4139// |<----------------| |
4140// | | SubDelReq |
4141// | |------------->|
4142// | | |
4143// | | SubDelFail |
4144// | |<-------------|
4145// | | |
4146//
4147//-----------------------------------------------------------------------------
4148func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4149 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4150
4151 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004152 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004153 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004154 Counter{cSubReqToE2, 1},
4155 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004156 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004157 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004158 Counter{cSubDelReqToE2, 1},
4159 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004160 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004161 })
4162
4163 // Req
4164 var params *teststube2ap.RESTSubsReqParams = nil
4165 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4166
4167 // Del
4168 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4169
4170 // E2t: Send receive SubsDelReq and send SubsDelFail
4171 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4172 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4173
4174 //Wait that subs is cleaned
4175 waitSubsCleanup(t, e2SubsId, 10)
4176
4177 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004178 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004179}
4180
4181//-----------------------------------------------------------------------------
4182// TestRESTSubReqAndSubDelOkSameAction
4183//
4184// stub stub
4185// +-------+ +-------+ +---------+ +---------+
4186// | xapp2 | | xapp1 | | submgr | | e2term |
4187// +-------+ +-------+ +---------+ +---------+
4188// | | | |
4189// | | RESTSubReq1 | |
4190// | |---------------->| |
4191// | | | |
4192// | | RESTSubResp1 | |
4193// | |<----------------| |
4194// | | | |
4195// | | | SubReq1 |
4196// | | |------------->|
4197// | | | SubResp1 |
4198// | | |<-------------|
4199// | | RESTNotif1 | |
4200// | |<----------------| |
4201// | | | |
4202// | RESTSubReq2 | |
4203// |------------------------------>| |
4204// | | | |
4205// | RESTSubResp2 | |
4206// |<------------------------------| |
4207// | | | |
4208// | | RESTNotif2 | |
4209// |<------------------------------| |
4210// | | | |
4211// | | RESTSubDelReq1 | |
4212// | |---------------->| |
4213// | | | |
4214// | | RESTSubDelResp1 | |
4215// | |<----------------| |
4216// | | | |
4217// | RESTSubDelReq2 | |
4218// |------------------------------>| |
4219// | | | |
4220// | RESTSubDelResp2 | |
4221// |<------------------------------| |
4222// | | | |
4223// | | | SubDelReq2 |
4224// | | |------------->|
4225// | | | |
4226// | | | SubDelResp2 |
4227// | | |<-------------|
4228// | | | |
4229//
4230//-----------------------------------------------------------------------------
4231func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4232 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4233
4234 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004235 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004236 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004237 Counter{cSubReqToE2, 1},
4238 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004239 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004240 Counter{cMergedSubscriptions, 1},
4241 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004242 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004243 Counter{cSubDelReqToE2, 1},
4244 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004245 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004246 })
4247
4248 // Req1
4249 var params *teststube2ap.RESTSubsReqParams = nil
4250
4251 //Subs Create
4252 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4253 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4254
4255 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004256 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004257 params.SetMeid("RAN_NAME_1")
4258
4259 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004260 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004261 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004262 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004263 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004264 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004265 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004266 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004267
4268 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4269
4270 // Del1
4271 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4272
4273 // Del2
4274 deleteXapp2Subscription(t, &restSubId2)
4275
4276 //Wait that subs is cleaned
4277 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004278 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004279 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004280}
4281
4282//-----------------------------------------------------------------------------
4283// TestSubReqAndSubDelOkSameActionParallel
4284//
4285// stub stub stub
4286// +-------+ +-------+ +---------+ +---------+
4287// | xapp2 | | xapp1 | | submgr | | e2term |
4288// +-------+ +-------+ +---------+ +---------+
4289// | | | |
4290// | | | |
4291// | | | |
4292// | | SubReq1 | |
4293// | |------------->| |
4294// | | | |
4295// | | | SubReq1 |
4296// | | |------------->|
4297// | SubReq2 | |
4298// |--------------------------->| |
4299// | | | SubResp1 |
4300// | | |<-------------|
4301// | | SubResp1 | |
4302// | |<-------------| |
4303// | | | SubReq2 |
4304// | | |------------->|
4305// | | | |
4306// | | | SubResp2 |
4307// | | |<-------------|
4308// | SubResp2 | |
4309// |<---------------------------| |
4310// | | | |
4311// | | SubDelReq 1 | |
4312// | |------------->| |
4313// | | | |
4314// | | SubDelResp 1 | |
4315// | |<-------------| |
4316// | | | |
4317// | SubDelReq 2 | |
4318// |--------------------------->| |
4319// | | | |
4320// | | | SubDelReq 2 |
4321// | | |------------->|
4322// | | | |
4323// | | | SubDelReq 2 |
4324// | | |------------->|
4325// | | | |
4326// | SubDelResp 2 | |
4327// |<---------------------------| |
4328//
4329func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4330 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4331
4332 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004333 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004334 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004335 Counter{cSubReqToE2, 2},
4336 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004337 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004338 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004339 Counter{cSubDelReqToE2, 2},
4340 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004341 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004342 })
4343
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004344 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004345 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4346 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4347
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004348 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004349 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4350
4351 xappConn1.ExpectRESTNotification(t, restSubId1)
4352 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4353 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4354
4355 xappConn2.ExpectRESTNotification(t, restSubId2)
4356 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4357 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4358 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4359
4360 // Del1
4361 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4362 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4363 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4364 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4365
4366 // Del2
4367 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4368 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4369 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4370
4371 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004372 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004373 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004374}
4375
4376//-----------------------------------------------------------------------------
4377// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4378//
4379// stub stub stub
4380// +-------+ +-------+ +---------+ +---------+
4381// | xapp2 | | xapp1 | | submgr | | e2term |
4382// +-------+ +-------+ +---------+ +---------+
4383// | | | |
4384// | | | |
4385// | | | |
4386// | | RESTSubReq1 | |
4387// | |---------------->| |
4388// | | | |
4389// | | RESTSubResp1 | |
4390// | |<----------------| |
4391// | | | SubReq1 |
4392// | | |------------->|
4393// | RESTSubReq2 | |
4394// |------------------------------>| |
4395// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004396// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004397// |<------------------------------| |
4398// | | | SubReq1 |
4399// | | |------------->|
4400// | | | |
4401// | | | |
4402// | | | SubDelReq |
4403// | | |------------->|
4404// | | | |
4405// | | | SubDelResp |
4406// | | |<-------------|
4407// | | RESTNotif1 | |
4408// | | unsuccess | |
4409// | |<----------------| |
4410// | RESTNotif2 | |
4411// | | unsuccess | |
4412// |<------------------------------| |
4413// | | | |
4414// | | RESTSubDelReq1 | |
4415// | |---------------->| |
4416// | | | |
4417// | | RESTSubDelResp1 | |
4418// | |<----------------| |
4419// | | | |
4420// | RESTSubDelReq2 | |
4421// |------------------------------>| |
4422// | | | |
4423// | RESTSubDelResp2 | |
4424// |<------------------------------| |
4425//
4426//-----------------------------------------------------------------------------
4427func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4428 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4429
4430 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004431 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004432 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004433 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004434 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004435 Counter{cSubReqTimerExpiry, 2},
4436 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004437 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004438 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004439 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004440 Counter{cSubDelReqToE2, 1},
4441 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004442 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004443 })
archaggeafbf95f2021-04-14 08:54:05 +03004444 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004445
4446 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004447 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004448 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4449 crereq1, _ := e2termConn1.RecvSubsReq(t)
4450
4451 // Req2
4452 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004453 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004454 params2.SetMeid("RAN_NAME_1")
4455 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4456 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4457
4458 //Req1 (retransmitted)
4459 e2termConn1.RecvSubsReq(t)
4460
4461 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004462
4463 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004464 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4465
Markku Virtanenda34eec2021-05-20 08:22:04 +00004466 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004467 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004468 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004469 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004470
4471 // Del1
4472 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4473
4474 // Del2
4475 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4476
Markku Virtanenda34eec2021-05-20 08:22:04 +00004477 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4478
archaggeafbf95f2021-04-14 08:54:05 +03004479 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004480 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004481 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004482 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004483}
4484
4485//-----------------------------------------------------------------------------
4486// TestRESTSubReqAndSubDelNokSameActionParallel
4487//
4488// stub stub stub
4489// +-------+ +-------+ +---------+ +---------+
4490// | xapp2 | | xapp1 | | submgr | | e2term |
4491// +-------+ +-------+ +---------+ +---------+
4492// | | | |
4493// | | | |
4494// | | | |
4495// | | RESTSubReq1 | |
4496// | |---------------->| |
4497// | | | |
4498// | | RESTSubResp1 | |
4499// | |<----------------| |
4500// | | | SubReq1 |
4501// | | |------------->|
4502// | RESTSubReq2 | |
4503// |------------------------------>| |
4504// | | | |
4505// | RESTSubDelResp2 | |
4506// |<------------------------------| |
4507// | | | SubFail1 |
4508// | | |<-------------|
4509// | | | |
4510// | | RESTNotif1 | |
4511// | | unsuccess | |
4512// | |<----------------| |
4513// | RESTNotif2 | |
4514// | | unsuccess | |
4515// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004516// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004517// | | 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 +03004518// | |---------------->| |
4519// | | | |
4520// | | RESTSubDelResp1 | |
4521// | |<----------------| |
4522// | | | |
4523// | RESTSubDelReq2 | |
4524// |------------------------------>| |
4525// | | | |
4526// | RESTSubDelResp2 | |
4527// |<------------------------------| |
4528//
4529//-----------------------------------------------------------------------------
4530func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4531 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4532
4533 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004534 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004535 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004536 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004537 Counter{cSubReqToE2, 1},
4538 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004539 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02004540 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004541 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004542 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004543 })
4544
4545 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004546
4547 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004548 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004549 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4550 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4551
4552 // Req2
4553 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004554 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004555 params2.SetMeid("RAN_NAME_1")
4556 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4557 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4558
4559 // E2t: send SubsFail (first)
4560 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4561 fparams1.Set(crereq1)
4562 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4563
archaggeafbf95f2021-04-14 08:54:05 +03004564 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004565 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004566 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004567 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004568 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004569
4570 // Del1
4571 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4572
4573 // Del2
4574 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4575
4576 //Wait that subs is cleaned
4577 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4578 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004579 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004580 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004581}
Anssi Mannila54838ed2021-11-19 11:25:01 +02004582
archaggeafbf95f2021-04-14 08:54:05 +03004583func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4584 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4585
4586 // Init counter check
4587 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004588 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004589 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004590 Counter{cSubReqToE2, 1},
4591 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004592 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004593 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004594 Counter{cSubDelReqToE2, 1},
4595 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004596 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004597 })
4598
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004599 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004600 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004601 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004602
4603 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4604 xappConn1.ExpectRESTNotification(t, restSubId)
4605 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4606 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004607 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004608
4609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4610 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4611 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4612
4613 // Wait that subs is cleaned
4614 waitSubsCleanup(t, e2SubsId, 10)
4615 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004616 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004617}
4618
4619//-----------------------------------------------------------------------------
4620// TestRESTSubReqPolicyChangeAndSubDelOk
4621//
4622// stub stub
4623// +-------+ +---------+ +---------+
4624// | xapp | | submgr | | e2term |
4625// +-------+ +---------+ +---------+
4626// | | |
4627// | RESTSubReq | |
4628// |---------------->| |
4629// | | |
4630// | RESTSubResp | |
4631// |<----------------| |
4632// | | SubReq |
4633// | |------------->|
4634// | | |
4635// | | SubResp |
4636// | |<-------------|
4637// | | |
4638// | RESTNotif | |
4639// |<----------------| |
4640// | | |
4641// | RESTSubReq | |
4642// |---------------->| |
4643// | | |
4644// | RESTSubResp | |
4645// |<----------------| |
4646// | | SubReq |
4647// | |------------->|
4648// | | |
4649// | | SubResp |
4650// | |<-------------|
4651// | | |
4652// | RESTNotif | |
4653// |<----------------| |
4654// | | |
4655// | RESTSubDelReq | |
4656// |---------------->| |
4657// | | |
4658// | | SubDelReq |
4659// | |------------->|
4660// | | |
4661// | | SubDelResp |
4662// | |<-------------|
4663// | | |
4664// | RESTSubDelResp | |
4665// |<----------------| |
4666//
4667//-----------------------------------------------------------------------------
4668func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4669 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4670
4671 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004672 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004673 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004674 Counter{cSubReqToE2, 2},
4675 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004676 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004677 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004678 Counter{cSubDelReqToE2, 1},
4679 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004680 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004681 })
4682
4683 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004684 const e2Timeout int64 = 1
4685 const e2RetryCount int64 = 0
4686 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004687
4688 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004689 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004690 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004691 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4692
4693 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004694 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004695
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004696 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004697 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004698 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004699 params.SetTimeToWait("w200ms")
4700 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4701
4702 // Del
4703 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4704
4705 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4706 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4707
4708 // Wait that subs is cleaned
4709 waitSubsCleanup(t, e2SubsId, 10)
4710 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004711 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004712}
4713
4714//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004715// TestRESTSubReqPolicyChangeNOk
4716//
4717// stub stub
4718// +-------+ +---------+ +---------+
4719// | xapp | | submgr | | e2term |
4720// +-------+ +---------+ +---------+
4721// | | |
4722// | RESTSubReq | |
4723// |---------------->| |
4724// | | |
4725// | RESTSubResp | |
4726// |<----------------| |
4727// | | SubReq |
4728// | |------------->|
4729// | | |
4730// | | SubResp |
4731// | |<-------------|
4732// | | |
4733// | RESTNotif | |
4734// |<----------------| |
4735// | | |
4736// | RESTSubReq | |
4737// |---------------->| |
4738// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004739// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004740// | | |
4741// | RESTSubDelReq | |
4742// |---------------->| |
4743// | | |
4744// | | SubDelReq |
4745// | |------------->|
4746// | | |
4747// | | SubDelResp |
4748// | |<-------------|
4749// | | |
4750// | RESTSubDelResp | |
4751// |<----------------| |
4752//
4753//-----------------------------------------------------------------------------
4754func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4755 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4756
4757 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4758 Counter{cRestSubReqFromXapp, 2},
4759 Counter{cRestSubRespToXapp, 1},
4760 Counter{cSubReqToE2, 1},
4761 Counter{cSubRespFromE2, 1},
4762 Counter{cRestSubNotifToXapp, 1},
4763 Counter{cRestSubFailToXapp, 1},
4764 Counter{cRestSubDelReqFromXapp, 1},
4765 Counter{cSubDelReqToE2, 1},
4766 Counter{cSubDelRespFromE2, 1},
4767 Counter{cRestSubDelRespToXapp, 1},
4768 })
4769
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004770 // Req
4771 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4772 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4773
4774 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004775 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4776
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004777 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004778 params.SetSubscriptionID(&restSubIdUpd)
4779 params.SetTimeToWait("w200ms")
4780
4781 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4782 assert.Equal(t, restSubId2, "")
4783
4784 // Del
4785 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4786
4787 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4788 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4789
4790 // Wait that subs is cleaned
4791 waitSubsCleanup(t, e2SubsId, 10)
4792 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004793 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004794}
4795
4796//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004797// TestRESTSubReqAndSubDelOkTwoE2termParallel
4798//
4799// stub stub stub
4800// +-------+ +---------+ +---------+ +---------+
4801// | xapp | | submgr | | e2term1 | | e2term2 |
4802// +-------+ +---------+ +---------+ +---------+
4803// | | | |
4804// | | | |
4805// | | | |
4806// | RESTSubReq1 | | |
4807// |---------------->| | |
4808// | | | |
4809// | RESTSubResp1 | | |
4810// |<----------------| | |
4811// | | SubReq1 | |
4812// | |------------->| |
4813// | | | |
4814// | RESTSubReq2 | | |
4815// |---------------->| | |
4816// | | | |
4817// | RESTSubResp2 | | |
4818// |<----------------| | |
4819// | | SubReq2 | |
4820// | |---------------------------->|
4821// | | | |
4822// | | SubResp1 | |
4823// | |<-------------| |
4824// | RESTNotif1 | | |
4825// |<----------------| | |
4826// | | SubResp2 | |
4827// | |<----------------------------|
4828// | RESTNotif2 | | |
4829// |<----------------| | |
4830// | | | |
4831// | [SUBS 1 DELETE] | |
4832// | | | |
4833// | [SUBS 2 DELETE] | |
4834// | | | |
4835//
4836//-----------------------------------------------------------------------------
4837func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4838 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4839
4840 // Init counter check
4841 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004842 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004843 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004844 Counter{cSubReqToE2, 2},
4845 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004846 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004847 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004848 Counter{cSubDelReqToE2, 2},
4849 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004850 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004851 })
4852
4853 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004854
4855 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004856 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004857 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4858 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4859
4860 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004861 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004862 params.SetMeid("RAN_NAME_11")
4863 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4864 // would not work as notification would not be received
4865 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4866 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4867
4868 // Resp1
4869 xappConn1.ExpectRESTNotification(t, restSubId1)
4870 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4871 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004872 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004873
4874 // Resp2
4875 xappConn2.ExpectRESTNotification(t, restSubId2)
4876 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4877 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004878 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004879
4880 // Delete1
4881 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4882 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4883 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4884
4885 // Wait that subs is cleaned
4886 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4887
4888 // Delete2
4889 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4890 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4891 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4892
4893 // Wait that subs is cleaned
4894 waitSubsCleanup(t, e2SubsId2, 10)
4895
4896 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004897 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004898}
4899
4900//-----------------------------------------------------------------------------
4901// TestRESTSubReqAsn1EncodeFail
4902//
4903// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4904// stub stub
4905// +-------+ +---------+ +---------+
4906// | xapp | | submgr | | e2term |
4907// +-------+ +---------+ +---------+
4908// | | |
4909// | RESTSubReq | |
4910// |---------------->| |
4911// | | |
4912// | RESTSubResp | |
4913// |<----------------| |
4914// | RESTSubDelReq | |
4915// |---------------->| |
4916// | RESTSubDelResp | |
4917// | unsuccess | |
4918// |<----------------| |
4919// | | |
4920//
4921//-----------------------------------------------------------------------------
4922func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4923 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4924
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004925 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004926
4927}
4928
4929//-----------------------------------------------------------------------------
4930// TestRESTSubReqInsertAndSubDelOk
4931//
4932// stub stub
4933// +-------+ +---------+ +---------+
4934// | xapp | | submgr | | e2term |
4935// +-------+ +---------+ +---------+
4936// | | |
4937// | RestSubReq | |
4938// |---------------->| |
4939// | | |
4940// | RESTSubResp | |
4941// |<----------------| |
4942// | | |
4943// | | SubReq |
4944// | |------------->|
4945// | | |
4946// | | SubResp |
4947// | |<-------------|
4948// | RESTNotif | |
4949// |<----------------| |
4950// | ... | ... |
4951// | | |
4952// | RESTSubDelReq | |
4953// |---------------->| |
4954// | | |
4955// | | SubDelReq |
4956// | |------------->|
4957// | | |
4958// | | SubDelResp |
4959// | |<-------------|
4960// | | |
4961// | RESTSubDelResp| |
4962// |<----------------| |
4963//
4964//-----------------------------------------------------------------------------
4965func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4966 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4967
4968 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004969 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004970 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004971 Counter{cSubReqToE2, 1},
4972 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004973 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004974 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004975 Counter{cSubDelReqToE2, 1},
4976 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004977 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004978 })
4979
4980 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004981
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004982 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004983 params.SetSubActionTypes("insert")
4984
4985 // Req
4986 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4987
4988 // Del
4989 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4990
4991 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4992 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4993
4994 // Wait that subs is cleaned
4995 waitSubsCleanup(t, e2SubsId, 10)
4996 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004997 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004998}
4999
5000//-----------------------------------------------------------------------------
5001// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5002//
5003// stub stub
5004// +-------+ +---------+ +---------+
5005// | xapp | | submgr | | e2term |
5006// +-------+ +---------+ +---------+
5007// | | |
5008// | RESTSubReq | |
5009// |------------->| |
5010// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005011// | RESTSubResp | |
5012// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005013// | | SubReq |
5014// | |------------->|
5015// | | |
5016// | | SubResp |
5017// | <----|
5018// | |
5019// | Submgr restart |
5020// | |
5021// | | |
5022// | | SubDelReq |
5023// | |------------->|
5024// | | |
5025// | | SubDelResp |
5026// | |<-------------|
5027// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005028// | RESTNotif | |
5029// | unsuccess | |
5030// |<-------------| |
5031// | | |
5032// | RESTSubDelReq| |
5033// |------------->| |
5034// | | |
5035// |RESTSubDelResp| |
5036// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005037//
5038//-----------------------------------------------------------------------------
5039func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5040 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5041
5042 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005043 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005044 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005045 Counter{cSubReqToE2, 1},
5046 Counter{cSubDelReqFromXapp, 1},
5047 Counter{cSubDelReqToE2, 1},
5048 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005049 Counter{cRestSubDelReqFromXapp, 1},
5050 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005051 })
5052
5053 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005054
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005055 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005056
5057 //Req
5058 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5059 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005060 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005061
5062 e2termConn1.RecvSubsReq(t)
5063
5064 mainCtrl.SetResetTestFlag(t, false)
5065
5066 mainCtrl.SimulateRestart(t)
5067 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5068
Anssi Mannilab43397e2021-11-16 12:06:16 +02005069 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005070 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5071 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5072
Anssi Mannilab43397e2021-11-16 12:06:16 +02005073 //Del
5074 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5075
archaggeafbf95f2021-04-14 08:54:05 +03005076 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005077 e2termConn1.TestMsgChanEmpty(t)
5078 mainCtrl.wait_registry_empty(t, 10)
5079
5080 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005081 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005082}
5083
5084//-----------------------------------------------------------------------------
5085// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5086//
5087// stub stub
5088// +-------+ +---------+ +---------+
5089// | xapp | | submgr | | e2term |
5090// +-------+ +---------+ +---------+
5091// | | |
5092// | RESTSubReq | |
5093// |---------------->| |
5094// | | |
5095// | RESTSubResp | |
5096// |<----------------| |
5097// | | SubReq |
5098// | |------------->|
5099// | | |
5100// | | SubResp |
5101// | |<-------------|
5102// | | |
5103// | RESTNotif | |
5104// |<----------------| |
5105// | | |
5106// | |
5107// | Submgr restart |
5108// | | |
5109// | RESTSubDelReq | |
5110// |---------------->| |
5111// | | |
5112// | | SubDelReq |
5113// | |------------->|
5114// | | |
5115// | | SubDelResp |
5116// | |<-------------|
5117// | | |
5118// | RESTSubDelResp | |
5119// |<----------------| |
5120//
5121//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005122
archaggeafbf95f2021-04-14 08:54:05 +03005123func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5124 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5125
5126 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005127 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005128 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005129 Counter{cSubReqToE2, 1},
5130 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005131 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005132 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005133 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005134 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005135 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005136 })
archaggeafbf95f2021-04-14 08:54:05 +03005137
5138 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005139 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005140 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005141 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005142
5143 // Check subscription
5144 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5145
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005146 mainCtrl.SimulateRestart(t)
5147 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005148
Anssi Mannila54838ed2021-11-19 11:25:01 +02005149 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5150 // That needs to be completed before successful subscription query is possible
5151 <-time.After(time.Second * 1)
5152
archaggeafbf95f2021-04-14 08:54:05 +03005153 // Check subscription
5154 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5155
5156 // Delete subscription
5157 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5158
5159 //Wait that subs is cleaned
5160 waitSubsCleanup(t, e2SubsId, 10)
5161
5162 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005163 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005164}
5165
5166//-----------------------------------------------------------------------------
5167// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5168//
5169// stub stub
5170// +-------+ +-------+ +---------+ +---------+
5171// | xapp2 | | xapp1 | | submgr | | e2term |
5172// +-------+ +-------+ +---------+ +---------+
5173// | | | |
5174// | | RESTSubReq1 | |
5175// | |---------------->| |
5176// | | | |
5177// | | RESTSubResp1 | |
5178// | |<----------------| |
5179// | | | |
5180// | | | SubReq1 |
5181// | | |------------->|
5182// | | | SubResp1 |
5183// | | |<-------------|
5184// | | RESTNotif1 | |
5185// | |<----------------| |
5186// | | | |
5187// | RESTSubReq2 | |
5188// |------------------------------>| |
5189// | | | |
5190// | RESTSubResp2 | |
5191// |<------------------------------| |
5192// | | | |
5193// | | RESTNotif2 | |
5194// |<------------------------------| |
5195// | | | |
5196// | | Submgr restart |
5197// | | | |
5198// | | RESTSubDelReq1 | |
5199// | |---------------->| |
5200// | | | |
5201// | | RESTSubDelResp1 | |
5202// | |<----------------| |
5203// | | | |
5204// | | Submgr restart |
5205// | | | |
5206// | RESTSubDelReq2 | |
5207// |------------------------------>| |
5208// | | | |
5209// | RESTSubDelResp2 | |
5210// |<------------------------------| |
5211// | | | |
5212// | | | SubDelReq2 |
5213// | | |------------->|
5214// | | | |
5215// | | | SubDelResp2 |
5216// | | |<-------------|
5217// | | | |
5218//
5219//-----------------------------------------------------------------------------
5220func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5221 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5222
5223 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005224 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005225 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005226 Counter{cSubReqToE2, 1},
5227 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005228 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005229 Counter{cMergedSubscriptions, 1},
5230 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005231 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005232 Counter{cSubDelReqToE2, 1},
5233 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005234 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005235 })
5236
archaggeafbf95f2021-04-14 08:54:05 +03005237 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005238 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005239 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005240 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005241
5242 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005243 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005244 params.SetMeid("RAN_NAME_1")
5245 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005246 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005247 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005248 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005249 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005250 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005251
5252 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5253
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005254 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005255 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5256
5257 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5258 // That needs to be completed before successful subscription delete is possible
5259 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005260
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005261 // Delete subscription 1, and wait until it has removed the first endpoint
5262 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005263 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005264 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005265
Anssi Mannila54838ed2021-11-19 11:25:01 +02005266 // Above wait does not work correctly anymore as this delay makes this test case work
5267 //<-time.After(time.Second * 1)
5268
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005269 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005270 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5271
5272 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5273 // That needs to be completed before successful subscription query is possible
5274 <-time.After(time.Second * 1)
5275
archaggeafbf95f2021-04-14 08:54:05 +03005276 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5277
5278 // Delete subscription 2
5279 deleteXapp2Subscription(t, &restSubId2)
5280
5281 //Wait that subs is cleaned
5282 waitSubsCleanup(t, e2SubsId2, 10)
5283
5284 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005285 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005286}
5287
5288//-----------------------------------------------------------------------------
5289// TestRESTReportSubReqAndSubDelOk
5290//
5291// stub stub
5292// +-------+ +---------+ +---------+
5293// | xapp | | submgr | | e2term |
5294// +-------+ +---------+ +---------+
5295// | | |
5296// | RestSubReq | |
5297// |---------------->| |
5298// | | |
5299// | RESTSubResp | |
5300// |<----------------| |
5301// | | |
5302// | | SubReq |
5303// | |------------->|
5304// | | |
5305// | | SubResp |
5306// | |<-------------|
5307// | RESTNotif | |
5308// |<----------------| |
5309// | | SubReq |
5310// | |------------->|
5311// | | |
5312// | | SubResp |
5313// | |<-------------|
5314// | RESTNotif | |
5315// |<----------------| |
5316// | ... | ... |
5317// | | |
5318// | | |
5319// | RESTSubDelReq | |
5320// |---------------->| |
5321// | | |
5322// | | SubDelReq |
5323// | |------------->|
5324// | | |
5325// | | SubDelResp |
5326// | |<-------------|
5327// | | |
5328// | RESTSubDelResp| |
5329// |<----------------| |
5330//
5331//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005332
archaggeafbf95f2021-04-14 08:54:05 +03005333func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5334 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005335 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005336 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005337 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005338}
5339
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005340func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005341 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005342
5343 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005344 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005345 restSubId := xappConn1.SendRESTSubsReq(t, params)
5346
5347 var e2SubsId []uint32
5348 for i := 0; i < subReqCount; i++ {
5349 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5350 xappConn1.ExpectRESTNotification(t, restSubId)
5351
5352 e2termConn1.SendSubsResp(t, crereq, cremsg)
5353 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005354 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005355 e2SubsId = append(e2SubsId, instanceId)
5356 resp, _ := xapp.Subscription.QuerySubscriptions()
5357 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5358 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5359 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5360
5361 }
5362
5363 // Del
5364 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5365
5366 for i := 0; i < subReqCount; i++ {
5367 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5368 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5369 }
5370
5371 // Wait that subs is cleaned
5372 for i := 0; i < subReqCount; i++ {
5373 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5374 }
5375
5376 xappConn1.TestMsgChanEmpty(t)
5377 e2termConn1.TestMsgChanEmpty(t)
5378 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005379 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005380}
5381
5382/*
Anssi Mannila54838ed2021-11-19 11:25:01 +02005383func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { was in comments already
archaggeafbf95f2021-04-14 08:54:05 +03005384 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5385
5386 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005387 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005388 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005389
5390 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005391 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005392 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005393}
5394*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005395func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005396 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005397
5398 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005399 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005400 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005401
5402 var e2SubsId []uint32
5403 for i := 0; i < subReqCount; i++ {
5404 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5405 xappConn1.ExpectRESTNotification(t, restSubId)
5406 e2termConn1.SendSubsResp(t, crereq, cremsg)
5407 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005408 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005409 e2SubsId = append(e2SubsId, instanceId)
5410 }
5411
5412 // Del
5413 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5414
5415 for i := 0; i < subReqCount; i++ {
5416 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5417 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5418 }
5419
5420 // Wait that subs is cleaned
5421 for i := 0; i < subReqCount; i++ {
5422 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5423 }
5424 xappConn1.TestMsgChanEmpty(t)
5425 e2termConn1.TestMsgChanEmpty(t)
5426 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005427 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005428}
5429
archaggeafbf95f2021-04-14 08:54:05 +03005430func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5431
archaggeafbf95f2021-04-14 08:54:05 +03005432 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005433 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005434 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005435 Counter{cSubReqToE2, 2},
5436 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005437 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005439 Counter{cSubDelReqToE2, 2},
5440 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005441 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005442 })
5443
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005444 const subReqCount int = 2
5445
archaggeafbf95f2021-04-14 08:54:05 +03005446 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005447 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005448 restSubId := xappConn1.SendRESTSubsReq(t, params)
5449 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5450
5451 assert.Equal(t, len(e2SubsIds), 2)
5452
5453 // Del
5454 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5455 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5456
5457 xappConn1.TestMsgChanEmpty(t)
5458 e2termConn1.TestMsgChanEmpty(t)
5459 mainCtrl.wait_registry_empty(t, 10)
5460
5461 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005462 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005463}
archaggeafbf95f2021-04-14 08:54:05 +03005464func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5465
archaggeafbf95f2021-04-14 08:54:05 +03005466 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005467 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005468 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005469 Counter{cSubReqToE2, 19},
5470 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005471 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005472 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005473 Counter{cSubDelReqToE2, 19},
5474 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005475 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005476 })
5477
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005478 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005479 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005480 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005481 restSubId := xappConn1.SendRESTSubsReq(t, params)
5482 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5483
5484 assert.Equal(t, len(e2SubsIds), 19)
5485
5486 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5487 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5488
5489 xappConn1.TestMsgChanEmpty(t)
5490 e2termConn1.TestMsgChanEmpty(t)
5491 mainCtrl.wait_registry_empty(t, 10)
5492
5493 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005494 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005495}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005496
archaggeafbf95f2021-04-14 08:54:05 +03005497func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5498
5499 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005500
5501 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005502 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005503 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005504 Counter{cSubReqToE2, uint64(subReqCount)},
5505 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005506 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005507 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005508 Counter{cSubDelReqToE2, uint64(subReqCount)},
5509 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005510 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005511 })
5512
5513 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005514 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005515 restSubId := xappConn1.SendRESTSubsReq(t, params)
5516 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5517
5518 assert.Equal(t, len(e2SubsIds), subReqCount)
5519
5520 // Del
5521 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5522 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5523
5524 xappConn1.TestMsgChanEmpty(t)
5525 e2termConn1.TestMsgChanEmpty(t)
5526 mainCtrl.wait_registry_empty(t, 10)
5527
5528 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005529 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005530}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005531
archaggeafbf95f2021-04-14 08:54:05 +03005532func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5533
5534 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005535
5536 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005537 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005538 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005539 Counter{cSubReqToE2, uint64(subReqCount)},
5540 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005541 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005542 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005543 Counter{cSubDelReqToE2, uint64(subReqCount)},
5544 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005545 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005546 })
5547
5548 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005549 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005550 restSubId := xappConn1.SendRESTSubsReq(t, params)
5551 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5552
5553 assert.Equal(t, len(e2SubsIds), subReqCount)
5554
5555 // Del
5556 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5557 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5558
5559 xappConn1.TestMsgChanEmpty(t)
5560 e2termConn1.TestMsgChanEmpty(t)
5561 mainCtrl.wait_registry_empty(t, 10)
5562
5563 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005564 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005565}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005566
archaggeafbf95f2021-04-14 08:54:05 +03005567func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5568
5569 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005570
5571 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005572 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005573 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005574 Counter{cSubReqToE2, uint64(subReqCount)},
5575 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005576 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005577 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005578 Counter{cSubDelReqToE2, uint64(subReqCount)},
5579 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005580 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005581 })
5582
5583 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005584 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005585 restSubId := xappConn1.SendRESTSubsReq(t, params)
5586 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5587
5588 assert.Equal(t, len(e2SubsIds), subReqCount)
5589
5590 // Del
5591 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5592 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5593
5594 xappConn1.TestMsgChanEmpty(t)
5595 e2termConn1.TestMsgChanEmpty(t)
5596 mainCtrl.wait_registry_empty(t, 10)
5597
5598 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005599 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005600}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005601
5602func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5603 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5604
5605 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005606 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005607 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005608 Counter{cSubReqToE2, 2},
5609 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005610 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005611 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005612 Counter{cSubDelReqToE2, 2},
5613 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005614 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005615 })
5616
5617 // Req1
5618 var params *teststube2ap.RESTSubsReqParams = nil
5619
5620 //Subs Create
5621 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005622 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005623
5624 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5625
5626 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005627 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005628 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005629 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005630 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5631
5632 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005633 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005634 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5635 xappConn2.ExpectRESTNotification(t, restSubId2)
5636 e2termConn1.SendSubsResp(t, crereq, cremsg)
5637 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5638
5639 deleteXapp1Subscription(t, &restSubId1)
5640 deleteXapp2Subscription(t, &restSubId2)
5641
5642 waitSubsCleanup(t, e2SubsId1, 10)
5643 waitSubsCleanup(t, e2SubsId2, 10)
5644
5645 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005646 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005647}
5648
5649func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5650 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5651
5652 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005653 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005654 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005655 Counter{cSubReqToE2, 2},
5656 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005657 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005658 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005659 Counter{cSubDelReqToE2, 2},
5660 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005661 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005662 })
5663
5664 // Req1
5665 var params *teststube2ap.RESTSubsReqParams = nil
5666
5667 //Subs Create
5668 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005669 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005670
5671 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5672
5673 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005674 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005675 params.SetMeid("RAN_NAME_1")
5676
5677 actionId := int64(1)
5678 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005679 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005680 subsequestActionType := "continue"
5681 timeToWait := "w10ms"
5682 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5683
5684 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005685 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005686 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5687 xappConn2.ExpectRESTNotification(t, restSubId2)
5688 e2termConn1.SendSubsResp(t, crereq, cremsg)
5689 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5690
5691 deleteXapp1Subscription(t, &restSubId1)
5692 deleteXapp2Subscription(t, &restSubId2)
5693
5694 waitSubsCleanup(t, e2SubsId1, 10)
5695 waitSubsCleanup(t, e2SubsId2, 10)
5696
5697 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005698 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005699}
5700
5701func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5702 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5703
5704 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005705 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005706 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005707 Counter{cSubReqToE2, 2},
5708 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005709 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005710 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005711 Counter{cSubDelReqToE2, 2},
5712 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005713 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005714 })
5715
5716 // Req1
5717 var params *teststube2ap.RESTSubsReqParams = nil
5718
5719 //Subs Create
5720 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005721 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005722
5723 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5724
5725 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005726 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005727 params.SetMeid("RAN_NAME_1")
5728 params.SetSubActionIDs(int64(2))
5729
5730 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005731 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005732 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5733 xappConn2.ExpectRESTNotification(t, restSubId2)
5734 e2termConn1.SendSubsResp(t, crereq, cremsg)
5735 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5736
5737 deleteXapp1Subscription(t, &restSubId1)
5738 deleteXapp2Subscription(t, &restSubId2)
5739
5740 waitSubsCleanup(t, e2SubsId1, 10)
5741 waitSubsCleanup(t, e2SubsId2, 10)
5742
5743 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005744 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005745}
5746
5747func TestRESTSubReqDiffActionType(t *testing.T) {
5748 CaseBegin("TestRESTSubReqDiffActionType")
5749
5750 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005751 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005752 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005753 Counter{cSubReqToE2, 2},
5754 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005755 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005756 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005757 Counter{cSubDelReqToE2, 2},
5758 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005759 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005760 })
5761
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005762 const e2Timeout int64 = 2
5763 const e2RetryCount int64 = 2
5764 const routingNeeded bool = true
5765
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005766 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005767 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005768 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005769
5770 //Subs Create
5771 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005772 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005773
5774 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5775
5776 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005777 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005778 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005779 params.SetMeid("RAN_NAME_1")
5780
5781 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005782 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005783 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5784 xappConn2.ExpectRESTNotification(t, restSubId2)
5785 e2termConn1.SendSubsResp(t, crereq, cremsg)
5786 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5787
5788 deleteXapp1Subscription(t, &restSubId1)
5789 deleteXapp2Subscription(t, &restSubId2)
5790
5791 waitSubsCleanup(t, e2SubsId1, 10)
5792 waitSubsCleanup(t, e2SubsId2, 10)
5793
5794 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005795 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005796}
5797
5798func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5799 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5800
5801 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005802 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005803 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005804 Counter{cSubReqToE2, 2},
5805 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005806 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005807 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005808 Counter{cSubDelReqToE2, 2},
5809 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005810 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005811 })
5812
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005813 const e2Timeout int64 = 2
5814 const e2RetryCount int64 = 2
5815 const routingNeeded bool = true
5816
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005817 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005818 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005819 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005820
5821 //Subs Create
5822 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005823 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005824
5825 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5826
5827 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005828 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005829 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005830 params.SetMeid("RAN_NAME_1")
5831
5832 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005833 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005834 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5835 xappConn2.ExpectRESTNotification(t, restSubId2)
5836 e2termConn1.SendSubsResp(t, crereq, cremsg)
5837 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5838
5839 deleteXapp1Subscription(t, &restSubId1)
5840 deleteXapp2Subscription(t, &restSubId2)
5841
5842 waitSubsCleanup(t, e2SubsId1, 10)
5843 waitSubsCleanup(t, e2SubsId2, 10)
5844
5845 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005846 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005847}
5848
5849func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5850 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5851
5852 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005853 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005854 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005855 Counter{cSubReqToE2, 2},
5856 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005857 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005859 Counter{cSubDelReqToE2, 2},
5860 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005861 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005862 })
5863
5864 // Req1
5865 var params *teststube2ap.RESTSubsReqParams = nil
5866
5867 //Subs Create
5868 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005869 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005870
5871 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5872
5873 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005874 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005875 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005876 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005877 params.SetSubActionDefinition(actionDefinition)
5878
5879 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005880 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005881 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5882 xappConn2.ExpectRESTNotification(t, restSubId2)
5883 e2termConn1.SendSubsResp(t, crereq, cremsg)
5884 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5885
5886 deleteXapp1Subscription(t, &restSubId1)
5887 deleteXapp2Subscription(t, &restSubId2)
5888
5889 waitSubsCleanup(t, e2SubsId1, 10)
5890 waitSubsCleanup(t, e2SubsId2, 10)
5891
5892 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005893 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005894}
5895
5896func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5897 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5898
5899 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005900 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005901 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005902 Counter{cSubReqToE2, 2},
5903 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005904 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005905 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005906 Counter{cSubDelReqToE2, 2},
5907 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005908 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005909 })
5910
5911 // Req1
5912 var params *teststube2ap.RESTSubsReqParams = nil
5913
5914 //Subs Create
5915 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005916 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005917
5918 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5919
5920 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005921 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005922 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005923 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005924 params.SetSubActionDefinition(actionDefinition)
5925
5926 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005927 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005928 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5929 xappConn2.ExpectRESTNotification(t, restSubId2)
5930 e2termConn1.SendSubsResp(t, crereq, cremsg)
5931 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5932
5933 deleteXapp1Subscription(t, &restSubId1)
5934 deleteXapp2Subscription(t, &restSubId2)
5935
5936 waitSubsCleanup(t, e2SubsId1, 10)
5937 waitSubsCleanup(t, e2SubsId2, 10)
5938
5939 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005940 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005941}
5942
5943func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5944 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5945
5946 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005947 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005948 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005949 Counter{cSubReqToE2, 2},
5950 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005951 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005952 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005953 Counter{cSubDelReqToE2, 2},
5954 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005955 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005956 })
5957
5958 // Req1
5959 var params *teststube2ap.RESTSubsReqParams = nil
5960
5961 //Subs Create
5962 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005963 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005964
5965 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5966
5967 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005968 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005969 params.SetMeid("RAN_NAME_1")
5970 params.SetTimeToWait("w200ms")
5971 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005972 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005973 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5974 xappConn2.ExpectRESTNotification(t, restSubId2)
5975 e2termConn1.SendSubsResp(t, crereq, cremsg)
5976 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5977
5978 deleteXapp1Subscription(t, &restSubId1)
5979 deleteXapp2Subscription(t, &restSubId2)
5980
5981 waitSubsCleanup(t, e2SubsId1, 10)
5982 waitSubsCleanup(t, e2SubsId2, 10)
5983
5984 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005985 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005986}
5987
Anssi Mannila51122392021-05-25 11:51:31 +03005988//-----------------------------------------------------------------------------
5989// TestRESTUnpackSubscriptionResponseDecodeFail
5990//
5991// stub stub
5992// +-------+ +---------+ +---------+
5993// | xapp | | submgr | | e2term |
5994// +-------+ +---------+ +---------+
5995// | | |
5996// | RestSubReq | |
5997// |---------------->| |
5998// | | |
5999// | RESTSubResp | |
6000// |<----------------| |
6001// | | |
6002// | | SubReq |
6003// | |------------->|
6004// | | |
6005// | | SubResp | ASN.1 decode fails
6006// | |<-------------|
6007// | | |
6008// | | SubReq |
6009// | |------------->|
6010// | | |
6011// | | SubFail | Duplicated action
6012// | |<-------------|
6013// | RESTNotif (fail)| |
6014// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006015// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006016//
6017//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006018
Anssi Mannila51122392021-05-25 11:51:31 +03006019func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006020 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
6021 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006022
6023 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006024 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006025 restSubId := xappConn1.SendRESTSubsReq(t, params)
6026
6027 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6028 // Decode of this response fails which will result resending original request
6029 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6030
6031 _, cremsg = e2termConn1.RecvSubsReq(t)
6032
Markku Virtanen55d2a282021-06-04 14:46:56 +03006033 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006034
6035 // Subscription already created in E2 Node.
6036 fparams := &teststube2ap.E2StubSubsFailParams{}
6037 fparams.Set(crereq)
6038 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6039 e2termConn1.SendSubsFail(t, fparams, cremsg)
6040
Anssi Mannila51122392021-05-25 11:51:31 +03006041 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006042 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006043
Anssi Mannilab43397e2021-11-16 12:06:16 +02006044 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6045
Anssi Mannila51122392021-05-25 11:51:31 +03006046 // Wait that subs is cleaned
6047 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6048
6049 xappConn1.TestMsgChanEmpty(t)
6050 e2termConn1.TestMsgChanEmpty(t)
6051 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006052 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006053}
6054
6055//-----------------------------------------------------------------------------
6056// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6057//
6058// stub stub
6059// +-------+ +---------+ +---------+
6060// | xapp | | submgr | | e2term |
6061// +-------+ +---------+ +---------+
6062// | | |
6063// | RestSubReq | |
6064// |---------------->| |
6065// | | |
6066// | RESTSubResp | |
6067// |<----------------| |
6068// | | |
6069// | | SubReq |
6070// | |------------->|
6071// | | |
6072// | | SubResp | Unknown instanceId
6073// | |<-------------|
6074// | | |
6075// | | SubReq |
6076// | |------------->|
6077// | | |
6078// | | SubFail | Duplicated action
6079// | |<-------------|
6080// | RESTNotif (fail)| |
6081// |<----------------| |
6082// | | SubDelReq |
6083// | |------------->|
6084// | | |
6085// | | SubDelResp |
6086// | |<-------------|
6087//
6088//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006089
Anssi Mannila51122392021-05-25 11:51:31 +03006090func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006091 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6092 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006093
6094 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006095 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006096 restSubId := xappConn1.SendRESTSubsReq(t, params)
6097
6098 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6099
6100 // Unknown instanceId in this response which will result resending original request
6101 orgInstanceId := crereq.RequestId.InstanceId
6102 crereq.RequestId.InstanceId = 0
6103 e2termConn1.SendSubsResp(t, crereq, cremsg)
6104
6105 _, cremsg = e2termConn1.RecvSubsReq(t)
6106
Markku Virtanen55d2a282021-06-04 14:46:56 +03006107 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006108
6109 // Subscription already created in E2 Node.
6110 fparams := &teststube2ap.E2StubSubsFailParams{}
6111 fparams.Set(crereq)
6112 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6113 e2termConn1.SendSubsFail(t, fparams, cremsg)
6114
6115 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6116 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6117
6118 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006119 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006120
Anssi Mannilab43397e2021-11-16 12:06:16 +02006121 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6122
Anssi Mannila51122392021-05-25 11:51:31 +03006123 // Wait that subs is cleaned
6124 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6125
6126 xappConn1.TestMsgChanEmpty(t)
6127 e2termConn1.TestMsgChanEmpty(t)
6128 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006129 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006130}
6131
6132//-----------------------------------------------------------------------------
6133// TestRESTUnpackSubscriptionResponseNoTransaction
6134//
6135// stub stub
6136// +-------+ +---------+ +---------+
6137// | xapp | | submgr | | e2term |
6138// +-------+ +---------+ +---------+
6139// | | |
6140// | RestSubReq | |
6141// |---------------->| |
6142// | | |
6143// | RESTSubResp | |
6144// |<----------------| |
6145// | | |
6146// | | SubReq |
6147// | |------------->|
6148// | | |
6149// | | SubResp | No transaction for the response
6150// | |<-------------|
6151// | | |
6152// | | SubReq |
6153// | |------------->|
6154// | | |
6155// | | SubFail | Duplicated action
6156// | |<-------------|
6157// | RESTNotif (fail)| |
6158// |<----------------| |
6159// | | SubDelReq |
6160// | |------------->|
6161// | | |
6162// | | SubDelResp |
6163// | |<-------------|
6164// | | |
6165// | | SubDelReq |
6166// | |------------->|
6167// | | |
6168// | | SubDelResp |
6169// | |<-------------|
6170//
6171//-----------------------------------------------------------------------------
6172func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006173 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6174 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006175
6176 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006177 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006178 restSubId := xappConn1.SendRESTSubsReq(t, params)
6179
6180 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6181
6182 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6183 // No transaction exist for this response which will result resending original request
6184 e2termConn1.SendSubsResp(t, crereq, cremsg)
6185
6186 _, cremsg = e2termConn1.RecvSubsReq(t)
6187
Markku Virtanen55d2a282021-06-04 14:46:56 +03006188 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006189
6190 // Subscription already created in E2 Node.
6191 fparams := &teststube2ap.E2StubSubsFailParams{}
6192 fparams.Set(crereq)
6193 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6194 e2termConn1.SendSubsFail(t, fparams, cremsg)
6195
6196 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6197 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6198
6199 // Resending happens because there no transaction
6200 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6201 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6202
6203 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006204 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006205
Anssi Mannilab43397e2021-11-16 12:06:16 +02006206 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6207
Anssi Mannila51122392021-05-25 11:51:31 +03006208 // Wait that subs is cleaned
6209 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6210
6211 xappConn1.TestMsgChanEmpty(t)
6212 e2termConn1.TestMsgChanEmpty(t)
6213 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006214 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006215}
6216
6217//-----------------------------------------------------------------------------
6218// TestRESTUnpackSubscriptionFailureDecodeFail
6219//
6220// stub stub
6221// +-------+ +---------+ +---------+
6222// | xapp | | submgr | | e2term |
6223// +-------+ +---------+ +---------+
6224// | | |
6225// | RestSubReq | |
6226// |---------------->| |
6227// | | |
6228// | RESTSubResp | |
6229// |<----------------| |
6230// | | |
6231// | | SubReq |
6232// | |------------->|
6233// | | |
6234// | | SubFail | ASN.1 decode fails
6235// | |<-------------|
6236// | | |
6237// | | SubReq |
6238// | |------------->|
6239// | | |
6240// | | SubFail | Duplicated action
6241// | |<-------------|
6242// | RESTNotif (fail)| |
6243// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006244// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006245//
6246//-----------------------------------------------------------------------------
6247func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006248 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6249 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006250
6251 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006252 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006253 restSubId := xappConn1.SendRESTSubsReq(t, params)
6254
6255 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6256
6257 // Decode of this response fails which will result resending original request
6258 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6259
6260 _, cremsg = e2termConn1.RecvSubsReq(t)
6261
Markku Virtanen55d2a282021-06-04 14:46:56 +03006262 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006263
6264 // Subscription already created in E2 Node.
6265 fparams := &teststube2ap.E2StubSubsFailParams{}
6266 fparams.Set(crereq)
6267 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6268 e2termConn1.SendSubsFail(t, fparams, cremsg)
6269
Anssi Mannila51122392021-05-25 11:51:31 +03006270 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006271 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006272
Anssi Mannilab43397e2021-11-16 12:06:16 +02006273 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6274
Anssi Mannila51122392021-05-25 11:51:31 +03006275 // Wait that subs is cleaned
6276 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6277
6278 xappConn1.TestMsgChanEmpty(t)
6279 e2termConn1.TestMsgChanEmpty(t)
6280 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006281 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006282}
6283
6284//-----------------------------------------------------------------------------
6285// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6286//
6287// stub stub
6288// +-------+ +---------+ +---------+
6289// | xapp | | submgr | | e2term |
6290// +-------+ +---------+ +---------+
6291// | | |
6292// | RestSubReq | |
6293// |---------------->| |
6294// | | |
6295// | RESTSubResp | |
6296// |<----------------| |
6297// | | |
6298// | | SubReq |
6299// | |------------->|
6300// | | |
6301// | | SubFail | Unknown instanceId
6302// | |<-------------|
6303// | | |
6304// | | SubReq |
6305// | |------------->|
6306// | | |
6307// | | SubFail | Duplicated action
6308// | |<-------------|
6309// | RESTNotif (fail)| |
6310// |<----------------| |
6311// | | SubDelReq |
6312// | |------------->|
6313// | | |
6314// | | SubDelResp |
6315// | |<-------------|
6316//
6317//-----------------------------------------------------------------------------
6318func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006319 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6320 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006321
6322 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006323 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006324 restSubId := xappConn1.SendRESTSubsReq(t, params)
6325
6326 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6327
6328 // Unknown instanceId in this response which will result resending original request
6329 fparams := &teststube2ap.E2StubSubsFailParams{}
6330 fparams.Set(crereq)
6331 fparams.Fail.RequestId.InstanceId = 0
6332 e2termConn1.SendSubsFail(t, fparams, cremsg)
6333
6334 _, cremsg = e2termConn1.RecvSubsReq(t)
6335
Markku Virtanen55d2a282021-06-04 14:46:56 +03006336 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006337
6338 // Subscription already created in E2 Node.
6339 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6340 e2termConn1.SendSubsFail(t, fparams, cremsg)
6341
6342 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6343 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6344
6345 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006346 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006347
Anssi Mannilab43397e2021-11-16 12:06:16 +02006348 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6349
Anssi Mannila51122392021-05-25 11:51:31 +03006350 // Wait that subs is cleaned
6351 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6352
6353 xappConn1.TestMsgChanEmpty(t)
6354 e2termConn1.TestMsgChanEmpty(t)
6355 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006356 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006357}
6358
6359//-----------------------------------------------------------------------------
6360// TestRESTUnpackSubscriptionFailureNoTransaction
6361//
6362// stub stub
6363// +-------+ +---------+ +---------+
6364// | xapp | | submgr | | e2term |
6365// +-------+ +---------+ +---------+
6366// | | |
6367// | RestSubReq | |
6368// |---------------->| |
6369// | | |
6370// | RESTSubResp | |
6371// |<----------------| |
6372// | | |
6373// | | SubReq |
6374// | |------------->|
6375// | | |
6376// | | SubFail | No transaction for the response
6377// | |<-------------|
6378// | | |
6379// | | SubReq |
6380// | |------------->|
6381// | | |
6382// | | SubFail | Duplicated action
6383// | |<-------------|
6384// | RESTNotif (fail)| |
6385// |<----------------| |
6386// | | SubDelReq |
6387// | |------------->|
6388// | | |
6389// | | SubDelResp |
6390// | |<-------------|
6391//
6392//-----------------------------------------------------------------------------
6393func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006394 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6395 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006396
6397 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006398 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006399 restSubId := xappConn1.SendRESTSubsReq(t, params)
6400
6401 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6402
6403 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6404
6405 // No transaction exist for this response which will result resending original request
6406 fparams := &teststube2ap.E2StubSubsFailParams{}
6407 fparams.Set(crereq)
6408 e2termConn1.SendSubsFail(t, fparams, cremsg)
6409
6410 _, cremsg = e2termConn1.RecvSubsReq(t)
6411
Markku Virtanen55d2a282021-06-04 14:46:56 +03006412 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006413
6414 // Subscription already created in E2 Node.
6415 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6416 e2termConn1.SendSubsFail(t, fparams, cremsg)
6417
6418 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6419 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6420
6421 // Resending happens because there no transaction
6422 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6423 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6424
6425 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006426 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006427
Anssi Mannilab43397e2021-11-16 12:06:16 +02006428 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6429
Anssi Mannila51122392021-05-25 11:51:31 +03006430 // Wait that subs is cleaned
6431 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6432
6433 xappConn1.TestMsgChanEmpty(t)
6434 e2termConn1.TestMsgChanEmpty(t)
6435 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006436 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006437}
6438
6439//-----------------------------------------------------------------------------
6440// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6441//
6442// stub stub
6443// +-------+ +---------+ +---------+
6444// | xapp | | submgr | | e2term |
6445// +-------+ +---------+ +---------+
6446// | | |
6447// | [SUBS CREATE] |
6448// | | |
6449// | | |
6450// | RESTSubDelReq | |
6451// |---------------->| |
6452// | | |
6453// | RESTSubDelResp | |
6454// |<----------------| |
6455// | | |
6456// | | SubDelReq |
6457// | |------------->|
6458// | | |
6459// | | SubDelResp | ASN.1 decode fails
6460// | |<-------------|
6461// | | |
6462// | | SubDelReq |
6463// | |------------->|
6464// | | |
6465// | | SubDelFail | Subscription does exist any more
6466// | |<-------------|
6467// | | |
6468//
6469//-----------------------------------------------------------------------------
6470func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006471 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006472
6473 // Req
6474 var params *teststube2ap.RESTSubsReqParams = nil
6475 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6476
6477 // Del
6478 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6479
6480 // E2t: Receive 1st SubsDelReq
6481 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6482
6483 // Decode of this response fails which will result resending original request
6484 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6485
6486 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6487 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6488
6489 // Subscription does not exist in in E2 Node.
6490 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6491
6492 // Wait that subs is cleaned
6493 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6494
6495 xappConn1.TestMsgChanEmpty(t)
6496 e2termConn1.TestMsgChanEmpty(t)
6497 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006498 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006499}
6500
6501//-----------------------------------------------------------------------------
6502// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6503//
6504// stub stub
6505// +-------+ +---------+ +---------+
6506// | xapp | | submgr | | e2term |
6507// +-------+ +---------+ +---------+
6508// | | |
6509// | [SUBS CREATE] |
6510// | | |
6511// | | |
6512// | RESTSubDelReq | |
6513// |---------------->| |
6514// | | |
6515// | RESTSubDelResp | |
6516// |<----------------| |
6517// | | |
6518// | | SubDelReq |
6519// | |------------->|
6520// | | |
6521// | | SubDelResp | Unknown instanceId
6522// | |<-------------|
6523// | | |
6524// | | SubDelReq |
6525// | |------------->|
6526// | | |
6527// | | SubDelFail | Subscription does exist any more
6528// | |<-------------|
6529//
6530//-----------------------------------------------------------------------------
6531func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006532 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006533
6534 // Req
6535 var params *teststube2ap.RESTSubsReqParams = nil
6536 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6537
6538 // Del
6539 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6540
6541 // E2t: Receive 1st SubsDelReq
6542 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6543
6544 // Unknown instanceId in this response which will result resending original request
6545 delreq.RequestId.InstanceId = 0
6546 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6547
6548 // E2t: Receive 2nd SubsDelReq
6549 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6550
6551 // Subscription does not exist in in E2 Node.
6552 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6553
6554 // Wait that subs is cleaned
6555 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6556
6557 xappConn1.TestMsgChanEmpty(t)
6558 e2termConn1.TestMsgChanEmpty(t)
6559 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006560 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006561}
6562
6563//-----------------------------------------------------------------------------
6564// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6565//
6566// stub stub
6567// +-------+ +---------+ +---------+
6568// | xapp | | submgr | | e2term |
6569// +-------+ +---------+ +---------+
6570// | | |
6571// | [SUBS CREATE] |
6572// | | |
6573// | | |
6574// | RESTSubDelReq | |
6575// |---------------->| |
6576// | | |
6577// | RESTSubDelResp | |
6578// |<----------------| |
6579// | | |
6580// | | SubDelReq |
6581// | |------------->|
6582// | | |
6583// | | SubDelResp | No transaction for the response
6584// | |<-------------|
6585// | | |
6586// | | SubDelReq |
6587// | |------------->|
6588// | | |
6589// | | SubDelFail | Subscription does exist any more
6590// | |<-------------|
6591//
6592//-----------------------------------------------------------------------------
6593func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006594 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006595
6596 // Req
6597 var params *teststube2ap.RESTSubsReqParams = nil
6598 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6599
6600 // Del
6601 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6602
6603 // E2t: Receive 1st SubsDelReq
6604 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6605
6606 mainCtrl.MakeTransactionNil(t, e2SubsId)
6607
6608 // No transaction exist for this response which will result resending original request
6609 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6610
6611 // E2t: Receive 2nd SubsDelReq
6612 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6613
6614 // Subscription does not exist in in E2 Node.
6615 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6616
6617 // Wait that subs is cleaned
6618 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6619
6620 xappConn1.TestMsgChanEmpty(t)
6621 e2termConn1.TestMsgChanEmpty(t)
6622 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006623 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006624}
6625
6626//-----------------------------------------------------------------------------
6627// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6628//
6629// stub stub
6630// +-------+ +---------+ +---------+
6631// | xapp | | submgr | | e2term |
6632// +-------+ +---------+ +---------+
6633// | | |
6634// | [SUBS CREATE] |
6635// | | |
6636// | | |
6637// | RESTSubDelReq | |
6638// |---------------->| |
6639// | | |
6640// | RESTSubDelResp | |
6641// |<----------------| |
6642// | | |
6643// | | SubDelReq |
6644// | |------------->|
6645// | | |
6646// | | SubDelFail | ASN.1 decode fails
6647// | |<-------------|
6648// | | |
6649// | | SubDelReq |
6650// | |------------->|
6651// | | |
6652// | | SubDelFail | Subscription does exist any more
6653// | |<-------------|
6654//
6655//-----------------------------------------------------------------------------
6656func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006657 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006658
6659 // Req
6660 var params *teststube2ap.RESTSubsReqParams = nil
6661 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6662
6663 // Del
6664 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6665
6666 // E2t: Receive 1st SubsDelReq
6667 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6668
6669 // Decode of this response fails which will result resending original request
6670 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6671
6672 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6673 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6674
6675 // Subscription does not exist in in E2 Node.
6676 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6677
6678 // Wait that subs is cleaned
6679 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6680
6681 xappConn1.TestMsgChanEmpty(t)
6682 e2termConn1.TestMsgChanEmpty(t)
6683 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006684 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006685}
6686
6687//-----------------------------------------------------------------------------
6688// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6689//
6690// stub stub
6691// +-------+ +---------+ +---------+
6692// | xapp | | submgr | | e2term |
6693// +-------+ +---------+ +---------+
6694// | | |
6695// | [SUBS CREATE] |
6696// | | |
6697// | | |
6698// | RESTSubDelReq | |
6699// |---------------->| |
6700// | | |
6701// | RESTSubDelResp | |
6702// |<----------------| |
6703// | | |
6704// | | SubDelReq |
6705// | |------------->|
6706// | | |
6707// | | SubDelFail | Unknown instanceId
6708// | |<-------------|
6709// | | |
6710// | | SubDelReq |
6711// | |------------->|
6712// | | |
6713// | | SubDelFail | Subscription does exist any more
6714// | |<-------------|
6715//
6716//-----------------------------------------------------------------------------
6717func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006718 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006719
6720 // Req
6721 var params *teststube2ap.RESTSubsReqParams = nil
6722 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6723
6724 // Del
6725 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6726
6727 // E2t: Receive 1st SubsDelReq
6728 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6729
6730 // Unknown instanceId in this response which will result resending original request
6731 delreq.RequestId.InstanceId = 0
6732 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6733
6734 // E2t: Receive 2nd SubsDelReq
6735 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6736
6737 // Subscription does not exist in in E2 Node.
6738 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6739
6740 // Wait that subs is cleaned
6741 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6742
6743 xappConn1.TestMsgChanEmpty(t)
6744 e2termConn1.TestMsgChanEmpty(t)
6745 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006746 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006747}
6748
6749//-----------------------------------------------------------------------------
6750// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6751//
6752// stub stub
6753// +-------+ +---------+ +---------+
6754// | xapp | | submgr | | e2term |
6755// +-------+ +---------+ +---------+
6756// | | |
6757// | [SUBS CREATE] |
6758// | | |
6759// | | |
6760// | RESTSubDelReq | |
6761// |---------------->| |
6762// | | |
6763// | RESTSubDelResp | |
6764// |<----------------| |
6765// | | |
6766// | | SubDelReq |
6767// | |------------->|
6768// | | |
6769// | | SubDelFail | No transaction for the response
6770// | |<-------------|
6771// | | |
6772// | | SubDelReq |
6773// | |------------->|
6774// | | |
6775// | | SubDelFail | Subscription does exist any more
6776// | |<-------------|
6777//
6778//-----------------------------------------------------------------------------
6779func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006780 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006781
6782 // Req
6783 var params *teststube2ap.RESTSubsReqParams = nil
6784 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6785
6786 // Del
6787 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6788
6789 // E2t: Receive 1st SubsDelReq
6790 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6791
6792 mainCtrl.MakeTransactionNil(t, e2SubsId)
6793
6794 // No transaction exist for this response which will result resending original request
6795 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6796
6797 // E2t: Receive 2nd SubsDelReq
6798 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6799
6800 // Subscription does not exist in in E2 Node.
6801 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6802
6803 // Wait that subs is cleaned
6804 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6805
6806 xappConn1.TestMsgChanEmpty(t)
6807 e2termConn1.TestMsgChanEmpty(t)
6808 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006809 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006810}
6811
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006812//-----------------------------------------------------------------------------
6813// TestRESTSubReqFailAsn1PackSubReqError
6814//
6815// stub stub
6816// +-------+ +---------+ +---------+
6817// | xapp | | submgr | | e2term |
6818// +-------+ +---------+ +---------+
6819// | | |
6820// | RESTSubReq | |
6821// |---------------->| |
6822// | | |
6823// | RESTSubResp | |
6824// |<----------------| |
6825// | | |
6826// | ASN.1 encode fails |
6827// | | |
6828// | | SubDelReq |
6829// | |------------->|
6830// | | |
6831// | | SubDelFail |
6832// | |<-------------|
6833// | | |
6834// | RESTNotif | |
6835// | unsuccess | |
6836// |<----------------| |
6837// | | |
6838// | [SUBS DELETE] |
6839// | | |
6840//
6841//-----------------------------------------------------------------------------
6842func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6843
6844 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006845 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006846 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006847 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006848 Counter{cRestSubDelReqFromXapp, 1},
6849 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006850 })
6851
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006852 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006853
6854 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006855 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006856 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6857
6858 // Req
6859 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006860 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006861
6862 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006863 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006864
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006865 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006866 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006867
6868 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006869
6870 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6871
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006872 // Wait that subs is cleaned
6873 waitSubsCleanup(t, e2SubsId, 10)
6874 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006875 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006876}
6877
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006878func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6879 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6880
6881 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6882 Counter{cRestSubReqFromXapp, 2},
6883 Counter{cRestSubRespToXapp, 2},
6884 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006885 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006886 Counter{cSubRespFromE2, 1},
6887 Counter{cRestSubNotifToXapp, 1},
6888 Counter{cRestSubFailNotifToXapp, 1},
6889 Counter{cRestSubDelReqFromXapp, 1},
6890 Counter{cSubDelReqToE2, 1},
6891 Counter{cSubDelRespFromE2, 1},
6892 Counter{cRestSubDelRespToXapp, 1},
6893 })
6894
6895 const e2Timeout int64 = 1
6896 const e2RetryCount int64 = 0
6897 const routingNeeded bool = false
6898
6899 // Req1
6900 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6901 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6902
6903 // Subs Create
6904 restSubId := xappConn1.SendRESTSubsReq(t, params)
6905 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6906
6907 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6908 xappConn1.ExpectRESTNotification(t, restSubId)
6909 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6910 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6911 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6912
6913 // Policy change
6914 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6915 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6916 params.SetSubscriptionID(&restSubId)
6917 params.SetTimeToWait("w200ms")
6918 restSubId = xappConn1.SendRESTSubsReq(t, params)
6919 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6920
6921 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6922 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006923 // SubsResp is missing, e2SubsId will be 0
6924 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6925 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006926
6927 // Del
6928 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6929 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6930 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6931
6932 waitSubsCleanup(t, e2SubsId, 10)
6933
6934 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006935 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006936}
6937
6938//-----------------------------------------------------------------------------
6939// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6940//
6941// stub stub
6942// +-------+ +---------+ +---------+
6943// | xapp | | submgr | | e2term |
6944// +-------+ +---------+ +---------+
6945// | | |
6946// | RESTSubReq | |
6947// |---------------->| |
6948// | | |
6949// | RESTSubResp | |
6950// |<----------------| |
6951// | | SubReq |
6952// | |------------->|
6953// | | |
6954// | | SubResp |
6955// | |<-------------|
6956// | | |
6957// | RESTNotif | |
6958// |<----------------| |
6959// | | |
6960// | RESTSubReq | |
6961// |---------------->| |
6962// | | |
6963// | RESTSubResp | |
6964// |<----------------| |
6965// | | SubReq |
6966// | |------------->|
6967// | |
6968// | Submgr restart |
6969// | | |
6970// | RESTSubDelReq | |
6971// |---------------->| |
6972// | | |
6973// | | SubDelReq |
6974// | |------------->|
6975// | | |
6976// | | SubDelResp |
6977// | |<-------------|
6978// | | |
6979// | RESTSubDelResp | |
6980// |<----------------| |
6981//
6982//-----------------------------------------------------------------------------
6983
6984func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6985 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6986
6987 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6988 Counter{cRestSubReqFromXapp, 2},
6989 Counter{cRestSubRespToXapp, 2},
6990 Counter{cSubReqToE2, 2},
6991 Counter{cSubRespFromE2, 1},
6992 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006993 Counter{cRestSubDelReqFromXapp, 1},
6994 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006995 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006996 Counter{cRestSubDelRespToXapp, 1},
6997 })
6998
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006999 const e2Timeout int64 = 1
7000 const e2RetryCount int64 = 0
7001 const routingNeeded bool = false
7002
7003 // Req1
7004 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7005 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7006 // Create subscription
7007 restSubId := xappConn1.SendRESTSubsReq(t, params)
7008 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7009
7010 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7011 xappConn1.ExpectRESTNotification(t, restSubId)
7012 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7013 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7014 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7015
7016 // Check subscription
7017 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7018
7019 // Policy change
7020 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7021 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7022 params.SetSubscriptionID(&restSubId)
7023 params.SetTimeToWait("w200ms")
7024 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7025 restSubId = xappConn1.SendRESTSubsReq(t, params)
7026 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7027
7028 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7029 mainCtrl.SetResetTestFlag(t, false)
7030
7031 // SubsResp is missing due to submgr restart
7032
7033 mainCtrl.SimulateRestart(t)
7034 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7035
Anssi Mannila54838ed2021-11-19 11:25:01 +02007036 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
7037 // That needs to be completed before successful subscription query is possible
7038 <-time.After(time.Second * 1)
7039
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007040 // Check subscription
7041 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7042
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007043 // Delete subscription
7044 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7045 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7046 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7047
7048 //Wait that subs is cleaned
7049 waitSubsCleanup(t, e2SubsId, 10)
7050
7051 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007052 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007053}
7054
archaggeafbf95f2021-04-14 08:54:05 +03007055////////////////////////////////////////////////////////////////////////////////////
7056// Services for UT cases
7057////////////////////////////////////////////////////////////////////////////////////
7058const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007059const host string = "localhost"
7060
7061func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7062 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007063 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007064 }
7065 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007066 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007067
7068 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7069 fromXappConn.ExpectRESTNotification(t, restSubId)
7070 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7071 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007072 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007073
7074 return restSubId, e2SubsId
7075}
7076
7077func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7078
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007079 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007080 if meid != "" {
7081 params.SetMeid(meid)
7082 }
7083 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7084 restSubId := xappConn2.SendRESTSubsReq(t, params)
7085 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007086 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007087 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007088 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007089
7090 return restSubId, e2SubsId
7091}
7092
7093func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007094
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007095 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007096 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007097 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007098
7099 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7100 xappConn1.ExpectRESTNotification(t, restSubId)
7101 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7102 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007103 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007104
7105 return restSubId, e2SubsId
7106}
7107
7108func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007109 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007110 restSubId := xappConn1.SendRESTSubsReq(t, params)
7111
7112 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7113 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7114 fparams1.Set(crereq1)
7115 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7116
7117 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7118 xappConn1.ExpectRESTNotification(t, restSubId)
7119 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7120 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007121 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007122
7123 return restSubId, e2SubsId
7124}
7125
7126func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7127 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7128 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7129 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7130}
7131
7132func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7133 xappConn1.SendRESTSubsDelReq(t, restSubId)
7134 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7135 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7136}
7137
7138func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7139 xappConn2.SendRESTSubsDelReq(t, restSubId)
7140 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7141 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7142}
7143
7144func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7145 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02007146 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
7147 assert.Equal(t, meid, resp[0].Meid)
7148 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03007149}
7150
7151func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7152 //Wait that subs is cleaned
7153 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7154
7155 xappConn1.TestMsgChanEmpty(t)
7156 xappConn2.TestMsgChanEmpty(t)
7157 e2termConn1.TestMsgChanEmpty(t)
7158 mainCtrl.wait_registry_empty(t, timeout)
7159}
7160
7161func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7162
7163 var e2SubsId []uint32
7164
7165 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007166 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007167 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7168 fromXappConn.ExpectRESTNotification(t, restSubId)
7169 toE2termConn.SendSubsResp(t, crereq, cremsg)
7170 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7171 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007172 xapp.Logger.Debug("TEST: %v", e2SubsId)
7173 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007174 <-time.After(100 * time.Millisecond)
7175 }
7176 return e2SubsId
7177}
7178
7179func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7180
7181 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007182 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007183 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7184 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7185 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007186 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007187 <-time.After(100 * time.Millisecond)
7188 }
7189
7190 // Wait that subs is cleaned
7191 for i := 0; i < len(e2SubsIds); i++ {
7192 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7193 }
7194
7195}