blob: 2a3ad96216cf9436c55adb3ec1c589d673f704aa [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
archaggeafbf95f2021-04-14 08:54:05 +03005262 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02005263 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005264 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02005265
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005266 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005267 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5268
5269 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5270 // That needs to be completed before successful subscription query is possible
5271 <-time.After(time.Second * 1)
5272
archaggeafbf95f2021-04-14 08:54:05 +03005273 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5274
5275 // Delete subscription 2
5276 deleteXapp2Subscription(t, &restSubId2)
5277
5278 //Wait that subs is cleaned
5279 waitSubsCleanup(t, e2SubsId2, 10)
5280
5281 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005282 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005283}
5284
5285//-----------------------------------------------------------------------------
5286// TestRESTReportSubReqAndSubDelOk
5287//
5288// stub stub
5289// +-------+ +---------+ +---------+
5290// | xapp | | submgr | | e2term |
5291// +-------+ +---------+ +---------+
5292// | | |
5293// | RestSubReq | |
5294// |---------------->| |
5295// | | |
5296// | RESTSubResp | |
5297// |<----------------| |
5298// | | |
5299// | | SubReq |
5300// | |------------->|
5301// | | |
5302// | | SubResp |
5303// | |<-------------|
5304// | RESTNotif | |
5305// |<----------------| |
5306// | | SubReq |
5307// | |------------->|
5308// | | |
5309// | | SubResp |
5310// | |<-------------|
5311// | RESTNotif | |
5312// |<----------------| |
5313// | ... | ... |
5314// | | |
5315// | | |
5316// | RESTSubDelReq | |
5317// |---------------->| |
5318// | | |
5319// | | SubDelReq |
5320// | |------------->|
5321// | | |
5322// | | SubDelResp |
5323// | |<-------------|
5324// | | |
5325// | RESTSubDelResp| |
5326// |<----------------| |
5327//
5328//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005329
archaggeafbf95f2021-04-14 08:54:05 +03005330func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5331 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005332 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005333 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005334 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005335}
5336
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005337func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005338 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005339
5340 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005341 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005342 restSubId := xappConn1.SendRESTSubsReq(t, params)
5343
5344 var e2SubsId []uint32
5345 for i := 0; i < subReqCount; i++ {
5346 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5347 xappConn1.ExpectRESTNotification(t, restSubId)
5348
5349 e2termConn1.SendSubsResp(t, crereq, cremsg)
5350 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005351 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005352 e2SubsId = append(e2SubsId, instanceId)
5353 resp, _ := xapp.Subscription.QuerySubscriptions()
5354 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5355 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5356 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5357
5358 }
5359
5360 // Del
5361 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5362
5363 for i := 0; i < subReqCount; i++ {
5364 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5365 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5366 }
5367
5368 // Wait that subs is cleaned
5369 for i := 0; i < subReqCount; i++ {
5370 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5371 }
5372
5373 xappConn1.TestMsgChanEmpty(t)
5374 e2termConn1.TestMsgChanEmpty(t)
5375 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005376 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005377}
5378
5379/*
Anssi Mannila54838ed2021-11-19 11:25:01 +02005380func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { was in comments already
archaggeafbf95f2021-04-14 08:54:05 +03005381 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5382
5383 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005384 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005385 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005386
5387 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005388 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005389 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005390}
5391*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005392func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005393 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005394
5395 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005396 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005397 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005398
5399 var e2SubsId []uint32
5400 for i := 0; i < subReqCount; i++ {
5401 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5402 xappConn1.ExpectRESTNotification(t, restSubId)
5403 e2termConn1.SendSubsResp(t, crereq, cremsg)
5404 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005405 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005406 e2SubsId = append(e2SubsId, instanceId)
5407 }
5408
5409 // Del
5410 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5411
5412 for i := 0; i < subReqCount; i++ {
5413 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5414 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5415 }
5416
5417 // Wait that subs is cleaned
5418 for i := 0; i < subReqCount; i++ {
5419 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5420 }
5421 xappConn1.TestMsgChanEmpty(t)
5422 e2termConn1.TestMsgChanEmpty(t)
5423 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005424 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005425}
5426
archaggeafbf95f2021-04-14 08:54:05 +03005427func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5428
archaggeafbf95f2021-04-14 08:54:05 +03005429 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005430 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005431 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005432 Counter{cSubReqToE2, 2},
5433 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005434 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005435 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005436 Counter{cSubDelReqToE2, 2},
5437 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005439 })
5440
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005441 const subReqCount int = 2
5442
archaggeafbf95f2021-04-14 08:54:05 +03005443 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005444 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005445 restSubId := xappConn1.SendRESTSubsReq(t, params)
5446 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5447
5448 assert.Equal(t, len(e2SubsIds), 2)
5449
5450 // Del
5451 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5452 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5453
5454 xappConn1.TestMsgChanEmpty(t)
5455 e2termConn1.TestMsgChanEmpty(t)
5456 mainCtrl.wait_registry_empty(t, 10)
5457
5458 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005459 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005460}
archaggeafbf95f2021-04-14 08:54:05 +03005461func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5462
archaggeafbf95f2021-04-14 08:54:05 +03005463 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005464 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005465 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005466 Counter{cSubReqToE2, 19},
5467 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005468 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005469 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005470 Counter{cSubDelReqToE2, 19},
5471 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005472 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005473 })
5474
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005475 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005476 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005477 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005478 restSubId := xappConn1.SendRESTSubsReq(t, params)
5479 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5480
5481 assert.Equal(t, len(e2SubsIds), 19)
5482
5483 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5484 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5485
5486 xappConn1.TestMsgChanEmpty(t)
5487 e2termConn1.TestMsgChanEmpty(t)
5488 mainCtrl.wait_registry_empty(t, 10)
5489
5490 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005491 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005492}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005493
archaggeafbf95f2021-04-14 08:54:05 +03005494func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5495
5496 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005497
5498 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005499 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005500 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005501 Counter{cSubReqToE2, uint64(subReqCount)},
5502 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005503 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005504 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005505 Counter{cSubDelReqToE2, uint64(subReqCount)},
5506 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005507 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005508 })
5509
5510 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005511 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005512 restSubId := xappConn1.SendRESTSubsReq(t, params)
5513 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5514
5515 assert.Equal(t, len(e2SubsIds), subReqCount)
5516
5517 // Del
5518 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5519 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5520
5521 xappConn1.TestMsgChanEmpty(t)
5522 e2termConn1.TestMsgChanEmpty(t)
5523 mainCtrl.wait_registry_empty(t, 10)
5524
5525 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005526 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005527}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005528
archaggeafbf95f2021-04-14 08:54:05 +03005529func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5530
5531 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005532
5533 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005534 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005535 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005536 Counter{cSubReqToE2, uint64(subReqCount)},
5537 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005538 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005539 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005540 Counter{cSubDelReqToE2, uint64(subReqCount)},
5541 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005542 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005543 })
5544
5545 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005546 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005547 restSubId := xappConn1.SendRESTSubsReq(t, params)
5548 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5549
5550 assert.Equal(t, len(e2SubsIds), subReqCount)
5551
5552 // Del
5553 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5554 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5555
5556 xappConn1.TestMsgChanEmpty(t)
5557 e2termConn1.TestMsgChanEmpty(t)
5558 mainCtrl.wait_registry_empty(t, 10)
5559
5560 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005561 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005562}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005563
archaggeafbf95f2021-04-14 08:54:05 +03005564func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5565
5566 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005567
5568 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005569 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005570 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005571 Counter{cSubReqToE2, uint64(subReqCount)},
5572 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005573 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005574 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005575 Counter{cSubDelReqToE2, uint64(subReqCount)},
5576 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005577 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005578 })
5579
5580 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005581 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005582 restSubId := xappConn1.SendRESTSubsReq(t, params)
5583 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5584
5585 assert.Equal(t, len(e2SubsIds), subReqCount)
5586
5587 // Del
5588 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5589 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5590
5591 xappConn1.TestMsgChanEmpty(t)
5592 e2termConn1.TestMsgChanEmpty(t)
5593 mainCtrl.wait_registry_empty(t, 10)
5594
5595 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005596 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005597}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005598
5599func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5600 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5601
5602 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005603 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005604 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005605 Counter{cSubReqToE2, 2},
5606 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005607 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005608 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005609 Counter{cSubDelReqToE2, 2},
5610 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005611 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005612 })
5613
5614 // Req1
5615 var params *teststube2ap.RESTSubsReqParams = nil
5616
5617 //Subs Create
5618 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005619 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005620
5621 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5622
5623 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005624 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005625 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005626 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005627 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5628
5629 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005630 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005631 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5632 xappConn2.ExpectRESTNotification(t, restSubId2)
5633 e2termConn1.SendSubsResp(t, crereq, cremsg)
5634 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5635
5636 deleteXapp1Subscription(t, &restSubId1)
5637 deleteXapp2Subscription(t, &restSubId2)
5638
5639 waitSubsCleanup(t, e2SubsId1, 10)
5640 waitSubsCleanup(t, e2SubsId2, 10)
5641
5642 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005643 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005644}
5645
5646func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5647 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5648
5649 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005650 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005651 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005652 Counter{cSubReqToE2, 2},
5653 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005654 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005655 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005656 Counter{cSubDelReqToE2, 2},
5657 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005658 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005659 })
5660
5661 // Req1
5662 var params *teststube2ap.RESTSubsReqParams = nil
5663
5664 //Subs Create
5665 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005666 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005667
5668 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5669
5670 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005671 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005672 params.SetMeid("RAN_NAME_1")
5673
5674 actionId := int64(1)
5675 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005676 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005677 subsequestActionType := "continue"
5678 timeToWait := "w10ms"
5679 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5680
5681 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005682 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005683 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5684 xappConn2.ExpectRESTNotification(t, restSubId2)
5685 e2termConn1.SendSubsResp(t, crereq, cremsg)
5686 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5687
5688 deleteXapp1Subscription(t, &restSubId1)
5689 deleteXapp2Subscription(t, &restSubId2)
5690
5691 waitSubsCleanup(t, e2SubsId1, 10)
5692 waitSubsCleanup(t, e2SubsId2, 10)
5693
5694 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005695 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005696}
5697
5698func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5699 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5700
5701 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005702 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005703 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005704 Counter{cSubReqToE2, 2},
5705 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005706 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005707 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005708 Counter{cSubDelReqToE2, 2},
5709 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005710 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005711 })
5712
5713 // Req1
5714 var params *teststube2ap.RESTSubsReqParams = nil
5715
5716 //Subs Create
5717 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005718 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005719
5720 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5721
5722 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005723 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005724 params.SetMeid("RAN_NAME_1")
5725 params.SetSubActionIDs(int64(2))
5726
5727 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005728 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005729 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5730 xappConn2.ExpectRESTNotification(t, restSubId2)
5731 e2termConn1.SendSubsResp(t, crereq, cremsg)
5732 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5733
5734 deleteXapp1Subscription(t, &restSubId1)
5735 deleteXapp2Subscription(t, &restSubId2)
5736
5737 waitSubsCleanup(t, e2SubsId1, 10)
5738 waitSubsCleanup(t, e2SubsId2, 10)
5739
5740 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005741 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005742}
5743
5744func TestRESTSubReqDiffActionType(t *testing.T) {
5745 CaseBegin("TestRESTSubReqDiffActionType")
5746
5747 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005748 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005749 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005750 Counter{cSubReqToE2, 2},
5751 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005752 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005753 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005754 Counter{cSubDelReqToE2, 2},
5755 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005756 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005757 })
5758
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005759 const e2Timeout int64 = 2
5760 const e2RetryCount int64 = 2
5761 const routingNeeded bool = true
5762
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005763 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005764 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005765 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005766
5767 //Subs Create
5768 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005769 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005770
5771 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5772
5773 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005774 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005775 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005776 params.SetMeid("RAN_NAME_1")
5777
5778 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005779 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005780 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5781 xappConn2.ExpectRESTNotification(t, restSubId2)
5782 e2termConn1.SendSubsResp(t, crereq, cremsg)
5783 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5784
5785 deleteXapp1Subscription(t, &restSubId1)
5786 deleteXapp2Subscription(t, &restSubId2)
5787
5788 waitSubsCleanup(t, e2SubsId1, 10)
5789 waitSubsCleanup(t, e2SubsId2, 10)
5790
5791 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005792 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005793}
5794
5795func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5796 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5797
5798 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005799 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005800 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005801 Counter{cSubReqToE2, 2},
5802 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005803 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005804 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005805 Counter{cSubDelReqToE2, 2},
5806 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005807 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005808 })
5809
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005810 const e2Timeout int64 = 2
5811 const e2RetryCount int64 = 2
5812 const routingNeeded bool = true
5813
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005814 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005815 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005816 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005817
5818 //Subs Create
5819 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005820 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005821
5822 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5823
5824 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005825 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005826 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005827 params.SetMeid("RAN_NAME_1")
5828
5829 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005830 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005831 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5832 xappConn2.ExpectRESTNotification(t, restSubId2)
5833 e2termConn1.SendSubsResp(t, crereq, cremsg)
5834 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5835
5836 deleteXapp1Subscription(t, &restSubId1)
5837 deleteXapp2Subscription(t, &restSubId2)
5838
5839 waitSubsCleanup(t, e2SubsId1, 10)
5840 waitSubsCleanup(t, e2SubsId2, 10)
5841
5842 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005843 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005844}
5845
5846func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5847 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5848
5849 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005850 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005851 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005852 Counter{cSubReqToE2, 2},
5853 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005854 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005855 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005856 Counter{cSubDelReqToE2, 2},
5857 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005859 })
5860
5861 // Req1
5862 var params *teststube2ap.RESTSubsReqParams = nil
5863
5864 //Subs Create
5865 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005866 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005867
5868 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5869
5870 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005871 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005872 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005873 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005874 params.SetSubActionDefinition(actionDefinition)
5875
5876 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005877 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005878 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5879 xappConn2.ExpectRESTNotification(t, restSubId2)
5880 e2termConn1.SendSubsResp(t, crereq, cremsg)
5881 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5882
5883 deleteXapp1Subscription(t, &restSubId1)
5884 deleteXapp2Subscription(t, &restSubId2)
5885
5886 waitSubsCleanup(t, e2SubsId1, 10)
5887 waitSubsCleanup(t, e2SubsId2, 10)
5888
5889 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005890 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005891}
5892
5893func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5894 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5895
5896 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005897 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005898 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005899 Counter{cSubReqToE2, 2},
5900 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005901 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005902 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005903 Counter{cSubDelReqToE2, 2},
5904 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005905 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005906 })
5907
5908 // Req1
5909 var params *teststube2ap.RESTSubsReqParams = nil
5910
5911 //Subs Create
5912 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005913 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005914
5915 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5916
5917 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005918 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005919 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005920 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005921 params.SetSubActionDefinition(actionDefinition)
5922
5923 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005924 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005925 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5926 xappConn2.ExpectRESTNotification(t, restSubId2)
5927 e2termConn1.SendSubsResp(t, crereq, cremsg)
5928 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5929
5930 deleteXapp1Subscription(t, &restSubId1)
5931 deleteXapp2Subscription(t, &restSubId2)
5932
5933 waitSubsCleanup(t, e2SubsId1, 10)
5934 waitSubsCleanup(t, e2SubsId2, 10)
5935
5936 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005937 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005938}
5939
5940func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5941 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5942
5943 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005944 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005945 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005946 Counter{cSubReqToE2, 2},
5947 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005948 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005949 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005950 Counter{cSubDelReqToE2, 2},
5951 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005952 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005953 })
5954
5955 // Req1
5956 var params *teststube2ap.RESTSubsReqParams = nil
5957
5958 //Subs Create
5959 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005960 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005961
5962 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5963
5964 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005965 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005966 params.SetMeid("RAN_NAME_1")
5967 params.SetTimeToWait("w200ms")
5968 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005969 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005970 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5971 xappConn2.ExpectRESTNotification(t, restSubId2)
5972 e2termConn1.SendSubsResp(t, crereq, cremsg)
5973 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5974
5975 deleteXapp1Subscription(t, &restSubId1)
5976 deleteXapp2Subscription(t, &restSubId2)
5977
5978 waitSubsCleanup(t, e2SubsId1, 10)
5979 waitSubsCleanup(t, e2SubsId2, 10)
5980
5981 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005982 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005983}
5984
Anssi Mannila51122392021-05-25 11:51:31 +03005985//-----------------------------------------------------------------------------
5986// TestRESTUnpackSubscriptionResponseDecodeFail
5987//
5988// stub stub
5989// +-------+ +---------+ +---------+
5990// | xapp | | submgr | | e2term |
5991// +-------+ +---------+ +---------+
5992// | | |
5993// | RestSubReq | |
5994// |---------------->| |
5995// | | |
5996// | RESTSubResp | |
5997// |<----------------| |
5998// | | |
5999// | | SubReq |
6000// | |------------->|
6001// | | |
6002// | | SubResp | ASN.1 decode fails
6003// | |<-------------|
6004// | | |
6005// | | SubReq |
6006// | |------------->|
6007// | | |
6008// | | SubFail | Duplicated action
6009// | |<-------------|
6010// | RESTNotif (fail)| |
6011// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006012// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006013//
6014//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006015
Anssi Mannila51122392021-05-25 11:51:31 +03006016func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006017 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
6018 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006019
6020 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006021 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006022 restSubId := xappConn1.SendRESTSubsReq(t, params)
6023
6024 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6025 // Decode of this response fails which will result resending original request
6026 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
6027
6028 _, cremsg = e2termConn1.RecvSubsReq(t)
6029
Markku Virtanen55d2a282021-06-04 14:46:56 +03006030 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006031
6032 // Subscription already created in E2 Node.
6033 fparams := &teststube2ap.E2StubSubsFailParams{}
6034 fparams.Set(crereq)
6035 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6036 e2termConn1.SendSubsFail(t, fparams, cremsg)
6037
Anssi Mannila51122392021-05-25 11:51:31 +03006038 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006039 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006040
Anssi Mannilab43397e2021-11-16 12:06:16 +02006041 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6042
Anssi Mannila51122392021-05-25 11:51:31 +03006043 // Wait that subs is cleaned
6044 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6045
6046 xappConn1.TestMsgChanEmpty(t)
6047 e2termConn1.TestMsgChanEmpty(t)
6048 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006049 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006050}
6051
6052//-----------------------------------------------------------------------------
6053// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6054//
6055// stub stub
6056// +-------+ +---------+ +---------+
6057// | xapp | | submgr | | e2term |
6058// +-------+ +---------+ +---------+
6059// | | |
6060// | RestSubReq | |
6061// |---------------->| |
6062// | | |
6063// | RESTSubResp | |
6064// |<----------------| |
6065// | | |
6066// | | SubReq |
6067// | |------------->|
6068// | | |
6069// | | SubResp | Unknown instanceId
6070// | |<-------------|
6071// | | |
6072// | | SubReq |
6073// | |------------->|
6074// | | |
6075// | | SubFail | Duplicated action
6076// | |<-------------|
6077// | RESTNotif (fail)| |
6078// |<----------------| |
6079// | | SubDelReq |
6080// | |------------->|
6081// | | |
6082// | | SubDelResp |
6083// | |<-------------|
6084//
6085//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006086
Anssi Mannila51122392021-05-25 11:51:31 +03006087func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006088 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6089 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006090
6091 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006092 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006093 restSubId := xappConn1.SendRESTSubsReq(t, params)
6094
6095 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6096
6097 // Unknown instanceId in this response which will result resending original request
6098 orgInstanceId := crereq.RequestId.InstanceId
6099 crereq.RequestId.InstanceId = 0
6100 e2termConn1.SendSubsResp(t, crereq, cremsg)
6101
6102 _, cremsg = e2termConn1.RecvSubsReq(t)
6103
Markku Virtanen55d2a282021-06-04 14:46:56 +03006104 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006105
6106 // Subscription already created in E2 Node.
6107 fparams := &teststube2ap.E2StubSubsFailParams{}
6108 fparams.Set(crereq)
6109 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6110 e2termConn1.SendSubsFail(t, fparams, cremsg)
6111
6112 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6113 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6114
6115 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006116 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006117
Anssi Mannilab43397e2021-11-16 12:06:16 +02006118 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6119
Anssi Mannila51122392021-05-25 11:51:31 +03006120 // Wait that subs is cleaned
6121 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6122
6123 xappConn1.TestMsgChanEmpty(t)
6124 e2termConn1.TestMsgChanEmpty(t)
6125 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006126 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006127}
6128
6129//-----------------------------------------------------------------------------
6130// TestRESTUnpackSubscriptionResponseNoTransaction
6131//
6132// stub stub
6133// +-------+ +---------+ +---------+
6134// | xapp | | submgr | | e2term |
6135// +-------+ +---------+ +---------+
6136// | | |
6137// | RestSubReq | |
6138// |---------------->| |
6139// | | |
6140// | RESTSubResp | |
6141// |<----------------| |
6142// | | |
6143// | | SubReq |
6144// | |------------->|
6145// | | |
6146// | | SubResp | No transaction for the response
6147// | |<-------------|
6148// | | |
6149// | | SubReq |
6150// | |------------->|
6151// | | |
6152// | | SubFail | Duplicated action
6153// | |<-------------|
6154// | RESTNotif (fail)| |
6155// |<----------------| |
6156// | | SubDelReq |
6157// | |------------->|
6158// | | |
6159// | | SubDelResp |
6160// | |<-------------|
6161// | | |
6162// | | SubDelReq |
6163// | |------------->|
6164// | | |
6165// | | SubDelResp |
6166// | |<-------------|
6167//
6168//-----------------------------------------------------------------------------
6169func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006170 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6171 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006172
6173 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006174 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006175 restSubId := xappConn1.SendRESTSubsReq(t, params)
6176
6177 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6178
6179 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6180 // No transaction exist for this response which will result resending original request
6181 e2termConn1.SendSubsResp(t, crereq, cremsg)
6182
6183 _, cremsg = e2termConn1.RecvSubsReq(t)
6184
Markku Virtanen55d2a282021-06-04 14:46:56 +03006185 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006186
6187 // Subscription already created in E2 Node.
6188 fparams := &teststube2ap.E2StubSubsFailParams{}
6189 fparams.Set(crereq)
6190 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6191 e2termConn1.SendSubsFail(t, fparams, cremsg)
6192
6193 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6194 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6195
6196 // Resending happens because there no transaction
6197 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6198 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6199
6200 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006201 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006202
Anssi Mannilab43397e2021-11-16 12:06:16 +02006203 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6204
Anssi Mannila51122392021-05-25 11:51:31 +03006205 // Wait that subs is cleaned
6206 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6207
6208 xappConn1.TestMsgChanEmpty(t)
6209 e2termConn1.TestMsgChanEmpty(t)
6210 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006211 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006212}
6213
6214//-----------------------------------------------------------------------------
6215// TestRESTUnpackSubscriptionFailureDecodeFail
6216//
6217// stub stub
6218// +-------+ +---------+ +---------+
6219// | xapp | | submgr | | e2term |
6220// +-------+ +---------+ +---------+
6221// | | |
6222// | RestSubReq | |
6223// |---------------->| |
6224// | | |
6225// | RESTSubResp | |
6226// |<----------------| |
6227// | | |
6228// | | SubReq |
6229// | |------------->|
6230// | | |
6231// | | SubFail | ASN.1 decode fails
6232// | |<-------------|
6233// | | |
6234// | | SubReq |
6235// | |------------->|
6236// | | |
6237// | | SubFail | Duplicated action
6238// | |<-------------|
6239// | RESTNotif (fail)| |
6240// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006241// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006242//
6243//-----------------------------------------------------------------------------
6244func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006245 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6246 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006247
6248 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006249 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006250 restSubId := xappConn1.SendRESTSubsReq(t, params)
6251
6252 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6253
6254 // Decode of this response fails which will result resending original request
6255 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6256
6257 _, cremsg = e2termConn1.RecvSubsReq(t)
6258
Markku Virtanen55d2a282021-06-04 14:46:56 +03006259 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006260
6261 // Subscription already created in E2 Node.
6262 fparams := &teststube2ap.E2StubSubsFailParams{}
6263 fparams.Set(crereq)
6264 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6265 e2termConn1.SendSubsFail(t, fparams, cremsg)
6266
Anssi Mannila51122392021-05-25 11:51:31 +03006267 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006268 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006269
Anssi Mannilab43397e2021-11-16 12:06:16 +02006270 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6271
Anssi Mannila51122392021-05-25 11:51:31 +03006272 // Wait that subs is cleaned
6273 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6274
6275 xappConn1.TestMsgChanEmpty(t)
6276 e2termConn1.TestMsgChanEmpty(t)
6277 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006278 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006279}
6280
6281//-----------------------------------------------------------------------------
6282// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6283//
6284// stub stub
6285// +-------+ +---------+ +---------+
6286// | xapp | | submgr | | e2term |
6287// +-------+ +---------+ +---------+
6288// | | |
6289// | RestSubReq | |
6290// |---------------->| |
6291// | | |
6292// | RESTSubResp | |
6293// |<----------------| |
6294// | | |
6295// | | SubReq |
6296// | |------------->|
6297// | | |
6298// | | SubFail | Unknown instanceId
6299// | |<-------------|
6300// | | |
6301// | | SubReq |
6302// | |------------->|
6303// | | |
6304// | | SubFail | Duplicated action
6305// | |<-------------|
6306// | RESTNotif (fail)| |
6307// |<----------------| |
6308// | | SubDelReq |
6309// | |------------->|
6310// | | |
6311// | | SubDelResp |
6312// | |<-------------|
6313//
6314//-----------------------------------------------------------------------------
6315func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006316 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6317 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006318
6319 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006320 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006321 restSubId := xappConn1.SendRESTSubsReq(t, params)
6322
6323 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6324
6325 // Unknown instanceId in this response which will result resending original request
6326 fparams := &teststube2ap.E2StubSubsFailParams{}
6327 fparams.Set(crereq)
6328 fparams.Fail.RequestId.InstanceId = 0
6329 e2termConn1.SendSubsFail(t, fparams, cremsg)
6330
6331 _, cremsg = e2termConn1.RecvSubsReq(t)
6332
Markku Virtanen55d2a282021-06-04 14:46:56 +03006333 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006334
6335 // Subscription already created in E2 Node.
6336 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6337 e2termConn1.SendSubsFail(t, fparams, cremsg)
6338
6339 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6340 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6341
6342 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006343 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006344
Anssi Mannilab43397e2021-11-16 12:06:16 +02006345 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6346
Anssi Mannila51122392021-05-25 11:51:31 +03006347 // Wait that subs is cleaned
6348 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6349
6350 xappConn1.TestMsgChanEmpty(t)
6351 e2termConn1.TestMsgChanEmpty(t)
6352 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006353 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006354}
6355
6356//-----------------------------------------------------------------------------
6357// TestRESTUnpackSubscriptionFailureNoTransaction
6358//
6359// stub stub
6360// +-------+ +---------+ +---------+
6361// | xapp | | submgr | | e2term |
6362// +-------+ +---------+ +---------+
6363// | | |
6364// | RestSubReq | |
6365// |---------------->| |
6366// | | |
6367// | RESTSubResp | |
6368// |<----------------| |
6369// | | |
6370// | | SubReq |
6371// | |------------->|
6372// | | |
6373// | | SubFail | No transaction for the response
6374// | |<-------------|
6375// | | |
6376// | | SubReq |
6377// | |------------->|
6378// | | |
6379// | | SubFail | Duplicated action
6380// | |<-------------|
6381// | RESTNotif (fail)| |
6382// |<----------------| |
6383// | | SubDelReq |
6384// | |------------->|
6385// | | |
6386// | | SubDelResp |
6387// | |<-------------|
6388//
6389//-----------------------------------------------------------------------------
6390func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006391 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6392 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006393
6394 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006395 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006396 restSubId := xappConn1.SendRESTSubsReq(t, params)
6397
6398 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6399
6400 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6401
6402 // No transaction exist for this response which will result resending original request
6403 fparams := &teststube2ap.E2StubSubsFailParams{}
6404 fparams.Set(crereq)
6405 e2termConn1.SendSubsFail(t, fparams, cremsg)
6406
6407 _, cremsg = e2termConn1.RecvSubsReq(t)
6408
Markku Virtanen55d2a282021-06-04 14:46:56 +03006409 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006410
6411 // Subscription already created in E2 Node.
6412 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6413 e2termConn1.SendSubsFail(t, fparams, cremsg)
6414
6415 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6416 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6417
6418 // Resending happens because there no transaction
6419 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6420 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6421
6422 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006423 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006424
Anssi Mannilab43397e2021-11-16 12:06:16 +02006425 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6426
Anssi Mannila51122392021-05-25 11:51:31 +03006427 // Wait that subs is cleaned
6428 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6429
6430 xappConn1.TestMsgChanEmpty(t)
6431 e2termConn1.TestMsgChanEmpty(t)
6432 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006433 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006434}
6435
6436//-----------------------------------------------------------------------------
6437// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6438//
6439// stub stub
6440// +-------+ +---------+ +---------+
6441// | xapp | | submgr | | e2term |
6442// +-------+ +---------+ +---------+
6443// | | |
6444// | [SUBS CREATE] |
6445// | | |
6446// | | |
6447// | RESTSubDelReq | |
6448// |---------------->| |
6449// | | |
6450// | RESTSubDelResp | |
6451// |<----------------| |
6452// | | |
6453// | | SubDelReq |
6454// | |------------->|
6455// | | |
6456// | | SubDelResp | ASN.1 decode fails
6457// | |<-------------|
6458// | | |
6459// | | SubDelReq |
6460// | |------------->|
6461// | | |
6462// | | SubDelFail | Subscription does exist any more
6463// | |<-------------|
6464// | | |
6465//
6466//-----------------------------------------------------------------------------
6467func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006468 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006469
6470 // Req
6471 var params *teststube2ap.RESTSubsReqParams = nil
6472 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6473
6474 // Del
6475 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6476
6477 // E2t: Receive 1st SubsDelReq
6478 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6479
6480 // Decode of this response fails which will result resending original request
6481 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6482
6483 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6484 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6485
6486 // Subscription does not exist in in E2 Node.
6487 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6488
6489 // Wait that subs is cleaned
6490 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6491
6492 xappConn1.TestMsgChanEmpty(t)
6493 e2termConn1.TestMsgChanEmpty(t)
6494 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006495 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006496}
6497
6498//-----------------------------------------------------------------------------
6499// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6500//
6501// stub stub
6502// +-------+ +---------+ +---------+
6503// | xapp | | submgr | | e2term |
6504// +-------+ +---------+ +---------+
6505// | | |
6506// | [SUBS CREATE] |
6507// | | |
6508// | | |
6509// | RESTSubDelReq | |
6510// |---------------->| |
6511// | | |
6512// | RESTSubDelResp | |
6513// |<----------------| |
6514// | | |
6515// | | SubDelReq |
6516// | |------------->|
6517// | | |
6518// | | SubDelResp | Unknown instanceId
6519// | |<-------------|
6520// | | |
6521// | | SubDelReq |
6522// | |------------->|
6523// | | |
6524// | | SubDelFail | Subscription does exist any more
6525// | |<-------------|
6526//
6527//-----------------------------------------------------------------------------
6528func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006529 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006530
6531 // Req
6532 var params *teststube2ap.RESTSubsReqParams = nil
6533 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6534
6535 // Del
6536 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6537
6538 // E2t: Receive 1st SubsDelReq
6539 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6540
6541 // Unknown instanceId in this response which will result resending original request
6542 delreq.RequestId.InstanceId = 0
6543 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6544
6545 // E2t: Receive 2nd SubsDelReq
6546 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6547
6548 // Subscription does not exist in in E2 Node.
6549 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6550
6551 // Wait that subs is cleaned
6552 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6553
6554 xappConn1.TestMsgChanEmpty(t)
6555 e2termConn1.TestMsgChanEmpty(t)
6556 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006557 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006558}
6559
6560//-----------------------------------------------------------------------------
6561// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6562//
6563// stub stub
6564// +-------+ +---------+ +---------+
6565// | xapp | | submgr | | e2term |
6566// +-------+ +---------+ +---------+
6567// | | |
6568// | [SUBS CREATE] |
6569// | | |
6570// | | |
6571// | RESTSubDelReq | |
6572// |---------------->| |
6573// | | |
6574// | RESTSubDelResp | |
6575// |<----------------| |
6576// | | |
6577// | | SubDelReq |
6578// | |------------->|
6579// | | |
6580// | | SubDelResp | No transaction for the response
6581// | |<-------------|
6582// | | |
6583// | | SubDelReq |
6584// | |------------->|
6585// | | |
6586// | | SubDelFail | Subscription does exist any more
6587// | |<-------------|
6588//
6589//-----------------------------------------------------------------------------
6590func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006591 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006592
6593 // Req
6594 var params *teststube2ap.RESTSubsReqParams = nil
6595 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6596
6597 // Del
6598 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6599
6600 // E2t: Receive 1st SubsDelReq
6601 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6602
6603 mainCtrl.MakeTransactionNil(t, e2SubsId)
6604
6605 // No transaction exist for this response which will result resending original request
6606 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6607
6608 // E2t: Receive 2nd SubsDelReq
6609 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6610
6611 // Subscription does not exist in in E2 Node.
6612 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6613
6614 // Wait that subs is cleaned
6615 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6616
6617 xappConn1.TestMsgChanEmpty(t)
6618 e2termConn1.TestMsgChanEmpty(t)
6619 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006620 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006621}
6622
6623//-----------------------------------------------------------------------------
6624// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6625//
6626// stub stub
6627// +-------+ +---------+ +---------+
6628// | xapp | | submgr | | e2term |
6629// +-------+ +---------+ +---------+
6630// | | |
6631// | [SUBS CREATE] |
6632// | | |
6633// | | |
6634// | RESTSubDelReq | |
6635// |---------------->| |
6636// | | |
6637// | RESTSubDelResp | |
6638// |<----------------| |
6639// | | |
6640// | | SubDelReq |
6641// | |------------->|
6642// | | |
6643// | | SubDelFail | ASN.1 decode fails
6644// | |<-------------|
6645// | | |
6646// | | SubDelReq |
6647// | |------------->|
6648// | | |
6649// | | SubDelFail | Subscription does exist any more
6650// | |<-------------|
6651//
6652//-----------------------------------------------------------------------------
6653func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006654 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006655
6656 // Req
6657 var params *teststube2ap.RESTSubsReqParams = nil
6658 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6659
6660 // Del
6661 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6662
6663 // E2t: Receive 1st SubsDelReq
6664 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6665
6666 // Decode of this response fails which will result resending original request
6667 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6668
6669 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6670 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6671
6672 // Subscription does not exist in in E2 Node.
6673 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6674
6675 // Wait that subs is cleaned
6676 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6677
6678 xappConn1.TestMsgChanEmpty(t)
6679 e2termConn1.TestMsgChanEmpty(t)
6680 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006681 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006682}
6683
6684//-----------------------------------------------------------------------------
6685// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6686//
6687// stub stub
6688// +-------+ +---------+ +---------+
6689// | xapp | | submgr | | e2term |
6690// +-------+ +---------+ +---------+
6691// | | |
6692// | [SUBS CREATE] |
6693// | | |
6694// | | |
6695// | RESTSubDelReq | |
6696// |---------------->| |
6697// | | |
6698// | RESTSubDelResp | |
6699// |<----------------| |
6700// | | |
6701// | | SubDelReq |
6702// | |------------->|
6703// | | |
6704// | | SubDelFail | Unknown instanceId
6705// | |<-------------|
6706// | | |
6707// | | SubDelReq |
6708// | |------------->|
6709// | | |
6710// | | SubDelFail | Subscription does exist any more
6711// | |<-------------|
6712//
6713//-----------------------------------------------------------------------------
6714func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006715 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006716
6717 // Req
6718 var params *teststube2ap.RESTSubsReqParams = nil
6719 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6720
6721 // Del
6722 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6723
6724 // E2t: Receive 1st SubsDelReq
6725 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6726
6727 // Unknown instanceId in this response which will result resending original request
6728 delreq.RequestId.InstanceId = 0
6729 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6730
6731 // E2t: Receive 2nd SubsDelReq
6732 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6733
6734 // Subscription does not exist in in E2 Node.
6735 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6736
6737 // Wait that subs is cleaned
6738 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6739
6740 xappConn1.TestMsgChanEmpty(t)
6741 e2termConn1.TestMsgChanEmpty(t)
6742 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006743 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006744}
6745
6746//-----------------------------------------------------------------------------
6747// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6748//
6749// stub stub
6750// +-------+ +---------+ +---------+
6751// | xapp | | submgr | | e2term |
6752// +-------+ +---------+ +---------+
6753// | | |
6754// | [SUBS CREATE] |
6755// | | |
6756// | | |
6757// | RESTSubDelReq | |
6758// |---------------->| |
6759// | | |
6760// | RESTSubDelResp | |
6761// |<----------------| |
6762// | | |
6763// | | SubDelReq |
6764// | |------------->|
6765// | | |
6766// | | SubDelFail | No transaction for the response
6767// | |<-------------|
6768// | | |
6769// | | SubDelReq |
6770// | |------------->|
6771// | | |
6772// | | SubDelFail | Subscription does exist any more
6773// | |<-------------|
6774//
6775//-----------------------------------------------------------------------------
6776func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006777 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006778
6779 // Req
6780 var params *teststube2ap.RESTSubsReqParams = nil
6781 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6782
6783 // Del
6784 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6785
6786 // E2t: Receive 1st SubsDelReq
6787 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6788
6789 mainCtrl.MakeTransactionNil(t, e2SubsId)
6790
6791 // No transaction exist for this response which will result resending original request
6792 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6793
6794 // E2t: Receive 2nd SubsDelReq
6795 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6796
6797 // Subscription does not exist in in E2 Node.
6798 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6799
6800 // Wait that subs is cleaned
6801 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6802
6803 xappConn1.TestMsgChanEmpty(t)
6804 e2termConn1.TestMsgChanEmpty(t)
6805 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006806 mainCtrl.VerifyAllClean(t)
Anssi Mannila51122392021-05-25 11:51:31 +03006807}
6808
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006809//-----------------------------------------------------------------------------
6810// TestRESTSubReqFailAsn1PackSubReqError
6811//
6812// stub stub
6813// +-------+ +---------+ +---------+
6814// | xapp | | submgr | | e2term |
6815// +-------+ +---------+ +---------+
6816// | | |
6817// | RESTSubReq | |
6818// |---------------->| |
6819// | | |
6820// | RESTSubResp | |
6821// |<----------------| |
6822// | | |
6823// | ASN.1 encode fails |
6824// | | |
6825// | | SubDelReq |
6826// | |------------->|
6827// | | |
6828// | | SubDelFail |
6829// | |<-------------|
6830// | | |
6831// | RESTNotif | |
6832// | unsuccess | |
6833// |<----------------| |
6834// | | |
6835// | [SUBS DELETE] |
6836// | | |
6837//
6838//-----------------------------------------------------------------------------
6839func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6840
6841 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006842 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006843 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006844 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02006845 Counter{cRestSubDelReqFromXapp, 1},
6846 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006847 })
6848
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006849 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006850
6851 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006852 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006853 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6854
6855 // Req
6856 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006857 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006858
6859 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006860 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006861
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006862 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006863 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006864
6865 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006866
6867 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6868
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006869 // Wait that subs is cleaned
6870 waitSubsCleanup(t, e2SubsId, 10)
6871 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006872 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006873}
6874
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006875func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6876 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6877
6878 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6879 Counter{cRestSubReqFromXapp, 2},
6880 Counter{cRestSubRespToXapp, 2},
6881 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006882 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006883 Counter{cSubRespFromE2, 1},
6884 Counter{cRestSubNotifToXapp, 1},
6885 Counter{cRestSubFailNotifToXapp, 1},
6886 Counter{cRestSubDelReqFromXapp, 1},
6887 Counter{cSubDelReqToE2, 1},
6888 Counter{cSubDelRespFromE2, 1},
6889 Counter{cRestSubDelRespToXapp, 1},
6890 })
6891
6892 const e2Timeout int64 = 1
6893 const e2RetryCount int64 = 0
6894 const routingNeeded bool = false
6895
6896 // Req1
6897 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6898 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6899
6900 // Subs Create
6901 restSubId := xappConn1.SendRESTSubsReq(t, params)
6902 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6903
6904 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6905 xappConn1.ExpectRESTNotification(t, restSubId)
6906 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6907 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6908 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6909
6910 // Policy change
6911 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6912 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6913 params.SetSubscriptionID(&restSubId)
6914 params.SetTimeToWait("w200ms")
6915 restSubId = xappConn1.SendRESTSubsReq(t, params)
6916 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6917
6918 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6919 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006920 // SubsResp is missing, e2SubsId will be 0
6921 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6922 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006923
6924 // Del
6925 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6926 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6927 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6928
6929 waitSubsCleanup(t, e2SubsId, 10)
6930
6931 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006932 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006933}
6934
6935//-----------------------------------------------------------------------------
6936// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6937//
6938// stub stub
6939// +-------+ +---------+ +---------+
6940// | xapp | | submgr | | e2term |
6941// +-------+ +---------+ +---------+
6942// | | |
6943// | RESTSubReq | |
6944// |---------------->| |
6945// | | |
6946// | RESTSubResp | |
6947// |<----------------| |
6948// | | SubReq |
6949// | |------------->|
6950// | | |
6951// | | SubResp |
6952// | |<-------------|
6953// | | |
6954// | RESTNotif | |
6955// |<----------------| |
6956// | | |
6957// | RESTSubReq | |
6958// |---------------->| |
6959// | | |
6960// | RESTSubResp | |
6961// |<----------------| |
6962// | | SubReq |
6963// | |------------->|
6964// | |
6965// | Submgr restart |
6966// | | |
6967// | RESTSubDelReq | |
6968// |---------------->| |
6969// | | |
6970// | | SubDelReq |
6971// | |------------->|
6972// | | |
6973// | | SubDelResp |
6974// | |<-------------|
6975// | | |
6976// | RESTSubDelResp | |
6977// |<----------------| |
6978//
6979//-----------------------------------------------------------------------------
6980
6981func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6982 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6983
6984 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6985 Counter{cRestSubReqFromXapp, 2},
6986 Counter{cRestSubRespToXapp, 2},
6987 Counter{cSubReqToE2, 2},
6988 Counter{cSubRespFromE2, 1},
6989 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006990 Counter{cRestSubDelReqFromXapp, 1},
6991 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006992 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006993 Counter{cRestSubDelRespToXapp, 1},
6994 })
6995
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006996 const e2Timeout int64 = 1
6997 const e2RetryCount int64 = 0
6998 const routingNeeded bool = false
6999
7000 // Req1
7001 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7002 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7003 // Create subscription
7004 restSubId := xappConn1.SendRESTSubsReq(t, params)
7005 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7006
7007 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7008 xappConn1.ExpectRESTNotification(t, restSubId)
7009 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7010 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
7011 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
7012
7013 // Check subscription
7014 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7015
7016 // Policy change
7017 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
7018 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
7019 params.SetSubscriptionID(&restSubId)
7020 params.SetTimeToWait("w200ms")
7021 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
7022 restSubId = xappConn1.SendRESTSubsReq(t, params)
7023 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
7024
7025 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
7026 mainCtrl.SetResetTestFlag(t, false)
7027
7028 // SubsResp is missing due to submgr restart
7029
7030 mainCtrl.SimulateRestart(t)
7031 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
7032
Anssi Mannila54838ed2021-11-19 11:25:01 +02007033 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
7034 // That needs to be completed before successful subscription query is possible
7035 <-time.After(time.Second * 1)
7036
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007037 // Check subscription
7038 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
7039
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007040 // Delete subscription
7041 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7042 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7043 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7044
7045 //Wait that subs is cleaned
7046 waitSubsCleanup(t, e2SubsId, 10)
7047
7048 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007049 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007050}
7051
archaggeafbf95f2021-04-14 08:54:05 +03007052////////////////////////////////////////////////////////////////////////////////////
7053// Services for UT cases
7054////////////////////////////////////////////////////////////////////////////////////
7055const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03007056const host string = "localhost"
7057
7058func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
7059 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007060 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007061 }
7062 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007063 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007064
7065 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7066 fromXappConn.ExpectRESTNotification(t, restSubId)
7067 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7068 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007069 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007070
7071 return restSubId, e2SubsId
7072}
7073
7074func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7075
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007076 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007077 if meid != "" {
7078 params.SetMeid(meid)
7079 }
7080 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7081 restSubId := xappConn2.SendRESTSubsReq(t, params)
7082 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007083 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007084 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007085 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007086
7087 return restSubId, e2SubsId
7088}
7089
7090func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007091
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007092 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007093 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007094 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007095
7096 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7097 xappConn1.ExpectRESTNotification(t, restSubId)
7098 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7099 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007100 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007101
7102 return restSubId, e2SubsId
7103}
7104
7105func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007106 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007107 restSubId := xappConn1.SendRESTSubsReq(t, params)
7108
7109 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7110 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7111 fparams1.Set(crereq1)
7112 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7113
7114 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7115 xappConn1.ExpectRESTNotification(t, restSubId)
7116 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7117 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007118 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007119
7120 return restSubId, e2SubsId
7121}
7122
7123func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7124 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7125 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7126 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7127}
7128
7129func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7130 xappConn1.SendRESTSubsDelReq(t, restSubId)
7131 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7132 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7133}
7134
7135func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7136 xappConn2.SendRESTSubsDelReq(t, restSubId)
7137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7138 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7139}
7140
7141func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7142 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02007143 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
7144 assert.Equal(t, meid, resp[0].Meid)
7145 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03007146}
7147
7148func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7149 //Wait that subs is cleaned
7150 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7151
7152 xappConn1.TestMsgChanEmpty(t)
7153 xappConn2.TestMsgChanEmpty(t)
7154 e2termConn1.TestMsgChanEmpty(t)
7155 mainCtrl.wait_registry_empty(t, timeout)
7156}
7157
7158func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7159
7160 var e2SubsId []uint32
7161
7162 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007163 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007164 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7165 fromXappConn.ExpectRESTNotification(t, restSubId)
7166 toE2termConn.SendSubsResp(t, crereq, cremsg)
7167 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7168 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007169 xapp.Logger.Debug("TEST: %v", e2SubsId)
7170 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007171 <-time.After(100 * time.Millisecond)
7172 }
7173 return e2SubsId
7174}
7175
7176func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7177
7178 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007179 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007180 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7181 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7182 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007183 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007184 <-time.After(100 * time.Millisecond)
7185 }
7186
7187 // Wait that subs is cleaned
7188 for i := 0; i < len(e2SubsIds); i++ {
7189 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7190 }
7191
7192}