blob: 20f8709553532cad6bc647cc1cd8ee27329016fc [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 Mannila4abf1802021-01-28 13:06:46 +020023 "testing"
24 "time"
25
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020026 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020027 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020028 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
29 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020030)
31
32//-----------------------------------------------------------------------------
33// TestSubReqAndRouteNok
34//
35// stub stub
36// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +020037// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +020038// +-------+ +---------+ +---------+
39// | | |
40// | SubReq | |
41// |------------->| |
42// | | |
43// | | RouteCreate |
44// | |------------->|
45// | | |
46// | | RouteCreate |
47// | | status:400 |
48// | |<-------------|
49// | | |
50// | [SUBS INT DELETE] |
51// | | |
52//
53//-----------------------------------------------------------------------------
54
55func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020056 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +020057
Anssi Mannila4abf1802021-01-28 13:06:46 +020058 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +020059 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
60 Counter{cSubReqFromXapp, 1},
61 Counter{cRouteCreateFail, 1},
62 })
Anssi Mannila4abf1802021-01-28 13:06:46 +020063
Juha Hyttinenfa015662020-01-24 10:05:18 +020064 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +030065 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020066 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020067 waiter.WaitResult(t)
68
69 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020070 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020071
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020072 xappConn1.TestMsgChanEmpty(t)
73 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020074 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020075 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +020076
77 <-time.After(1 * time.Second)
78 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +020079}
80
81//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +020082// TestSubReqAndRouteUpdateNok
83
84// stub stub
85// +-------+ +-------+ +---------+ +---------+
86// | xapp2 | | xapp1 | | submgr | | rtmgr |
87// +-------+ +-------+ +---------+ +---------+
88// | | | |
89// | [SUBS CREATE] | |
90// | | | |
91// | | | |
92// | | | |
93// | SubReq (mergeable) | |
94// |--------------------------->| | |
95// | | | |
96// | | | RouteUpdate |
97// | | |------------->|
98// | | | |
99// | | | RouteUpdate |
100// | | | status:400 |
101// | | |<-------------|
102// | | | |
103// | [SUBS INT DELETE] | |
104// | | | |
105// | | | |
106// | [SUBS DELETE] | |
107// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300108
Anssi Mannila4abf1802021-01-28 13:06:46 +0200109func TestSubReqAndRouteUpdateNok(t *testing.T) {
110 CaseBegin("TestSubReqAndRouteUpdateNok")
111
112 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200113 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
114 Counter{cSubReqFromXapp, 2},
115 Counter{cSubReqToE2, 1},
116 Counter{cSubRespFromE2, 1},
117 Counter{cSubRespToXapp, 1},
118 Counter{cRouteCreateUpdateFail, 1},
119 Counter{cSubDelReqFromXapp, 1},
120 Counter{cSubDelReqToE2, 1},
121 Counter{cSubDelRespFromE2, 1},
122 Counter{cSubDelRespToXapp, 1},
123 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200124
125 cretrans := xappConn1.SendSubsReq(t, nil, nil)
126 crereq, cremsg := e2termConn1.RecvSubsReq(t)
127 e2termConn1.SendSubsResp(t, crereq, cremsg)
128 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
129
130 resp, _ := xapp.Subscription.QuerySubscriptions()
131 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
132 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300133 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200134
135 waiter := rtmgrHttp.AllocNextEvent(false)
136 newSubsId := mainCtrl.get_registry_next_subid(t)
137 xappConn2.SendSubsReq(t, nil, nil)
138 waiter.WaitResult(t)
139
140 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
141 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
142
143 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
144 xappConn1.RecvSubsDelResp(t, deltrans)
145
146 //Wait that subs is cleaned
147 mainCtrl.wait_subs_clean(t, newSubsId, 10)
148 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
149
150 xappConn1.TestMsgChanEmpty(t)
151 xappConn2.TestMsgChanEmpty(t)
152 e2termConn1.TestMsgChanEmpty(t)
153 mainCtrl.wait_registry_empty(t, 10)
154
155 mainCtrl.VerifyCounterValues(t)
156}
157
158//-----------------------------------------------------------------------------
159// TestSubDelReqAndRouteDeleteNok
160//
161// stub stub
162// +-------+ +---------+ +---------+ +---------+
163// | xapp | | submgr | | e2term | | rtmgr |
164// +-------+ +---------+ +---------+ +---------+
165// | | | |
166// | [SUBS CREATE] | |
167// | | | |
168// | | | |
169// | | | |
170// | SubDelReq | | |
171// |------------->| | |
172// | | SubDelReq | |
173// | |------------->| |
174// | | SubDelRsp | |
175// | |<-------------| |
176// | SubDelRsp | | |
177// |<-------------| | |
178// | | RouteDelete | |
179// | |---------------------------->|
180// | | | |
181// | | RouteDelete | |
182// | | status:400 | |
183// | |<----------------------------|
184// | | | |
185func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
186 CaseBegin("TestSubDelReqAndRouteDeleteNok")
187
188 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200189 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
190 Counter{cSubReqFromXapp, 1},
191 Counter{cSubReqToE2, 1},
192 Counter{cSubRespFromE2, 1},
193 Counter{cSubRespToXapp, 1},
194 Counter{cSubDelReqFromXapp, 1},
195 Counter{cRouteDeleteFail, 1},
196 Counter{cSubDelReqToE2, 1},
197 Counter{cSubDelRespFromE2, 1},
198 Counter{cSubDelRespToXapp, 1},
199 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200200
201 cretrans := xappConn1.SendSubsReq(t, nil, nil)
202 crereq, cremsg := e2termConn1.RecvSubsReq(t)
203 e2termConn1.SendSubsResp(t, crereq, cremsg)
204 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
205
206 resp, _ := xapp.Subscription.QuerySubscriptions()
207 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
208 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300209 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200210
211 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
212 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
213
214 waiter := rtmgrHttp.AllocNextEvent(false)
215 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
216 waiter.WaitResult(t)
217
218 xappConn1.RecvSubsDelResp(t, deltrans)
219
220 //Wait that subs is cleaned
221 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
222
223 xappConn1.TestMsgChanEmpty(t)
224 xappConn2.TestMsgChanEmpty(t)
225 e2termConn1.TestMsgChanEmpty(t)
226 mainCtrl.wait_registry_empty(t, 10)
227
228 mainCtrl.VerifyCounterValues(t)
229}
230
231//-----------------------------------------------------------------------------
232// TestSubMergeDelAndRouteUpdateNok
233// stub stub
234// +-------+ +-------+ +---------+ +---------+
235// | xapp2 | | xapp1 | | submgr | | e2term |
236// +-------+ +-------+ +---------+ +---------+
237// | | | |
238// | | | |
239// | | | |
240// | | SubReq1 | |
241// | |------------->| |
242// | | | |
243// | | | SubReq1 |
244// | | |------------->|
245// | | | SubResp1 |
246// | | |<-------------|
247// | | SubResp1 | |
248// | |<-------------| |
249// | | | |
250// | SubReq2 | |
251// |--------------------------->| |
252// | | | |
253// | SubResp2 | |
254// |<---------------------------| |
255// | | | |
256// | | SubDelReq 1 | |
257// | |------------->| |
258// | | | RouteUpdate |
259// | | |-----> rtmgr |
260// | | | |
261// | | | RouteUpdate |
262// | | | status:400 |
263// | | |<----- rtmgr |
264// | | | |
265// | | SubDelResp 1 | |
266// | |<-------------| |
267// | | | |
268// | SubDelReq 2 | |
269// |--------------------------->| |
270// | | | |
271// | | | SubDelReq 2 |
272// | | |------------->|
273// | | | |
274// | | | SubDelReq 2 |
275// | | |------------->|
276// | | | |
277// | SubDelResp 2 | |
278// |<---------------------------| |
279//
280//-----------------------------------------------------------------------------
281func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
282 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
283
284 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200285 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
286 Counter{cSubReqFromXapp, 2},
287 Counter{cSubReqToE2, 1},
288 Counter{cSubRespFromE2, 1},
289 Counter{cSubRespToXapp, 2},
290 Counter{cSubDelReqFromXapp, 2},
291 Counter{cRouteDeleteUpdateFail, 1},
292 Counter{cSubDelReqToE2, 1},
293 Counter{cSubDelRespFromE2, 1},
294 Counter{cSubDelRespToXapp, 2},
295 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200296
297 //Req1
298 rparams1 := &teststube2ap.E2StubSubsReqParams{}
299 rparams1.Init()
300 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
301 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
302 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
303 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
304
305 //Req2
306 rparams2 := &teststube2ap.E2StubSubsReqParams{}
307 rparams2.Init()
308 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
309 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
310
311 resp, _ := xapp.Subscription.QuerySubscriptions()
312 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
313 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300314 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200315
316 //Del1
317 waiter := rtmgrHttp.AllocNextEvent(false)
318 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
319 waiter.WaitResult(t)
320
321 xappConn1.RecvSubsDelResp(t, deltrans1)
322
323 //Del2
324 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
325 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
326 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
327 xappConn2.RecvSubsDelResp(t, deltrans2)
328 //Wait that subs is cleaned
329 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
330
331 xappConn1.TestMsgChanEmpty(t)
332 xappConn2.TestMsgChanEmpty(t)
333 e2termConn1.TestMsgChanEmpty(t)
334 mainCtrl.wait_registry_empty(t, 10)
335
336 mainCtrl.VerifyCounterValues(t)
337}
338
339//-----------------------------------------------------------------------------
340
341//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200342// TestSubReqAndSubDelOk
343//
344// stub stub
345// +-------+ +---------+ +---------+
346// | xapp | | submgr | | e2term |
347// +-------+ +---------+ +---------+
348// | | |
349// | SubReq | |
350// |------------->| |
351// | | |
352// | | SubReq |
353// | |------------->|
354// | | |
355// | | SubResp |
356// | |<-------------|
357// | | |
358// | SubResp | |
359// |<-------------| |
360// | | |
361// | | |
362// | SubDelReq | |
363// |------------->| |
364// | | |
365// | | SubDelReq |
366// | |------------->|
367// | | |
368// | | SubDelResp |
369// | |<-------------|
370// | | |
371// | SubDelResp | |
372// |<-------------| |
373//
374//-----------------------------------------------------------------------------
375func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200376 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200377
Anssi Mannila4abf1802021-01-28 13:06:46 +0200378 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200379 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
380 Counter{cSubReqFromXapp, 1},
381 Counter{cSubReqToE2, 1},
382 Counter{cSubRespFromE2, 1},
383 Counter{cSubRespToXapp, 1},
384 Counter{cSubDelReqFromXapp, 1},
385 Counter{cSubDelReqToE2, 1},
386 Counter{cSubDelRespFromE2, 1},
387 Counter{cSubDelRespToXapp, 1},
388 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200389
390 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200391 crereq, cremsg := e2termConn1.RecvSubsReq(t)
392 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200393 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200394
395 resp, _ := xapp.Subscription.QuerySubscriptions()
396 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
397 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300398 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200399
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200400 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200401 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200402
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200403 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200404 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200405
406 //Wait that subs is cleaned
407 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
408
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200409 xappConn1.TestMsgChanEmpty(t)
410 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200411 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200412 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200413
414 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200415}
416
417//-----------------------------------------------------------------------------
418// TestSubReqRetransmission
419//
420// stub stub
421// +-------+ +---------+ +---------+
422// | xapp | | submgr | | e2term |
423// +-------+ +---------+ +---------+
424// | | |
425// | SubReq | |
426// |------------->| |
427// | | |
428// | | SubReq |
429// | |------------->|
430// | | |
431// | SubReq | |
432// | (retrans) | |
433// |------------->| |
434// | | |
435// | | SubResp |
436// | |<-------------|
437// | | |
438// | SubResp | |
439// |<-------------| |
440// | | |
441// | [SUBS DELETE] |
442// | | |
443//
444//-----------------------------------------------------------------------------
445func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200446 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200447
448 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200449 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200450 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200451
452 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200453 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200454 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
455
Juha Hyttinen1683f912020-04-17 10:39:57 +0300456 // hack as there is no real way to see has message be handled.
457 // Previuos counter check just tells that is has been received by submgr
458 // --> artificial delay
459 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200460 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200461 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200462
463 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200464 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200465 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
466 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200467 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200468
469 //Wait that subs is cleaned
470 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
471
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200472 xappConn1.TestMsgChanEmpty(t)
473 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200474 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200475 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200476}
477
478//-----------------------------------------------------------------------------
479// TestSubDelReqRetransmission
480//
481// stub stub
482// +-------+ +---------+ +---------+
483// | xapp | | submgr | | e2term |
484// +-------+ +---------+ +---------+
485// | | |
486// | [SUBS CREATE] |
487// | | |
488// | | |
489// | SubDelReq | |
490// |------------->| |
491// | | |
492// | | SubDelReq |
493// | |------------->|
494// | | |
495// | SubDelReq | |
496// | (same sub) | |
497// | (same xid) | |
498// |------------->| |
499// | | |
500// | | SubDelResp |
501// | |<-------------|
502// | | |
503// | SubDelResp | |
504// |<-------------| |
505//
506//-----------------------------------------------------------------------------
507func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200508 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200509
510 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200511 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200512 crereq, cremsg := e2termConn1.RecvSubsReq(t)
513 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200514 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200515
516 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200517 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200518 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200519
520 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200521 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200522 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
523
Juha Hyttinen1683f912020-04-17 10:39:57 +0300524 // hack as there is no real way to see has message be handled.
525 // Previuos counter check just tells that is has been received by submgr
526 // --> artificial delay
527 <-time.After(1 * time.Second)
528
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200529 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200530 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200531
532 //Wait that subs is cleaned
533 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
534
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200535 xappConn1.TestMsgChanEmpty(t)
536 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200537 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200538 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200539}
540
541//-----------------------------------------------------------------------------
542// TestSubDelReqCollision
543//
544// stub stub
545// +-------+ +---------+ +---------+
546// | xapp | | submgr | | e2term |
547// +-------+ +---------+ +---------+
548// | | |
549// | [SUBS CREATE] |
550// | | |
551// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200552// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200553// |------------->| |
554// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200555// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200556// | |------------->|
557// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200558// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200559// | (same sub) | |
560// | (diff xid) | |
561// |------------->| |
562// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200563// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200564// | |<-------------|
565// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200566// | SubDelResp 1 | |
567// |<-------------| |
568// | | |
569// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200570// |<-------------| |
571//
572//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200573
Juha Hyttinenfa015662020-01-24 10:05:18 +0200574func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200575 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576
577 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200578 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200579 crereq, cremsg := e2termConn1.RecvSubsReq(t)
580 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200581 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200582
583 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200584 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200585 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200586
Juha Hyttinen3944a222020-01-24 11:51:46 +0200587 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200588 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200589 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
590 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200591 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
592
Juha Hyttinen1683f912020-04-17 10:39:57 +0300593 // hack as there is no real way to see has message be handled.
594 // Previuos counter check just tells that is has been received by submgr
595 // --> artificial delay
596 <-time.After(1 * time.Second)
597
Juha Hyttinen3944a222020-01-24 11:51:46 +0200598 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200599 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200600
601 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200602 xappConn1.RecvSubsDelResp(t, nil)
603 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200604
605 //Wait that subs is cleaned
606 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
607
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200608 xappConn1.TestMsgChanEmpty(t)
609 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200610 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200611 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200612}
613
614//-----------------------------------------------------------------------------
615// TestSubReqAndSubDelOkTwoParallel
616//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200617// stub stub stub
618// +-------+ +-------+ +---------+ +---------+
619// | xapp | | xapp | | submgr | | e2term |
620// +-------+ +-------+ +---------+ +---------+
621// | | | |
622// | | | |
623// | | | |
624// | | SubReq1 | |
625// | |------------->| |
626// | | | |
627// | | | SubReq1 |
628// | | |------------->|
629// | | | |
630// | SubReq2 | |
631// |------------------------>| |
632// | | | |
633// | | | SubReq2 |
634// | | |------------->|
635// | | | |
636// | | | SubResp1 |
637// | | |<-------------|
638// | | SubResp1 | |
639// | |<-------------| |
640// | | | |
641// | | | SubResp2 |
642// | | |<-------------|
643// | SubResp2 | |
644// |<------------------------| |
645// | | | |
646// | | [SUBS 1 DELETE] |
647// | | | |
648// | | [SUBS 2 DELETE] |
649// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200650//
651//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300652
Juha Hyttinenfa015662020-01-24 10:05:18 +0200653func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200654 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200655
656 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200657 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200658 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200659 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200660 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200661
662 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200663 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200664 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300665
666 rparams2.Req.EventTriggerDefinition.Data.Length = 1
667 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
668 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
669
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200670 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200671 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200672
673 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200674 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200675 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200676
677 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200678 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200679 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200680
681 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200682 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200683 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
684 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200685 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200686 //Wait that subs is cleaned
687 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
688
689 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200690 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200691 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
692 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200693 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200694 //Wait that subs is cleaned
695 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
696
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200697 xappConn1.TestMsgChanEmpty(t)
698 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200699 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200700 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200701}
702
703//-----------------------------------------------------------------------------
704// TestSameSubsDiffRan
705// Same subscription to different RANs
706//
707// stub stub
708// +-------+ +---------+ +---------+
709// | xapp | | submgr | | e2term |
710// +-------+ +---------+ +---------+
711// | | |
712// | | |
713// | | |
714// | SubReq(r1) | |
715// |------------->| |
716// | | |
717// | | SubReq(r1) |
718// | |------------->|
719// | | |
720// | | SubResp(r1) |
721// | |<-------------|
722// | | |
723// | SubResp(r1) | |
724// |<-------------| |
725// | | |
726// | SubReq(r2) | |
727// |------------->| |
728// | | |
729// | | SubReq(r2) |
730// | |------------->|
731// | | |
732// | | SubResp(r2) |
733// | |<-------------|
734// | | |
735// | SubResp(r2) | |
736// |<-------------| |
737// | | |
738// | [SUBS r1 DELETE] |
739// | | |
740// | [SUBS r2 DELETE] |
741// | | |
742//
743//-----------------------------------------------------------------------------
744func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200745 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200746
747 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200748 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
749 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200750 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
751 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200752 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200753
754 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200755 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
756 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200757 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
758 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200759 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200760
761 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200762 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
763 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200764 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
765 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200766 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200767 //Wait that subs is cleaned
768 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
769
770 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200771 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
772 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200773 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
774 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200775 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200776 //Wait that subs is cleaned
777 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
778
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200779 xappConn1.TestMsgChanEmpty(t)
780 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200781 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200782 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200783}
784
785//-----------------------------------------------------------------------------
786// TestSubReqRetryInSubmgr
787//
788// stub stub
789// +-------+ +---------+ +---------+
790// | xapp | | submgr | | e2term |
791// +-------+ +---------+ +---------+
792// | | |
793// | SubReq | |
794// |------------->| |
795// | | |
796// | | SubReq |
797// | |------------->|
798// | | |
799// | | |
800// | | SubReq |
801// | |------------->|
802// | | |
803// | | SubResp |
804// | |<-------------|
805// | | |
806// | SubResp | |
807// |<-------------| |
808// | | |
809// | [SUBS DELETE] |
810// | | |
811//
812//-----------------------------------------------------------------------------
813
814func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200815 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200816
817 // Init counter check
818 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
819 Counter{cSubReqFromXapp, 1},
820 Counter{cSubReqToE2, 1},
821 Counter{cSubReReqToE2, 1},
822 Counter{cSubRespFromE2, 1},
823 Counter{cSubRespToXapp, 1},
824 Counter{cSubDelReqFromXapp, 1},
825 Counter{cSubDelReqToE2, 1},
826 Counter{cSubDelRespFromE2, 1},
827 Counter{cSubDelRespToXapp, 1},
828 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200829
830 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200831 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200832
833 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200834 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200835
836 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200837 crereq, cremsg := e2termConn1.RecvSubsReq(t)
838 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200839
840 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200842
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200843 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200844 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
845 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200847
848 // Wait that subs is cleaned
849 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
850
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200851 xappConn1.TestMsgChanEmpty(t)
852 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200853 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200854 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200855
856 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200857}
858
859//-----------------------------------------------------------------------------
860// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
861//
862// stub stub
863// +-------+ +---------+ +---------+
864// | xapp | | submgr | | e2term |
865// +-------+ +---------+ +---------+
866// | | |
867// | SubReq | |
868// |------------->| |
869// | | |
870// | | SubReq |
871// | |------------->|
872// | | |
873// | | |
874// | | SubReq |
875// | |------------->|
876// | | |
877// | | SubDelReq |
878// | |------------->|
879// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200880// | | SubDelResp |
881// | |<-------------|
882// | | |
883//
884//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200885func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200886 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200887
888 // Init counter check
889 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
890 Counter{cSubReqFromXapp, 1},
891 Counter{cSubReqToE2, 1},
892 Counter{cSubReReqToE2, 1},
893 Counter{cSubReqTimerExpiry, 2},
894 Counter{cSubDelReqToE2, 1},
895 Counter{cSubDelRespFromE2, 1},
896 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200897
898 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200899 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200900
901 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200902 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200903
904 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200905 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200906
907 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200908 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
909 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200910
911 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300912 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200913
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200914 xappConn1.TestMsgChanEmpty(t)
915 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200916 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200917 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200918
919 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920}
921
922//-----------------------------------------------------------------------------
923// TestSubReqTwoRetriesNoRespAtAllInSubmgr
924//
925// stub stub
926// +-------+ +---------+ +---------+
927// | xapp | | submgr | | e2term |
928// +-------+ +---------+ +---------+
929// | | |
930// | SubReq | |
931// |------------->| |
932// | | |
933// | | SubReq |
934// | |------------->|
935// | | |
936// | | |
937// | | SubReq |
938// | |------------->|
939// | | |
940// | | SubDelReq |
941// | |------------->|
942// | | |
943// | | |
944// | | SubDelReq |
945// | |------------->|
946// | | |
947// | | |
948//
949//-----------------------------------------------------------------------------
950
951func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200952 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200953
954 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
955 Counter{cSubReqFromXapp, 1},
956 Counter{cSubReqToE2, 1},
957 Counter{cSubReReqToE2, 1},
958 Counter{cSubReqTimerExpiry, 2},
959 Counter{cSubDelReqToE2, 1},
960 Counter{cSubDelReReqToE2, 1},
961 Counter{cSubDelReqTimerExpiry, 2},
962 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200963
964 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200965 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200966
967 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200968 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200969
970 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200971 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200972
973 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200974 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200975
976 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200977 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200978
979 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300980 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200981
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 xappConn1.TestMsgChanEmpty(t)
983 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200984 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200985 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200986
987 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200988}
989
990//-----------------------------------------------------------------------------
991// TestSubReqSubFailRespInSubmgr
992//
993// stub stub
994// +-------+ +---------+ +---------+
995// | xapp | | submgr | | e2term |
996// +-------+ +---------+ +---------+
997// | | |
998// | SubReq | |
999// |------------->| |
1000// | | |
1001// | | SubReq |
1002// | |------------->|
1003// | | |
1004// | | SubFail |
1005// | |<-------------|
1006// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001007// | | SubDelReq |
1008// | |------------->|
1009// | | |
1010// | | SubDelResp |
1011// | |<-------------|
1012// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001013// | SubFail | |
1014// |<-------------| |
1015// | | |
1016//
1017//-----------------------------------------------------------------------------
1018
1019func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001020 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001021
1022 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1023 Counter{cSubReqFromXapp, 1},
1024 Counter{cSubReqToE2, 1},
1025 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001026 Counter{cSubFailToXapp, 1},
1027 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028
1029 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001030 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001031
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001032 // E2t: Receive SubsReq and send SubsFail (first)
1033 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1034 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1035 fparams1.Set(crereq1)
1036 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1037
archaggeafbf95f2021-04-14 08:54:05 +03001038 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1039 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1040 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1041
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001042 // Xapp: Receive SubsFail
1043 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1044
1045 // Wait that subs is cleaned
1046 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1047
1048 xappConn1.TestMsgChanEmpty(t)
1049 xappConn2.TestMsgChanEmpty(t)
1050 e2termConn1.TestMsgChanEmpty(t)
1051 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001052
1053 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001054}
1055
1056//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001057// TestSubDelReqRetryInSubmgr
1058//
1059// stub stub
1060// +-------+ +---------+ +---------+
1061// | xapp | | submgr | | e2term |
1062// +-------+ +---------+ +---------+
1063// | | |
1064// | [SUBS CREATE] |
1065// | | |
1066// | | |
1067// | SubDelReq | |
1068// |------------->| |
1069// | | |
1070// | | SubDelReq |
1071// | |------------->|
1072// | | |
1073// | | SubDelReq |
1074// | |------------->|
1075// | | |
1076// | | SubDelResp |
1077// | |<-------------|
1078// | | |
1079// | SubDelResp | |
1080// |<-------------| |
1081//
1082//-----------------------------------------------------------------------------
1083
1084func TestSubDelReqRetryInSubmgr(t *testing.T) {
1085
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001086 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001087
1088 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001089 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001090 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1091 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001092 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001093
1094 // Subs Delete
1095 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001096 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001097
1098 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001099 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001100
1101 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001102 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1103 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001104
1105 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001106 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001107
1108 // Wait that subs is cleaned
1109 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1110
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001111 xappConn1.TestMsgChanEmpty(t)
1112 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001113 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001114 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001115}
1116
1117//-----------------------------------------------------------------------------
1118// TestSubDelReqTwoRetriesNoRespInSubmgr
1119//
1120// stub stub
1121// +-------+ +---------+ +---------+
1122// | xapp | | submgr | | e2term |
1123// +-------+ +---------+ +---------+
1124// | | |
1125// | [SUBS CREATE] |
1126// | | |
1127// | | |
1128// | SubDelReq | |
1129// |------------->| |
1130// | | |
1131// | | SubDelReq |
1132// | |------------->|
1133// | | |
1134// | | SubDelReq |
1135// | |------------->|
1136// | | |
1137// | | |
1138// | SubDelResp | |
1139// |<-------------| |
1140//
1141//-----------------------------------------------------------------------------
1142
1143func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1144
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001148 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001149 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1150 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001151 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152
1153 // Subs Delete
1154 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001155 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001156
1157 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001158 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001159
1160 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001161 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001162
1163 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001164 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001165
1166 // Wait that subs is cleaned
1167 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1168
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001169 xappConn1.TestMsgChanEmpty(t)
1170 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001171 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001172 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001173}
1174
1175//-----------------------------------------------------------------------------
1176// TestSubDelReqSubDelFailRespInSubmgr
1177//
1178// stub stub
1179// +-------+ +---------+ +---------+
1180// | xapp | | submgr | | e2term |
1181// +-------+ +---------+ +---------+
1182// | | |
1183// | [SUBS CREATE] |
1184// | | |
1185// | | |
1186// | SubDelReq | |
1187// |------------->| |
1188// | | |
1189// | | SubDelReq |
1190// | |------------->|
1191// | | |
1192// | | SubDelFail |
1193// | |<-------------|
1194// | | |
1195// | SubDelResp | |
1196// |<-------------| |
1197// | | |
1198//
1199//-----------------------------------------------------------------------------
1200
1201func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001202 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001203
1204 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1205 Counter{cSubReqFromXapp, 1},
1206 Counter{cSubReqToE2, 1},
1207 Counter{cSubRespFromE2, 1},
1208 Counter{cSubRespToXapp, 1},
1209 Counter{cSubDelReqFromXapp, 1},
1210 Counter{cSubDelReqToE2, 1},
1211 Counter{cSubDelFailFromE2, 1},
1212 Counter{cSubDelRespToXapp, 1},
1213 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001214
1215 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001216 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001217 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1218 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001220
1221 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001222 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001223
1224 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001225 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1226 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001227
1228 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001229 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001230
1231 // Wait that subs is cleaned
1232 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1233
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001234 xappConn1.TestMsgChanEmpty(t)
1235 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001236 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001237 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001238
1239 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001240}
1241
1242//-----------------------------------------------------------------------------
1243// TestSubReqAndSubDelOkSameAction
1244//
1245// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001246// +-------+ +-------+ +---------+ +---------+
1247// | xapp2 | | xapp1 | | submgr | | e2term |
1248// +-------+ +-------+ +---------+ +---------+
1249// | | | |
1250// | | | |
1251// | | | |
1252// | | SubReq1 | |
1253// | |------------->| |
1254// | | | |
1255// | | | SubReq1 |
1256// | | |------------->|
1257// | | | SubResp1 |
1258// | | |<-------------|
1259// | | SubResp1 | |
1260// | |<-------------| |
1261// | | | |
1262// | SubReq2 | |
1263// |--------------------------->| |
1264// | | | |
1265// | SubResp2 | |
1266// |<---------------------------| |
1267// | | | |
1268// | | SubDelReq 1 | |
1269// | |------------->| |
1270// | | | |
1271// | | SubDelResp 1 | |
1272// | |<-------------| |
1273// | | | |
1274// | SubDelReq 2 | |
1275// |--------------------------->| |
1276// | | | |
1277// | | | SubDelReq 2 |
1278// | | |------------->|
1279// | | | |
1280// | | | SubDelReq 2 |
1281// | | |------------->|
1282// | | | |
1283// | SubDelResp 2 | |
1284// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001285//
1286//-----------------------------------------------------------------------------
1287func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001288 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001289
Anssi Mannila4abf1802021-01-28 13:06:46 +02001290 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001291 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1292 Counter{cSubReqFromXapp, 2},
1293 Counter{cSubReqToE2, 1},
1294 Counter{cSubRespFromE2, 1},
1295 Counter{cSubRespToXapp, 2},
1296 Counter{cMergedSubscriptions, 1},
1297 Counter{cUnmergedSubscriptions, 1},
1298 Counter{cSubDelReqFromXapp, 2},
1299 Counter{cSubDelReqToE2, 1},
1300 Counter{cSubDelRespFromE2, 1},
1301 Counter{cSubDelRespToXapp, 2},
1302 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001303
Juha Hyttinen3944a222020-01-24 11:51:46 +02001304 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001305 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001306 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001307 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001308 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1309 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001310 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001311
1312 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001313 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001314 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001315 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001316 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1317 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001319
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001320 resp, _ := xapp.Subscription.QuerySubscriptions()
1321 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1322 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001323 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001324
Juha Hyttinen3944a222020-01-24 11:51:46 +02001325 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001326 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001327 //e2termConn1.RecvSubsDelReq(t)
1328 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001329 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001330 //Wait that subs is cleaned
1331 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1332
1333 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001334 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001335 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1336 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001337 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001338 //Wait that subs is cleaned
1339 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1340
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001341 xappConn1.TestMsgChanEmpty(t)
1342 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001343 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001344 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001345
1346 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001347}
1348
1349//-----------------------------------------------------------------------------
1350// TestSubReqAndSubDelOkSameActionParallel
1351//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001352// stub stub stub
1353// +-------+ +-------+ +---------+ +---------+
1354// | xapp2 | | xapp1 | | submgr | | e2term |
1355// +-------+ +-------+ +---------+ +---------+
1356// | | | |
1357// | | | |
1358// | | | |
1359// | | SubReq1 | |
1360// | |------------->| |
1361// | | | |
1362// | | | SubReq1 |
1363// | | |------------->|
1364// | SubReq2 | |
1365// |--------------------------->| |
1366// | | | SubResp1 |
1367// | | |<-------------|
1368// | | SubResp1 | |
1369// | |<-------------| |
1370// | | | |
1371// | SubResp2 | |
1372// |<---------------------------| |
1373// | | | |
1374// | | SubDelReq 1 | |
1375// | |------------->| |
1376// | | | |
1377// | | SubDelResp 1 | |
1378// | |<-------------| |
1379// | | | |
1380// | SubDelReq 2 | |
1381// |--------------------------->| |
1382// | | | |
1383// | | | SubDelReq 2 |
1384// | | |------------->|
1385// | | | |
1386// | | | SubDelReq 2 |
1387// | | |------------->|
1388// | | | |
1389// | SubDelResp 2 | |
1390// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001391//
1392//-----------------------------------------------------------------------------
1393func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001394 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001395
1396 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001397 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001398 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001399 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001400 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001401
1402 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001403 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001404 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001405 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001406
1407 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001408 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001409 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001410
1411 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001412 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001413
1414 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001415 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1416 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001417
1418 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001419 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001420 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1421 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001422 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001423
1424 //Wait that subs is cleaned
1425 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1426
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001427 xappConn1.TestMsgChanEmpty(t)
1428 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001429 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001430 mainCtrl.wait_registry_empty(t, 10)
1431}
1432
1433//-----------------------------------------------------------------------------
1434// TestSubReqAndSubDelNokSameActionParallel
1435//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001436// stub stub stub
1437// +-------+ +-------+ +---------+ +---------+
1438// | xapp2 | | xapp1 | | submgr | | e2term |
1439// +-------+ +-------+ +---------+ +---------+
1440// | | | |
1441// | | | |
1442// | | | |
1443// | | SubReq1 | |
1444// | |------------->| |
1445// | | | |
1446// | | | SubReq1 |
1447// | | |------------->|
1448// | SubReq2 | |
1449// |--------------------------->| |
1450// | | | SubFail1 |
1451// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001452// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001453// | | | SubDelReq |
1454// | | |------------->|
1455// | | | SubDelResp |
1456// | | |<-------------|
1457// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001458// | | SubFail1 | |
1459// | |<-------------| |
1460// | | | |
1461// | SubFail2 | |
1462// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001463//
1464//-----------------------------------------------------------------------------
1465func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001466 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001467
1468 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001469 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001470 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001471 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001472
1473 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001474 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001475
1476 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001477 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001478 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001479 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001480 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001481 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001482
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001483 // E2t: send SubsFail (first)
1484 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1485 fparams1.Set(crereq1)
1486 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1487
archaggeafbf95f2021-04-14 08:54:05 +03001488 // E2t: internal delete
1489 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1490 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1491
Juha Hyttinen3944a222020-01-24 11:51:46 +02001492 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001493 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001494 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001495 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001496
1497 //Wait that subs is cleaned
1498 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1499
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001500 xappConn1.TestMsgChanEmpty(t)
1501 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001502 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001503 mainCtrl.wait_registry_empty(t, 10)
1504}
1505
1506//-----------------------------------------------------------------------------
1507// TestSubReqAndSubDelNoAnswerSameActionParallel
1508//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001509// stub stub stub
1510// +-------+ +-------+ +---------+ +---------+
1511// | xapp2 | | xapp1 | | submgr | | e2term |
1512// +-------+ +-------+ +---------+ +---------+
1513// | | | |
1514// | | | |
1515// | | | |
1516// | | SubReq1 | |
1517// | |------------->| |
1518// | | | |
1519// | | | SubReq1 |
1520// | | |------------->|
1521// | | SubReq2 | |
1522// |--------------------------->| |
1523// | | | |
1524// | | | SubReq1 |
1525// | | |------------->|
1526// | | | |
1527// | | | |
1528// | | | SubDelReq |
1529// | | |------------->|
1530// | | | |
1531// | | | SubDelResp |
1532// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001533//
1534//-----------------------------------------------------------------------------
1535func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001536 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001537
1538 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001539 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001540 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001541 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001542
Juha Hyttinen1683f912020-04-17 10:39:57 +03001543 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001544
1545 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001546 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001547 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001548 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001549 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001550 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001551
1552 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001553 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001554
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001555 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1556 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001557
1558 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001559 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001560
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001561 xappConn1.TestMsgChanEmpty(t)
1562 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001563 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001564 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001565}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001566
1567//----------------------------- Policy cases ---------------------------------
1568//-----------------------------------------------------------------------------
1569// TestSubReqPolicyAndSubDelOk
1570//
1571// stub stub
1572// +-------+ +---------+ +---------+
1573// | xapp | | submgr | | e2term |
1574// +-------+ +---------+ +---------+
1575// | | |
1576// | SubReq | |
1577// |------------->| |
1578// | | |
1579// | | SubReq |
1580// | |------------->|
1581// | | |
1582// | | SubResp |
1583// | |<-------------|
1584// | | |
1585// | SubResp | |
1586// |<-------------| |
1587// | | |
1588// | | |
1589// | SubDelReq | |
1590// |------------->| |
1591// | | |
1592// | | SubDelReq |
1593// | |------------->|
1594// | | |
1595// | | SubDelResp |
1596// | |<-------------|
1597// | | |
1598// | SubDelResp | |
1599// |<-------------| |
1600//
1601//-----------------------------------------------------------------------------
1602func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1603 CaseBegin("TestSubReqAndSubDelOk")
1604
1605 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1606 rparams1.Init()
1607 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1608 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1609
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001610 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1611 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001612 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1613 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001614 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001615
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001616 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001617 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001618
1619 //Wait that subs is cleaned
1620 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1621
1622 xappConn1.TestMsgChanEmpty(t)
1623 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001624 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001625 mainCtrl.wait_registry_empty(t, 10)
1626}
1627
1628//-----------------------------------------------------------------------------
1629// TestSubReqPolicyChangeAndSubDelOk
1630//
1631// stub stub
1632// +-------+ +---------+ +---------+
1633// | xapp | | submgr | | e2term |
1634// +-------+ +---------+ +---------+
1635// | | |
1636// | SubReq | |
1637// |------------->| |
1638// | | |
1639// | | SubReq |
1640// | |------------->|
1641// | | |
1642// | | SubResp |
1643// | |<-------------|
1644// | | |
1645// | SubResp | |
1646// |<-------------| |
1647// | | |
1648// | SubReq | |
1649// |------------->| |
1650// | | |
1651// | | SubReq |
1652// | |------------->|
1653// | | |
1654// | | SubResp |
1655// | |<-------------|
1656// | | |
1657// | SubResp | |
1658// |<-------------| |
1659// | | |
1660// | SubDelReq | |
1661// |------------->| |
1662// | | |
1663// | | SubDelReq |
1664// | |------------->|
1665// | | |
1666// | | SubDelResp |
1667// | |<-------------|
1668// | | |
1669// | SubDelResp | |
1670// |<-------------| |
1671//
1672//-----------------------------------------------------------------------------
1673
1674func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1675 CaseBegin("TestSubReqAndSubDelOk")
1676
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001677 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1678 rparams1.Init()
1679 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1680 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001681
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001682 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1683 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001684 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1685
1686 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001687 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001688 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1689 xappConn1.SendSubsReq(t, rparams1, cretrans)
1690
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001691 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1692 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001693 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1694 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001695 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001696
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001697 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001698 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001699
1700 //Wait that subs is cleaned
1701 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1702
1703 xappConn1.TestMsgChanEmpty(t)
1704 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001705 e2termConn1.TestMsgChanEmpty(t)
1706 mainCtrl.wait_registry_empty(t, 10)
1707}
1708
1709//-----------------------------------------------------------------------------
1710// TestSubReqAndSubDelOkTwoE2termParallel
1711//
1712// stub stub stub
1713// +-------+ +---------+ +---------+ +---------+
1714// | xapp | | submgr | | e2term1 | | e2term2 |
1715// +-------+ +---------+ +---------+ +---------+
1716// | | | |
1717// | | | |
1718// | | | |
1719// | SubReq1 | | |
1720// |------------->| | |
1721// | | | |
1722// | | SubReq1 | |
1723// | |------------->| |
1724// | | | |
1725// | SubReq2 | | |
1726// |------------->| | |
1727// | | | |
1728// | | SubReq2 | |
1729// | |---------------------------->|
1730// | | | |
1731// | | SubResp1 | |
1732// | |<-------------| |
1733// | SubResp1 | | |
1734// |<-------------| | |
1735// | | SubResp2 | |
1736// | |<----------------------------|
1737// | SubResp2 | | |
1738// |<-------------| | |
1739// | | | |
1740// | [SUBS 1 DELETE] | |
1741// | | | |
1742// | [SUBS 2 DELETE] | |
1743// | | | |
1744//
1745//-----------------------------------------------------------------------------
1746func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1747 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1748
1749 //Req1
1750 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1751 xappConn1.SendSubsReq(t, nil, cretrans1)
1752 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1753
1754 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1755 xappConn1.SendSubsReq(t, nil, cretrans2)
1756 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1757
1758 //Resp1
1759 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1760 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1761
1762 //Resp2
1763 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1764 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1765
1766 //Del1
1767 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1768 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1769 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1770 xappConn1.RecvSubsDelResp(t, deltrans1)
1771 //Wait that subs is cleaned
1772 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1773
1774 //Del2
1775 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1776 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1777 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1778 xappConn1.RecvSubsDelResp(t, deltrans2)
1779 //Wait that subs is cleaned
1780 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1781
1782 xappConn1.TestMsgChanEmpty(t)
1783 xappConn2.TestMsgChanEmpty(t)
1784 e2termConn1.TestMsgChanEmpty(t)
1785 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001786 mainCtrl.wait_registry_empty(t, 10)
1787}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001788
1789//-----------------------------------------------------------------------------
1790// TestSubReqInsertAndSubDelOk
1791//
1792// stub stub
1793// +-------+ +---------+ +---------+
1794// | xapp | | submgr | | e2term |
1795// +-------+ +---------+ +---------+
1796// | | |
1797// | SubReq | |
1798// |------------->| |
1799// | | |
1800// | | SubReq |
1801// | |------------->|
1802// | | |
1803// | | SubResp |
1804// | |<-------------|
1805// | | |
1806// | SubResp | |
1807// |<-------------| |
1808// | | |
1809// | | |
1810// | SubDelReq | |
1811// |------------->| |
1812// | | |
1813// | | SubDelReq |
1814// | |------------->|
1815// | | |
1816// | | SubDelResp |
1817// | |<-------------|
1818// | | |
1819// | SubDelResp | |
1820// |<-------------| |
1821//
1822//-----------------------------------------------------------------------------
1823func TestSubReqInsertAndSubDelOk(t *testing.T) {
1824 CaseBegin("TestInsertSubReqAndSubDelOk")
1825
1826 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1827 rparams1.Init()
1828 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1829 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1830
1831 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1832 e2termConn1.SendSubsResp(t, crereq, cremsg)
1833 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1834 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1835 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1836
1837 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1838 xappConn1.RecvSubsDelResp(t, deltrans)
1839
1840 //Wait that subs is cleaned
1841 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1842
1843 xappConn1.TestMsgChanEmpty(t)
1844 xappConn2.TestMsgChanEmpty(t)
1845 e2termConn1.TestMsgChanEmpty(t)
1846 mainCtrl.wait_registry_empty(t, 10)
1847}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001848
1849//-----------------------------------------------------------------------------
1850// TestSubReqRetransmissionWithSameSubIdDiffXid
1851//
1852// This case simulates case where xApp restarts and starts sending same
1853// subscription requests which have already subscribed successfully
1854
1855// stub stub
1856// +-------+ +---------+ +---------+
1857// | xapp | | submgr | | e2term |
1858// +-------+ +---------+ +---------+
1859// | | |
1860// | SubReq | |
1861// |------------->| |
1862// | | |
1863// | | SubReq |
1864// | |------------->|
1865// | | |
1866// | | SubResp |
1867// | |<-------------|
1868// | | |
1869// | SubResp | |
1870// |<-------------| |
1871// | | |
1872// | xApp restart | |
1873// | | |
1874// | SubReq | |
1875// | (retrans with same xApp generated subid but diff xid)
1876// |------------->| |
1877// | | |
1878// | SubResp | |
1879// |<-------------| |
1880// | | |
1881// | [SUBS DELETE] |
1882// | | |
1883//
1884//-----------------------------------------------------------------------------
1885func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1886 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1887
1888 //Subs Create
1889 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1890 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1891 e2termConn1.SendSubsResp(t, crereq, cremsg)
1892 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1893
1894 // xApp restart here
1895 // --> artificial delay
1896 <-time.After(1 * time.Second)
1897
1898 //Subs Create
1899 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1900 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1901
1902 //Subs Delete
1903 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1904 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1905 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1906 xappConn1.RecvSubsDelResp(t, deltrans)
1907
1908 //Wait that subs is cleaned
1909 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1910
1911 xappConn1.TestMsgChanEmpty(t)
1912 xappConn2.TestMsgChanEmpty(t)
1913 e2termConn1.TestMsgChanEmpty(t)
1914 mainCtrl.wait_registry_empty(t, 10)
1915}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001916
1917//-----------------------------------------------------------------------------
1918// TestSubReqNokAndSubDelOkWithRestartInMiddle
1919//
1920// stub stub
1921// +-------+ +---------+ +---------+
1922// | xapp | | submgr | | e2term |
1923// +-------+ +---------+ +---------+
1924// | | |
1925// | SubReq | |
1926// |------------->| |
1927// | | |
1928// | | SubReq |
1929// | |------------->|
1930// | | |
1931// | | SubResp |
1932// | <----|
1933// | |
1934// | Submgr restart |
1935// | |
1936// | | |
1937// | | SubDelReq |
1938// | |------------->|
1939// | | |
1940// | | SubDelResp |
1941// | |<-------------|
1942// | | |
1943//
1944//-----------------------------------------------------------------------------
1945
1946func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1947 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1948
1949 // Remove possible existing subscrition
1950 mainCtrl.removeExistingSubscriptions(t)
1951
1952 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1953 xappConn1.SendSubsReq(t, nil, nil)
1954 e2termConn1.RecvSubsReq(t)
1955 mainCtrl.SetResetTestFlag(t, false)
1956
1957 resp, _ := xapp.Subscription.QuerySubscriptions()
1958 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001959 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02001960 e2SubsId := uint32(resp[0].SubscriptionID)
1961 t.Logf("e2SubsId = %v", e2SubsId)
1962
archaggeafbf95f2021-04-14 08:54:05 +03001963 mainCtrl.SimulateRestart(t)
1964 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02001965
1966 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1967 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1968
1969 // Wait that subs is cleaned
1970 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1971
1972 xappConn1.TestMsgChanEmpty(t)
1973 xappConn2.TestMsgChanEmpty(t)
1974 e2termConn1.TestMsgChanEmpty(t)
1975 mainCtrl.wait_registry_empty(t, 10)
1976}
1977
1978//-----------------------------------------------------------------------------
1979// TestSubReqAndSubDelOkWithRestartInMiddle
1980//
1981// stub stub
1982// +-------+ +---------+ +---------+
1983// | xapp | | submgr | | e2term |
1984// +-------+ +---------+ +---------+
1985// | | |
1986// | SubReq | |
1987// |------------->| |
1988// | | |
1989// | | SubReq |
1990// | |------------->|
1991// | | |
1992// | | SubResp |
1993// | |<-------------|
1994// | | |
1995// | SubResp | |
1996// |<-------------| |
1997// | | |
1998// | |
1999// | Submgr restart |
2000// | |
2001// | SubDelReq | |
2002// |------------->| |
2003// | | |
2004// | | SubDelReq |
2005// | |------------->|
2006// | | |
2007// | | SubDelResp |
2008// | |<-------------|
2009// | | |
2010// | SubDelResp | |
2011// |<-------------| |
2012//
2013//-----------------------------------------------------------------------------
2014
2015func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2016 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2017
2018 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2019 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2020 e2termConn1.SendSubsResp(t, crereq, cremsg)
2021 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2022
2023 // Check subscription
2024 resp, _ := xapp.Subscription.QuerySubscriptions()
2025 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2026 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002027 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002028
2029 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002030 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002031
2032 // Check that subscription is restored correctly after restart
2033 resp, _ = xapp.Subscription.QuerySubscriptions()
2034 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2035 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002036 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002037
2038 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2039 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2040 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2041 xappConn1.RecvSubsDelResp(t, deltrans)
2042
2043 //Wait that subs is cleaned
2044 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2045
2046 xappConn1.TestMsgChanEmpty(t)
2047 xappConn2.TestMsgChanEmpty(t)
2048 e2termConn1.TestMsgChanEmpty(t)
2049 mainCtrl.wait_registry_empty(t, 10)
2050}
2051
2052//-----------------------------------------------------------------------------
2053// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2054//
2055// stub stub
2056// +-------+ +-------+ +---------+ +---------+
2057// | xapp2 | | xapp1 | | submgr | | e2term |
2058// +-------+ +-------+ +---------+ +---------+
2059// | | | |
2060// | | | |
2061// | | | |
2062// | | SubReq1 | |
2063// | |------------->| |
2064// | | | |
2065// | | | SubReq1 |
2066// | | |------------->|
2067// | | | SubResp1 |
2068// | | |<-------------|
2069// | | SubResp1 | |
2070// | |<-------------| |
2071// | | | |
2072// | |
2073// | submgr restart |
2074// | |
2075// | | | |
2076// | | | |
2077// | SubReq2 | |
2078// |--------------------------->| |
2079// | | | |
2080// | SubResp2 | |
2081// |<---------------------------| |
2082// | | | |
2083// | | SubDelReq 1 | |
2084// | |------------->| |
2085// | | | |
2086// | | SubDelResp 1 | |
2087// | |<-------------| |
2088// | | | |
2089// | | | |
2090// | |
2091// | submgr restart |
2092// | |
2093// | | | |
2094// | SubDelReq 2 | |
2095// |--------------------------->| |
2096// | | | |
2097// | | | SubDelReq 2 |
2098// | | |------------->|
2099// | | | |
2100// | | | SubDelReq 2 |
2101// | | |------------->|
2102// | | | |
2103// | SubDelResp 2 | |
2104// |<---------------------------| |
2105//
2106//-----------------------------------------------------------------------------
2107
2108func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2109 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2110
2111 //Req1
2112 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2113 rparams1.Init()
2114 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2115 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2116 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2117 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2118
2119 //Req2
2120 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2121 rparams2.Init()
2122 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2123 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2124
2125 // Check subscription
2126 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2127 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2128 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002129 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002130
2131 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002132 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002133
2134 // Check that subscription is restored correctly after restart
2135 resp, _ = xapp.Subscription.QuerySubscriptions()
2136 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2137 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002138 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002139
2140 //Del1
2141 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2142 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2143 xappConn1.RecvSubsDelResp(t, deltrans1)
2144 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2145
2146 mainCtrl.SimulateRestart(t)
2147 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2148
2149 //Del2
2150 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2151 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2152
2153 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2154 xappConn2.RecvSubsDelResp(t, deltrans2)
2155
2156 //Wait that subs is cleaned
2157 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2158
2159 xappConn1.TestMsgChanEmpty(t)
2160 xappConn2.TestMsgChanEmpty(t)
2161 e2termConn1.TestMsgChanEmpty(t)
2162 mainCtrl.wait_registry_empty(t, 10)
2163}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002164
archaggeafbf95f2021-04-14 08:54:05 +03002165//*****************************************************************************
2166// REST interface test cases
2167//*****************************************************************************
2168
Anssi Mannila47518ae2021-04-16 09:27:07 +03002169//-----------------------------------------------------------------------------
2170// Test debug GET and POST requests
2171//
2172// curl
2173// +-------+ +---------+
2174// | user | | submgr |
2175// +-------+ +---------+
2176// | |
2177// | GET/POST Req |
2178// |------------->|
2179// | Resp |
2180// |<-------------|
2181// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002182func TestGetSubscriptions(t *testing.T) {
2183
2184 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2185}
2186
2187func TestGetSymptomData(t *testing.T) {
2188
2189 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2190}
2191
2192func TestPostdeleteSubId(t *testing.T) {
2193
2194 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2195}
2196
2197func TestPostEmptyDb(t *testing.T) {
2198
2199 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2200}
archaggeafbf95f2021-04-14 08:54:05 +03002201
2202//-----------------------------------------------------------------------------
2203// TestRESTSubReqAndRouteNok
2204//
2205// stub stub
2206// +-------+ +---------+ +---------+
2207// | xapp | | submgr | | rtmgr |
2208// +-------+ +---------+ +---------+
2209// | | |
2210// | RESTSubReq | |
2211// |---------------->| |
2212// | | |
2213// | RESTSubResp | |
2214// |<----------------| |
2215// | | RouteCreate |
2216// | |------------->|
2217// | | |
2218// | | RouteCreate |
2219// | | status:400 |
2220// | |(Bad request) |
2221// | |<-------------|
2222// | RESTNotif | |
2223// |<----------------| |
2224// | | |
2225// | [SUBS INT DELETE] |
2226// | | |
2227// | RESTSubDelReq | |
2228// |---------------->| |
2229// | RESTSubDelResp | |
2230// |<----------------| |
2231//
2232//-----------------------------------------------------------------------------
2233func TestRESTSubReqAndRouteNok(t *testing.T) {
2234 CaseBegin("TestRESTSubReqAndRouteNok")
2235
2236 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2237 Counter{cSubReqFromXapp, 1},
2238 Counter{cRouteCreateFail, 1},
2239 Counter{cSubRespToXapp, 1},
2240 Counter{cSubDelReqFromXapp, 1},
2241 Counter{cSubDelRespToXapp, 1},
2242 })
2243
2244 const subReqCount int = 1
2245 const parameterSet = 1
2246 const actionDefinitionPresent bool = true
2247 const actionParamCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002248 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2249 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002250 newSubsId := mainCtrl.get_registry_next_subid(t)
2251
2252 // Req
2253 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2254 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002255 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002256 waiter.WaitResult(t)
2257
archaggeafbf95f2021-04-14 08:54:05 +03002258 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2259 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2260
2261 // Del
2262 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2263
2264 // Wait that subs is cleaned
2265 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2266 waitSubsCleanup(t, e2SubsId, 10)
2267 mainCtrl.VerifyCounterValues(t)
2268}
2269
2270func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2271 CaseBegin("TestSubReqAndRouteUpdateNok")
2272
2273 //Init counter check
2274 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2275 Counter{cSubReqFromXapp, 2},
2276 Counter{cSubReqToE2, 1},
2277 Counter{cSubRespFromE2, 1},
2278 Counter{cSubRespToXapp, 2},
2279 Counter{cRouteCreateUpdateFail, 1},
2280 Counter{cSubDelReqFromXapp, 1},
2281 Counter{cSubDelReqToE2, 1},
2282 Counter{cSubDelRespFromE2, 1},
2283 Counter{cSubDelRespToXapp, 1},
2284 })
2285
2286 var params *teststube2ap.RESTSubsReqParams = nil
2287
2288 //Subs Create
2289 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2290
2291 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2292
2293 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2294 waiter := rtmgrHttp.AllocNextEvent(false)
2295 newSubsId := mainCtrl.get_registry_next_subid(t)
2296 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2297 params.SetMeid("RAN_NAME_1")
2298 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2299 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
2300 xappConn2.ExpectRESTNotification(t, restSubId2)
2301 waiter.WaitResult(t)
2302 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2303 xappConn2.WaitRESTNotification(t, restSubId2)
2304
2305 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2306
2307 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2308
2309 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2310 //Wait that subs is cleaned
2311 waitSubsCleanup(t, e2SubsId, 10)
2312
2313 mainCtrl.VerifyCounterValues(t)
2314}
2315
2316func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2317 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2318
2319 // Init counter check
2320 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2321 Counter{cSubReqFromXapp, 1},
2322 Counter{cSubReqToE2, 1},
2323 Counter{cSubRespFromE2, 1},
2324 Counter{cSubRespToXapp, 1},
2325 Counter{cSubDelReqFromXapp, 1},
2326 Counter{cRouteDeleteFail, 1},
2327 Counter{cSubDelReqToE2, 1},
2328 Counter{cSubDelRespFromE2, 1},
2329 Counter{cSubDelRespToXapp, 1},
2330 })
2331
2332 var params *teststube2ap.RESTSubsReqParams = nil
2333
2334 //Subs Create
2335 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2336
2337 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2338
2339 waiter := rtmgrHttp.AllocNextEvent(false)
2340 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2341 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2342 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2343 waiter.WaitResult(t)
2344
2345 waitSubsCleanup(t, e2SubsId, 10)
2346
2347 mainCtrl.VerifyCounterValues(t)
2348}
2349
2350func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2351 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2352
2353 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2354 Counter{cSubReqFromXapp, 2},
2355 Counter{cSubReqToE2, 1},
2356 Counter{cSubRespFromE2, 1},
2357 Counter{cSubRespToXapp, 2},
2358 Counter{cSubDelReqFromXapp, 2},
2359 Counter{cRouteDeleteUpdateFail, 1},
2360 Counter{cSubDelReqToE2, 1},
2361 Counter{cSubDelRespFromE2, 1},
2362 Counter{cSubDelRespToXapp, 2},
2363 })
2364
2365 var params *teststube2ap.RESTSubsReqParams = nil
2366
2367 //Subs Create
2368 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2369
2370 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2371 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2372
2373 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2374
2375 //Del1, this shall fail on rtmgr side
2376 waiter := rtmgrHttp.AllocNextEvent(false)
2377 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2378 waiter.WaitResult(t)
2379
2380 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2381
2382 //Del2
2383 deleteXapp2Subscription(t, &restSubId2)
2384
2385 waitSubsCleanup(t, e2SubsId2, 10)
2386
2387 mainCtrl.VerifyCounterValues(t)
2388}
2389
2390//-----------------------------------------------------------------------------
2391// TestRESTSubReqRetransmission
2392//
2393// stub stub
2394// +-------+ +---------+ +---------+
2395// | xapp | | submgr | | e2term |
2396// +-------+ +---------+ +---------+
2397// | | |
2398// | RESTSubReq1 | |
2399// |---------------->| |
2400// | | |
2401// | RESTSubResp | |
2402// |<----------------| |
2403// | | SubReq1 |
2404// | |------------->|
2405// | | |
2406// | RESTSubReq2 | |
2407// | (retrans) | |
2408// |---------------->| |
2409// | | |
2410// | | SubReq2 |
2411// | |------------->|
2412// | RESTSubResp2 | |
2413// |<----------------| |
2414// | | SubResp1 |
2415// | |<-------------|
2416// | RESTNotif1 | |
2417// |<----------------| |
2418// | | SubResp1 |
2419// | |<-------------|
2420// | RESTNotif2 | |
2421// |<----------------| |
2422// | | |
2423// | [SUBS DELETE] |
2424// | | |
2425//
2426//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002427
archaggeafbf95f2021-04-14 08:54:05 +03002428func TestRESTSubReqRetransmission(t *testing.T) {
2429 CaseBegin("TestRESTSubReqRetransmission")
2430
2431 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2432 Counter{cSubReqFromXapp, 2},
2433 Counter{cSubReqToE2, 2},
2434 Counter{cSubRespFromE2, 2},
2435 Counter{cSubRespToXapp, 2},
2436 Counter{cSubDelReqFromXapp, 2},
2437 Counter{cSubDelReqToE2, 2},
2438 Counter{cSubDelRespFromE2, 2},
2439 Counter{cSubDelRespToXapp, 2},
2440 })
2441 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2442 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2443 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2444
2445 // Subs Create
2446 const subReqCount int = 1
2447 const parameterSet = 1
2448 const actionDefinitionPresent bool = true
2449 const actionParamCount int = 1
2450
2451 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2452 // gets into execution before the rtmgrg responds for the first one.
2453 waiter := rtmgrHttp.AllocNextSleep(10, true)
2454 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2455 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2456 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2457
2458 waiter.WaitResult(t)
2459
2460 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2461
2462 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2463 // the order is not significant he6re.
2464 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2465 e2termConn1.SendSubsResp(t, crereq, cremsg)
2466 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2467 e2termConn1.SendSubsResp(t, crereq, cremsg)
2468
2469 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2470 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2471 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2472 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2473
2474 // Del1
2475 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2476 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2477 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2478
archaggeafbf95f2021-04-14 08:54:05 +03002479 // Del2
2480 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2481 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2482 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2483
Markku Virtanenda34eec2021-05-20 08:22:04 +00002484 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
2485
archaggeafbf95f2021-04-14 08:54:05 +03002486 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2487
2488 mainCtrl.VerifyCounterValues(t)
2489}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002490
archaggeafbf95f2021-04-14 08:54:05 +03002491func TestRESTSubDelReqRetransmission(t *testing.T) {
2492 CaseBegin("TestRESTSubDelReqRetransmission")
2493
2494 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2495 Counter{cSubReqFromXapp, 1},
2496 Counter{cSubReqToE2, 1},
2497 Counter{cSubRespFromE2, 1},
2498 Counter{cSubRespToXapp, 1},
2499 Counter{cSubDelReqFromXapp, 2},
2500 Counter{cSubDelReqToE2, 1},
2501 Counter{cSubDelRespFromE2, 1},
2502 Counter{cSubDelRespToXapp, 1},
2503 })
2504
2505 var params *teststube2ap.RESTSubsReqParams = nil
2506
2507 //Subs Create
2508 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2509
2510 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2511
2512 //Subs Delete
2513 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2514 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2515
2516 seqBef := mainCtrl.get_msgcounter(t)
2517 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2518 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2519
2520 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2521
2522 waitSubsCleanup(t, e2SubsId, 10)
2523
2524 mainCtrl.VerifyCounterValues(t)
2525}
2526
2527//-----------------------------------------------------------------------------
2528// TestRESTSubReqDelReq
2529//
2530// stub stub
2531// +-------+ +---------+ +---------+
2532// | xapp | | submgr | | e2term |
2533// +-------+ +---------+ +---------+
2534// | | |
2535// | RESTSubReq | |
2536// |---------------->| |
2537// | | |
2538// | RESTSubResp | |
2539// |<----------------| |
2540// | | SubReq |
2541// | |------------->|
2542// | RESTSubDelReq | |
2543// |---------------->| |
2544// | RESTSubDelResp | |
2545// | unsuccess | |
2546// |<----------------| |
2547// | | SubResp |
2548// | |<-------------|
2549// | RESTNotif1 | |
2550// |<----------------| |
2551// | | |
2552// | [SUBS DELETE] |
2553// | | |
2554//
2555//-----------------------------------------------------------------------------
2556func TestRESTSubReqDelReq(t *testing.T) {
2557 CaseBegin("TestRESTSubReqDelReq")
2558
2559 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2560 Counter{cSubReqFromXapp, 1},
2561 Counter{cSubReqToE2, 1},
2562 Counter{cSubRespFromE2, 1},
2563 Counter{cSubRespToXapp, 1},
2564 Counter{cSubDelReqFromXapp, 2},
2565 Counter{cSubDelReqToE2, 1},
2566 Counter{cSubDelRespFromE2, 1},
2567 Counter{cSubDelRespToXapp, 1},
2568 })
2569
2570 const subReqCount int = 1
2571 const parameterSet = 1
2572 const actionDefinitionPresent bool = true
2573 const actionParamCount int = 1
2574
2575 // Req
2576 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2577 restSubId := xappConn1.SendRESTSubsReq(t, params)
2578
2579 // Del. This will fail as processing of the subscription
2580 // is still ongoing in submgr. Deletion is not allowed before
2581 // subscription creation has been completed.
2582 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2583 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2584 xappConn1.ExpectRESTNotification(t, restSubId)
2585 e2termConn1.SendSubsResp(t, crereq, cremsg)
2586 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2587
2588 // Retry del
2589 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2590
2591 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2592 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2593
2594 // Wait that subs is cleaned
2595 waitSubsCleanup(t, e2SubsId, 10)
2596 mainCtrl.VerifyCounterValues(t)
2597
2598}
2599
2600func TestRESTSubDelReqCollision(t *testing.T) {
2601 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2602}
2603
2604func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2605 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2606
2607 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2608 Counter{cSubReqFromXapp, 2},
2609 Counter{cSubReqToE2, 2},
2610 Counter{cSubRespFromE2, 2},
2611 Counter{cSubRespToXapp, 2},
2612 Counter{cSubDelReqFromXapp, 2},
2613 Counter{cSubDelReqToE2, 2},
2614 Counter{cSubDelRespFromE2, 2},
2615 Counter{cSubDelRespToXapp, 2},
2616 })
2617
2618 //Req1
2619 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2620 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2621 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2622
2623 //Req2
2624 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2625 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2626 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2627
2628 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2629 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2630
2631 //XappConn1 receives both of the responses
2632 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2633
2634 //Resp1
2635 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2636 //Resp2
2637 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2638
2639 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2640 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2641 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2642 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2643
2644 //Del1
2645 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2646 //Del2
2647 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2648
2649 //Wait that subs is cleaned
2650 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2651 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2652
2653 mainCtrl.VerifyCounterValues(t)
2654
2655}
2656
2657func TestRESTSameSubsDiffRan(t *testing.T) {
2658 CaseBegin("TestRESTSameSubsDiffRan")
2659
2660 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2661 Counter{cSubReqFromXapp, 2},
2662 Counter{cSubReqToE2, 2},
2663 Counter{cSubRespFromE2, 2},
2664 Counter{cSubRespToXapp, 2},
2665 Counter{cSubDelReqFromXapp, 2},
2666 Counter{cSubDelReqToE2, 2},
2667 Counter{cSubDelRespFromE2, 2},
2668 Counter{cSubDelRespToXapp, 2},
2669 })
2670
2671 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2672 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2673 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2674
2675 params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2676 params.SetMeid("RAN_NAME_2")
2677 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2678 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2679
2680 //Del1
2681 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2682 //Del2
2683 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2684
2685 //Wait that subs is cleaned
2686 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2687 waitSubsCleanup(t, e2SubsId2, 10)
2688
2689 mainCtrl.VerifyCounterValues(t)
2690
2691}
2692
2693func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2694 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2695
2696 // Init counter check
2697 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2698 Counter{cSubReqFromXapp, 1},
2699 Counter{cSubReqToE2, 1},
2700 Counter{cSubReReqToE2, 1},
2701 Counter{cSubRespFromE2, 1},
2702 Counter{cSubRespToXapp, 1},
2703 Counter{cSubDelReqFromXapp, 1},
2704 Counter{cSubDelReqToE2, 1},
2705 Counter{cSubDelRespFromE2, 1},
2706 Counter{cSubDelRespToXapp, 1},
2707 })
2708
2709 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2710 restSubId := xappConn1.SendRESTSubsReq(t, params)
2711
2712 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2713
2714 // Catch the first message and ignore it
2715 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2716 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2717
2718 // The second request is being handled normally
2719 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2720 xappConn1.ExpectRESTNotification(t, restSubId)
2721 e2termConn1.SendSubsResp(t, crereq, cremsg)
2722 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2723
2724 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2725
2726 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2727
2728 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2729 //Wait that subs is cleaned
2730 waitSubsCleanup(t, e2SubsId, 10)
2731
2732 mainCtrl.VerifyCounterValues(t)
2733
2734}
2735
2736//-----------------------------------------------------------------------------
2737// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2738//
2739// stub stub
2740// +-------+ +---------+ +---------+
2741// | xapp | | submgr | | e2term |
2742// +-------+ +---------+ +---------+
2743// | | |
2744// | RESTSubReq | |
2745// |---------------->| |
2746// | | |
2747// | RESTSubResp | |
2748// |<----------------| |
2749// | | SubReq |
2750// | |------------->|
2751// | | |
2752// | | |
2753// | | SubReq |
2754// | |------------->|
2755// | | |
2756// | | SubDelReq |
2757// | |------------->|
2758// | | |
2759// | | |
2760// | | SubDelReq |
2761// | |------------->|
2762// | | |
2763// | | |
2764// | | SubDelResp |
2765// | |<-------------|
2766// | RESTNotif | |
2767// | unsuccess | |
2768// |<----------------| |
2769// | | |
2770// | [SUBS DELETE] |
2771// | | |
2772//
2773//-----------------------------------------------------------------------------
2774func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2775 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2776
2777 // Init counter check
2778 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2779 Counter{cSubReqFromXapp, 1},
2780 Counter{cSubReqToE2, 1},
2781 Counter{cSubReReqToE2, 1},
2782 Counter{cSubReqTimerExpiry, 2},
2783 Counter{cSubDelReqToE2, 1},
2784 Counter{cSubDelRespFromE2, 1},
2785 })
2786
2787 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2788 restSubId := xappConn1.SendRESTSubsReq(t, params)
2789 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2790
2791 e2termConn1.RecvSubsReq(t)
2792 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2793
2794 e2termConn1.RecvSubsReq(t)
2795 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2796
2797 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2798 xappConn1.ExpectRESTNotification(t, restSubId)
2799 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2800 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2801 xappConn1.WaitRESTNotification(t, restSubId)
2802
2803 // Wait that subs is cleaned
2804 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2805
2806 mainCtrl.VerifyCounterValues(t)
2807}
2808
2809func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2810 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2811
2812 // Init counter check
2813 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2814 Counter{cSubReqFromXapp, 1},
2815 Counter{cSubReqToE2, 1},
2816 Counter{cSubReReqToE2, 1},
2817 Counter{cSubReqTimerExpiry, 2},
2818 Counter{cSubDelReqToE2, 1},
2819 Counter{cSubDelReqTimerExpiry, 2},
2820 })
2821
2822 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2823 restSubId := xappConn1.SendRESTSubsReq(t, params)
2824 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2825
2826 e2termConn1.RecvSubsReq(t)
2827 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2828
2829 e2termConn1.RecvSubsReq(t)
2830 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2831
2832 e2termConn1.RecvSubsDelReq(t)
2833 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2834
2835 xappConn1.ExpectRESTNotification(t, restSubId)
2836 e2termConn1.RecvSubsDelReq(t)
2837 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2838
2839 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2840
2841 waitSubsCleanup(t, e2SubsId, 10)
2842
2843 mainCtrl.VerifyCounterValues(t)
2844
2845}
2846
2847//-----------------------------------------------------------------------------
2848// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2849//
2850// stub stub
2851// +-------+ +---------+ +---------+
2852// | xapp | | submgr | | e2term |
2853// +-------+ +---------+ +---------+
2854// | | |
2855// | RESTSubReq | |
2856// |---------------->| |
2857// | | |
2858// | RESTSubResp | |
2859// |<----------------| |
2860// | | SubReq |
2861// | |------------->|
2862// | | |
2863// | | |
2864// | | SubReq |
2865// | |------------->|
2866// | | |
2867// | | SubDelReq |
2868// | |------------->|
2869// | | |
2870// | | |
2871// | | SubDelReq |
2872// | |------------->|
2873// | | |
2874// | | |
2875// | | SubDelResp |
2876// | |<-------------|
2877// | RESTNotif | |
2878// | unsuccess | |
2879// |<----------------| |
2880// | | |
2881// | [SUBS DELETE] |
2882// | | |
2883//
2884//-----------------------------------------------------------------------------
2885func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
2886 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
2887
2888 // Init counter check
2889 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2890 Counter{cSubReqFromXapp, 1},
2891 Counter{cSubReqToE2, 1},
2892 Counter{cSubReReqToE2, 1},
2893 Counter{cSubReqTimerExpiry, 2},
2894 Counter{cSubDelReqToE2, 1},
2895 Counter{cSubDelReReqToE2, 1},
2896 Counter{cSubDelReqTimerExpiry, 2},
2897 })
2898
2899 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2900 restSubId := xappConn1.SendRESTSubsReq(t, params)
2901 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2902
2903 e2termConn1.RecvSubsReq(t)
2904 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2905
2906 e2termConn1.RecvSubsReq(t)
2907 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2908
2909 e2termConn1.RecvSubsDelReq(t)
2910 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2911
2912 xappConn1.ExpectRESTNotification(t, restSubId)
2913 e2termConn1.RecvSubsDelReq(t)
2914 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2915
2916 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2917
2918 waitSubsCleanup(t, e2SubsId, 10)
2919
2920 mainCtrl.VerifyCounterValues(t)
2921}
2922
2923//-----------------------------------------------------------------------------
2924// TestRESTSubReqSubFailRespInSubmgr
2925//
2926// stub stub
2927// +-------+ +---------+ +---------+
2928// | xapp | | submgr | | e2term |
2929// +-------+ +---------+ +---------+
2930// | | |
2931// | RESTSubReq | |
2932// |---------------->| |
2933// | | |
2934// | RESTSubResp | |
2935// |<----------------| |
2936// | | SubReq |
2937// | |------------->|
2938// | | |
2939// | | SubFail |
2940// | |<-------------|
2941// | | |
2942// | | SubDelReq |
2943// | |------------->|
2944// | | |
2945// | | SubDelResp |
2946// | |<-------------|
2947// | | |
2948// | RESTNotif | |
2949// | unsuccess | |
2950// |<----------------| |
2951// | | |
2952// | [SUBS DELETE] |
2953// | | |
2954//
2955//-----------------------------------------------------------------------------
2956func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
2957 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
2958
2959 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2960 Counter{cSubReqFromXapp, 1},
2961 Counter{cSubReqToE2, 1},
2962 Counter{cSubFailFromE2, 1},
2963 Counter{cSubRespToXapp, 1},
2964 Counter{cSubDelReqFromXapp, 1},
2965 })
2966
2967 const subReqCount int = 1
2968 const parameterSet = 1
2969 const actionDefinitionPresent bool = true
2970 const actionParamCount int = 1
2971
2972 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2973 restSubId := xappConn1.SendRESTSubsReq(t, params)
2974
2975 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2976 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2977 fparams1.Set(crereq1)
2978 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2979
2980 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2981 xappConn1.ExpectRESTNotification(t, restSubId)
2982 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2983 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2984 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2985
2986 // REST subscription sill there to be deleted
2987 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2988
2989 // Wait that subs is cleaned
2990 waitSubsCleanup(t, e2SubsId, 10)
2991
2992 mainCtrl.VerifyCounterValues(t)
2993
2994}
2995
2996//-----------------------------------------------------------------------------
2997// TestRESTSubDelReqRetryInSubmgr
2998//
2999// stub stub
3000// +-------+ +---------+ +---------+
3001// | xapp | | submgr | | e2term |
3002// +-------+ +---------+ +---------+
3003// | | |
3004// | [SUBS CREATE] |
3005// | | |
3006// | | |
3007// | RESTSubDelReq | |
3008// |---------------->| |
3009// | | |
3010// | RESTSubDelResp | |
3011// |<----------------| |
3012// | | SubDelReq |
3013// | |------------->|
3014// | | |
3015// | | SubDelReq |
3016// | |------------->|
3017// | | |
3018// | | SubDelResp |
3019// | |<-------------|
3020// | | |
3021//
3022//-----------------------------------------------------------------------------
3023func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3024 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3025
3026 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3027 Counter{cSubReqFromXapp, 1},
3028 Counter{cSubReqToE2, 1},
3029 Counter{cSubRespFromE2, 1},
3030 Counter{cSubRespToXapp, 1},
3031 Counter{cSubDelReqFromXapp, 1},
3032 Counter{cSubDelReqToE2, 1},
3033 Counter{cSubDelReReqToE2, 1},
3034 Counter{cSubDelRespFromE2, 1},
3035 Counter{cSubDelRespToXapp, 1},
3036 })
3037 // Req
3038 var params *teststube2ap.RESTSubsReqParams = nil
3039 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3040
3041 // Del
3042 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3043
3044 // E2t: Receive 1st SubsDelReq
3045 e2termConn1.RecvSubsDelReq(t)
3046
3047 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3048 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3049 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3050
3051 //Wait that subs is cleaned
3052 waitSubsCleanup(t, e2SubsId, 10)
3053
3054 mainCtrl.VerifyCounterValues(t)
3055}
3056
3057//-----------------------------------------------------------------------------
3058// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3059//
3060// stub stub
3061// +-------+ +---------+ +---------+
3062// | xapp | | submgr | | e2term |
3063// +-------+ +---------+ +---------+
3064// | | |
3065// | [SUBS CREATE] |
3066// | | |
3067// | | |
3068// | RESTSubDelReq | |
3069// |---------------->| |
3070// | | |
3071// | RESTSubDelResp | |
3072// |<----------------| |
3073// | | SubDelReq |
3074// | |------------->|
3075// | | |
3076// | | SubDelReq |
3077// | |------------->|
3078// | | |
3079// | | |
3080//
3081//-----------------------------------------------------------------------------
3082func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3083 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3084
3085 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3086 Counter{cSubReqFromXapp, 1},
3087 Counter{cSubReqToE2, 1},
3088 Counter{cSubRespFromE2, 1},
3089 Counter{cSubRespToXapp, 1},
3090 Counter{cSubDelReqFromXapp, 1},
3091 Counter{cSubDelReqToE2, 1},
3092 Counter{cSubDelReReqToE2, 1},
3093 Counter{cSubDelRespFromE2, 1},
3094 Counter{cSubDelRespToXapp, 1},
3095 })
3096
3097 // Req
3098 var params *teststube2ap.RESTSubsReqParams = nil
3099 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3100
3101 // Del
3102 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3103
3104 // E2t: Receive 1st SubsDelReq
3105 e2termConn1.RecvSubsDelReq(t)
3106
3107 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3108 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3109 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3110
3111 //Wait that subs is cleaned
3112 waitSubsCleanup(t, e2SubsId, 10)
3113
3114 mainCtrl.VerifyCounterValues(t)
3115}
3116
3117//-----------------------------------------------------------------------------
3118// TestRESTSubDelReqSubDelFailRespInSubmgr
3119//
3120// stub stub
3121// +-------+ +---------+ +---------+
3122// | xapp | | submgr | | e2term |
3123// +-------+ +---------+ +---------+
3124// | | |
3125// | [SUBS CREATE] |
3126// | | |
3127// | | |
3128// | RESTSubDelReq | |
3129// |---------------->| |
3130// | | |
3131// | RESTSubDelResp | |
3132// |<----------------| |
3133// | | SubDelReq |
3134// | |------------->|
3135// | | |
3136// | | SubDelFail |
3137// | |<-------------|
3138// | | |
3139//
3140//-----------------------------------------------------------------------------
3141func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3142 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3143
3144 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3145 Counter{cSubReqFromXapp, 1},
3146 Counter{cSubReqToE2, 1},
3147 Counter{cSubRespFromE2, 1},
3148 Counter{cSubRespToXapp, 1},
3149 Counter{cSubDelReqFromXapp, 1},
3150 Counter{cSubDelReqToE2, 1},
3151 Counter{cSubDelFailFromE2, 1},
3152 Counter{cSubDelRespToXapp, 1},
3153 })
3154
3155 // Req
3156 var params *teststube2ap.RESTSubsReqParams = nil
3157 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3158
3159 // Del
3160 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3161
3162 // E2t: Send receive SubsDelReq and send SubsDelFail
3163 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3164 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3165
3166 //Wait that subs is cleaned
3167 waitSubsCleanup(t, e2SubsId, 10)
3168
3169 mainCtrl.VerifyCounterValues(t)
3170}
3171
3172//-----------------------------------------------------------------------------
3173// TestRESTSubReqAndSubDelOkSameAction
3174//
3175// stub stub
3176// +-------+ +-------+ +---------+ +---------+
3177// | xapp2 | | xapp1 | | submgr | | e2term |
3178// +-------+ +-------+ +---------+ +---------+
3179// | | | |
3180// | | RESTSubReq1 | |
3181// | |---------------->| |
3182// | | | |
3183// | | RESTSubResp1 | |
3184// | |<----------------| |
3185// | | | |
3186// | | | SubReq1 |
3187// | | |------------->|
3188// | | | SubResp1 |
3189// | | |<-------------|
3190// | | RESTNotif1 | |
3191// | |<----------------| |
3192// | | | |
3193// | RESTSubReq2 | |
3194// |------------------------------>| |
3195// | | | |
3196// | RESTSubResp2 | |
3197// |<------------------------------| |
3198// | | | |
3199// | | RESTNotif2 | |
3200// |<------------------------------| |
3201// | | | |
3202// | | RESTSubDelReq1 | |
3203// | |---------------->| |
3204// | | | |
3205// | | RESTSubDelResp1 | |
3206// | |<----------------| |
3207// | | | |
3208// | RESTSubDelReq2 | |
3209// |------------------------------>| |
3210// | | | |
3211// | RESTSubDelResp2 | |
3212// |<------------------------------| |
3213// | | | |
3214// | | | SubDelReq2 |
3215// | | |------------->|
3216// | | | |
3217// | | | SubDelResp2 |
3218// | | |<-------------|
3219// | | | |
3220//
3221//-----------------------------------------------------------------------------
3222func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3223 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3224
3225 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3226 Counter{cSubReqFromXapp, 2},
3227 Counter{cSubReqToE2, 1},
3228 Counter{cSubRespFromE2, 1},
3229 Counter{cSubRespToXapp, 2},
3230 Counter{cMergedSubscriptions, 1},
3231 Counter{cUnmergedSubscriptions, 1},
3232 Counter{cSubDelReqFromXapp, 2},
3233 Counter{cSubDelReqToE2, 1},
3234 Counter{cSubDelRespFromE2, 1},
3235 Counter{cSubDelRespToXapp, 2},
3236 })
3237
3238 // Req1
3239 var params *teststube2ap.RESTSubsReqParams = nil
3240
3241 //Subs Create
3242 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3243 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3244
3245 // Req2
3246 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3247 params.SetMeid("RAN_NAME_1")
3248
3249 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3250 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003251 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003252 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003253 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003254 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3255 e2SubsId2 := <-xappConn2.RESTNotification
3256 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3257
3258 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3259
3260 // Del1
3261 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3262
3263 // Del2
3264 deleteXapp2Subscription(t, &restSubId2)
3265
3266 //Wait that subs is cleaned
3267 waitSubsCleanup(t, e2SubsId2, 10)
3268
3269 mainCtrl.VerifyCounterValues(t)
3270}
3271
3272//-----------------------------------------------------------------------------
3273// TestSubReqAndSubDelOkSameActionParallel
3274//
3275// stub stub stub
3276// +-------+ +-------+ +---------+ +---------+
3277// | xapp2 | | xapp1 | | submgr | | e2term |
3278// +-------+ +-------+ +---------+ +---------+
3279// | | | |
3280// | | | |
3281// | | | |
3282// | | SubReq1 | |
3283// | |------------->| |
3284// | | | |
3285// | | | SubReq1 |
3286// | | |------------->|
3287// | SubReq2 | |
3288// |--------------------------->| |
3289// | | | SubResp1 |
3290// | | |<-------------|
3291// | | SubResp1 | |
3292// | |<-------------| |
3293// | | | SubReq2 |
3294// | | |------------->|
3295// | | | |
3296// | | | SubResp2 |
3297// | | |<-------------|
3298// | SubResp2 | |
3299// |<---------------------------| |
3300// | | | |
3301// | | SubDelReq 1 | |
3302// | |------------->| |
3303// | | | |
3304// | | SubDelResp 1 | |
3305// | |<-------------| |
3306// | | | |
3307// | SubDelReq 2 | |
3308// |--------------------------->| |
3309// | | | |
3310// | | | SubDelReq 2 |
3311// | | |------------->|
3312// | | | |
3313// | | | SubDelReq 2 |
3314// | | |------------->|
3315// | | | |
3316// | SubDelResp 2 | |
3317// |<---------------------------| |
3318//
3319func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3320 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3321
3322 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3323 Counter{cSubReqFromXapp, 2},
3324 Counter{cSubReqToE2, 2},
3325 Counter{cSubRespFromE2, 2},
3326 Counter{cSubRespToXapp, 2},
3327 Counter{cSubDelReqFromXapp, 2},
3328 Counter{cSubDelReqToE2, 2},
3329 Counter{cSubDelRespFromE2, 2},
3330 Counter{cSubDelRespToXapp, 2},
3331 })
3332
3333 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3334 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3335 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3336
3337 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3338 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3339
3340 xappConn1.ExpectRESTNotification(t, restSubId1)
3341 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3342 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3343
3344 xappConn2.ExpectRESTNotification(t, restSubId2)
3345 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3346 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3347 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3348
3349 // Del1
3350 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3351 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3352 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3353 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3354
3355 // Del2
3356 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3357 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3358 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3359
3360 waitSubsCleanup(t, e2SubsId2, 10)
3361
3362 mainCtrl.VerifyCounterValues(t)
3363}
3364
3365//-----------------------------------------------------------------------------
3366// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3367//
3368// stub stub stub
3369// +-------+ +-------+ +---------+ +---------+
3370// | xapp2 | | xapp1 | | submgr | | e2term |
3371// +-------+ +-------+ +---------+ +---------+
3372// | | | |
3373// | | | |
3374// | | | |
3375// | | RESTSubReq1 | |
3376// | |---------------->| |
3377// | | | |
3378// | | RESTSubResp1 | |
3379// | |<----------------| |
3380// | | | SubReq1 |
3381// | | |------------->|
3382// | RESTSubReq2 | |
3383// |------------------------------>| |
3384// | | | |
3385// | RESTSubDelResp2 | |
3386// |<------------------------------| |
3387// | | | SubReq1 |
3388// | | |------------->|
3389// | | | |
3390// | | | |
3391// | | | SubDelReq |
3392// | | |------------->|
3393// | | | |
3394// | | | SubDelResp |
3395// | | |<-------------|
3396// | | RESTNotif1 | |
3397// | | unsuccess | |
3398// | |<----------------| |
3399// | RESTNotif2 | |
3400// | | unsuccess | |
3401// |<------------------------------| |
3402// | | | |
3403// | | RESTSubDelReq1 | |
3404// | |---------------->| |
3405// | | | |
3406// | | RESTSubDelResp1 | |
3407// | |<----------------| |
3408// | | | |
3409// | RESTSubDelReq2 | |
3410// |------------------------------>| |
3411// | | | |
3412// | RESTSubDelResp2 | |
3413// |<------------------------------| |
3414//
3415//-----------------------------------------------------------------------------
3416func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3417 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3418
3419 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3420 Counter{cSubReqFromXapp, 2},
3421 Counter{cSubReqToE2, 1},
3422 Counter{cSubRespToXapp, 2},
3423 Counter{cSubDelReqFromXapp, 2},
3424 Counter{cSubDelReqToE2, 1},
3425 Counter{cSubDelRespFromE2, 1},
3426 Counter{cSubDelRespToXapp, 2},
3427 })
3428
3429 const subReqCount int = 1
3430 const parameterSet = 1
3431 const actionDefinitionPresent bool = true
3432 const actionParamCount int = 1
3433
3434 // Req1
3435 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3436 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3437 crereq1, _ := e2termConn1.RecvSubsReq(t)
3438
3439 // Req2
3440 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3441 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3442 params2.SetMeid("RAN_NAME_1")
3443 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3444 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3445
3446 //Req1 (retransmitted)
3447 e2termConn1.RecvSubsReq(t)
3448
3449 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003450
3451 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003452 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3453
Markku Virtanenda34eec2021-05-20 08:22:04 +00003454 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3455 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3456 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3457 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003458
3459 // Del1
3460 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3461
3462 // Del2
3463 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3464
Markku Virtanenda34eec2021-05-20 08:22:04 +00003465 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3466
archaggeafbf95f2021-04-14 08:54:05 +03003467 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003468 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003469
3470 mainCtrl.VerifyCounterValues(t)
3471}
3472
3473//-----------------------------------------------------------------------------
3474// TestRESTSubReqAndSubDelNokSameActionParallel
3475//
3476// stub stub stub
3477// +-------+ +-------+ +---------+ +---------+
3478// | xapp2 | | xapp1 | | submgr | | e2term |
3479// +-------+ +-------+ +---------+ +---------+
3480// | | | |
3481// | | | |
3482// | | | |
3483// | | RESTSubReq1 | |
3484// | |---------------->| |
3485// | | | |
3486// | | RESTSubResp1 | |
3487// | |<----------------| |
3488// | | | SubReq1 |
3489// | | |------------->|
3490// | RESTSubReq2 | |
3491// |------------------------------>| |
3492// | | | |
3493// | RESTSubDelResp2 | |
3494// |<------------------------------| |
3495// | | | SubFail1 |
3496// | | |<-------------|
3497// | | | |
3498// | | RESTNotif1 | |
3499// | | unsuccess | |
3500// | |<----------------| |
3501// | RESTNotif2 | |
3502// | | unsuccess | |
3503// |<------------------------------| |
3504// | | | SubDelReq |
3505// | | |------------->|
3506// | | | SubDelResp |
3507// | | |<-------------|
3508// | | | |
3509// | | RESTSubDelReq1 | |
3510// | |---------------->| |
3511// | | | |
3512// | | RESTSubDelResp1 | |
3513// | |<----------------| |
3514// | | | |
3515// | RESTSubDelReq2 | |
3516// |------------------------------>| |
3517// | | | |
3518// | RESTSubDelResp2 | |
3519// |<------------------------------| |
3520//
3521//-----------------------------------------------------------------------------
3522func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3523 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3524
3525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3526 Counter{cSubReqFromXapp, 2},
3527 Counter{cSubReqToE2, 1},
3528 Counter{cSubFailFromE2, 1},
3529 Counter{cSubRespToXapp, 2},
3530 Counter{cSubDelReqFromXapp, 2},
3531 Counter{cSubDelReqToE2, 1},
3532 Counter{cSubDelRespFromE2, 1},
3533 Counter{cSubDelRespToXapp, 2},
3534 })
3535
3536 const subReqCount int = 1
3537 const parameterSet = 1
3538 const actionDefinitionPresent bool = true
3539 const actionParamCount int = 1
3540
3541 // Req1
3542 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3543 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3544 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3545
3546 // Req2
3547 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3548 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3549 params2.SetMeid("RAN_NAME_1")
3550 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3551 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3552
3553 // E2t: send SubsFail (first)
3554 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3555 fparams1.Set(crereq1)
3556 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3557
3558 // E2t: internal delete
3559 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3560 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3561 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3562
3563 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3564 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3565 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3566 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3567
3568 // Del1
3569 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3570
3571 // Del2
3572 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3573
3574 //Wait that subs is cleaned
3575 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3576 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3577
3578 mainCtrl.VerifyCounterValues(t)
3579}
3580
3581func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3582 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3583
3584 // Init counter check
3585 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3586 Counter{cSubReqFromXapp, 1},
3587 Counter{cSubReqToE2, 1},
3588 Counter{cSubRespFromE2, 1},
3589 Counter{cSubRespToXapp, 1},
3590 Counter{cSubDelReqFromXapp, 1},
3591 Counter{cSubDelReqToE2, 1},
3592 Counter{cSubDelRespFromE2, 1},
3593 Counter{cSubDelRespToXapp, 1},
3594 })
3595
3596 const subReqCount int = 1
3597 const parameterSet = 1
3598 const actionDefinitionPresent bool = true
3599 const actionParamCount int = 1
3600
3601 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3602 restSubId := xappConn1.SendRESTSubsReq(t, params)
3603 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3604
3605 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3606 xappConn1.ExpectRESTNotification(t, restSubId)
3607 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3608 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3609 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3610
3611 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3612 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3613 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3614
3615 // Wait that subs is cleaned
3616 waitSubsCleanup(t, e2SubsId, 10)
3617 mainCtrl.VerifyCounterValues(t)
3618}
3619
3620//-----------------------------------------------------------------------------
3621// TestRESTSubReqPolicyChangeAndSubDelOk
3622//
3623// stub stub
3624// +-------+ +---------+ +---------+
3625// | xapp | | submgr | | e2term |
3626// +-------+ +---------+ +---------+
3627// | | |
3628// | RESTSubReq | |
3629// |---------------->| |
3630// | | |
3631// | RESTSubResp | |
3632// |<----------------| |
3633// | | SubReq |
3634// | |------------->|
3635// | | |
3636// | | SubResp |
3637// | |<-------------|
3638// | | |
3639// | RESTNotif | |
3640// |<----------------| |
3641// | | |
3642// | RESTSubReq | |
3643// |---------------->| |
3644// | | |
3645// | RESTSubResp | |
3646// |<----------------| |
3647// | | SubReq |
3648// | |------------->|
3649// | | |
3650// | | SubResp |
3651// | |<-------------|
3652// | | |
3653// | RESTNotif | |
3654// |<----------------| |
3655// | | |
3656// | RESTSubDelReq | |
3657// |---------------->| |
3658// | | |
3659// | | SubDelReq |
3660// | |------------->|
3661// | | |
3662// | | SubDelResp |
3663// | |<-------------|
3664// | | |
3665// | RESTSubDelResp | |
3666// |<----------------| |
3667//
3668//-----------------------------------------------------------------------------
3669func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3670 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3671
3672 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3673 Counter{cSubReqFromXapp, 2},
3674 Counter{cSubReqToE2, 2},
3675 Counter{cSubRespFromE2, 2},
3676 Counter{cSubRespToXapp, 2},
3677 Counter{cSubDelReqFromXapp, 1},
3678 Counter{cSubDelReqToE2, 1},
3679 Counter{cSubDelRespFromE2, 1},
3680 Counter{cSubDelRespToXapp, 1},
3681 })
3682
3683 const subReqCount int = 1
3684 const parameterSet = 1
3685 const actionDefinitionPresent bool = true
3686 const policyParamCount int = 1
3687
3688 // Req
3689 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3690 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3691
3692 // Policy change
3693 instanceId := int64(e2SubsId)
3694 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
3695 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3696 params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
3697 params.SetTimeToWait("w200ms")
3698 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3699
3700 // Del
3701 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3702
3703 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3704 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3705
3706 // Wait that subs is cleaned
3707 waitSubsCleanup(t, e2SubsId, 10)
3708 mainCtrl.VerifyCounterValues(t)
3709}
3710
3711//-----------------------------------------------------------------------------
3712// TestRESTSubReqAndSubDelOkTwoE2termParallel
3713//
3714// stub stub stub
3715// +-------+ +---------+ +---------+ +---------+
3716// | xapp | | submgr | | e2term1 | | e2term2 |
3717// +-------+ +---------+ +---------+ +---------+
3718// | | | |
3719// | | | |
3720// | | | |
3721// | RESTSubReq1 | | |
3722// |---------------->| | |
3723// | | | |
3724// | RESTSubResp1 | | |
3725// |<----------------| | |
3726// | | SubReq1 | |
3727// | |------------->| |
3728// | | | |
3729// | RESTSubReq2 | | |
3730// |---------------->| | |
3731// | | | |
3732// | RESTSubResp2 | | |
3733// |<----------------| | |
3734// | | SubReq2 | |
3735// | |---------------------------->|
3736// | | | |
3737// | | SubResp1 | |
3738// | |<-------------| |
3739// | RESTNotif1 | | |
3740// |<----------------| | |
3741// | | SubResp2 | |
3742// | |<----------------------------|
3743// | RESTNotif2 | | |
3744// |<----------------| | |
3745// | | | |
3746// | [SUBS 1 DELETE] | |
3747// | | | |
3748// | [SUBS 2 DELETE] | |
3749// | | | |
3750//
3751//-----------------------------------------------------------------------------
3752func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3753 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3754
3755 // Init counter check
3756 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3757 Counter{cSubReqFromXapp, 2},
3758 Counter{cSubReqToE2, 2},
3759 Counter{cSubRespFromE2, 2},
3760 Counter{cSubRespToXapp, 2},
3761 Counter{cSubDelReqFromXapp, 2},
3762 Counter{cSubDelReqToE2, 2},
3763 Counter{cSubDelRespFromE2, 2},
3764 Counter{cSubDelRespToXapp, 2},
3765 })
3766
3767 const subReqCount int = 1
3768 const parameterSet = 1
3769 const actionDefinitionPresent bool = true
3770 const actionParamCount int = 1
3771
3772 // Req1
3773 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3774 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3775 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3776
3777 // Req2
3778 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3779 params.SetMeid("RAN_NAME_11")
3780 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3781 // would not work as notification would not be received
3782 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3783 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3784
3785 // Resp1
3786 xappConn1.ExpectRESTNotification(t, restSubId1)
3787 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3788 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3789 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3790
3791 // Resp2
3792 xappConn2.ExpectRESTNotification(t, restSubId2)
3793 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3794 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3795 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3796
3797 // Delete1
3798 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3799 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3800 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3801
3802 // Wait that subs is cleaned
3803 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3804
3805 // Delete2
3806 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3807 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3808 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3809
3810 // Wait that subs is cleaned
3811 waitSubsCleanup(t, e2SubsId2, 10)
3812
3813 mainCtrl.VerifyCounterValues(t)
3814}
3815
3816//-----------------------------------------------------------------------------
3817// TestRESTSubReqAsn1EncodeFail
3818//
3819// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3820// stub stub
3821// +-------+ +---------+ +---------+
3822// | xapp | | submgr | | e2term |
3823// +-------+ +---------+ +---------+
3824// | | |
3825// | RESTSubReq | |
3826// |---------------->| |
3827// | | |
3828// | RESTSubResp | |
3829// |<----------------| |
3830// | RESTSubDelReq | |
3831// |---------------->| |
3832// | RESTSubDelResp | |
3833// | unsuccess | |
3834// |<----------------| |
3835// | | |
3836//
3837//-----------------------------------------------------------------------------
3838func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
3839 CaseBegin("TestRESTSubReqAsn1EncodeFail")
3840
3841 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
3842
3843}
3844
3845//-----------------------------------------------------------------------------
3846// TestRESTSubReqInsertAndSubDelOk
3847//
3848// stub stub
3849// +-------+ +---------+ +---------+
3850// | xapp | | submgr | | e2term |
3851// +-------+ +---------+ +---------+
3852// | | |
3853// | RestSubReq | |
3854// |---------------->| |
3855// | | |
3856// | RESTSubResp | |
3857// |<----------------| |
3858// | | |
3859// | | SubReq |
3860// | |------------->|
3861// | | |
3862// | | SubResp |
3863// | |<-------------|
3864// | RESTNotif | |
3865// |<----------------| |
3866// | ... | ... |
3867// | | |
3868// | RESTSubDelReq | |
3869// |---------------->| |
3870// | | |
3871// | | SubDelReq |
3872// | |------------->|
3873// | | |
3874// | | SubDelResp |
3875// | |<-------------|
3876// | | |
3877// | RESTSubDelResp| |
3878// |<----------------| |
3879//
3880//-----------------------------------------------------------------------------
3881func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
3882 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
3883
3884 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3885 Counter{cSubReqFromXapp, 1},
3886 Counter{cSubReqToE2, 1},
3887 Counter{cSubRespFromE2, 1},
3888 Counter{cSubRespToXapp, 1},
3889 Counter{cSubDelReqFromXapp, 1},
3890 Counter{cSubDelReqToE2, 1},
3891 Counter{cSubDelRespFromE2, 1},
3892 Counter{cSubDelRespToXapp, 1},
3893 })
3894
3895 const subReqCount int = 1
3896 const parameterSet int = 1
3897 const actionDefinitionPresent bool = true
3898 const actionParamCount int = 1
3899
3900 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3901 params.SetSubActionTypes("insert")
3902
3903 // Req
3904 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3905
3906 // Del
3907 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3908
3909 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3910 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3911
3912 // Wait that subs is cleaned
3913 waitSubsCleanup(t, e2SubsId, 10)
3914 mainCtrl.VerifyCounterValues(t)
3915}
3916
3917//-----------------------------------------------------------------------------
3918// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
3919//
3920// stub stub
3921// +-------+ +---------+ +---------+
3922// | xapp | | submgr | | e2term |
3923// +-------+ +---------+ +---------+
3924// | | |
3925// | RESTSubReq | |
3926// |------------->| |
3927// | | |
3928// | | SubReq |
3929// | |------------->|
3930// | | |
3931// | | SubResp |
3932// | <----|
3933// | |
3934// | Submgr restart |
3935// | |
3936// | | |
3937// | | SubDelReq |
3938// | |------------->|
3939// | | |
3940// | | SubDelResp |
3941// | |<-------------|
3942// | | |
3943//
3944//-----------------------------------------------------------------------------
3945func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
3946 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
3947
3948 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3949 Counter{cSubReqFromXapp, 1},
3950 Counter{cSubReqToE2, 1},
3951 Counter{cSubDelReqFromXapp, 1},
3952 Counter{cSubDelReqToE2, 1},
3953 Counter{cSubDelRespFromE2, 1},
3954 })
3955
3956 const subReqCount int = 1
3957 const parameterSet = 1
3958 const actionDefinitionPresent bool = true
3959 const actionParamCount int = 1
3960
3961 // Remove possible existing subscription
3962 mainCtrl.removeExistingSubscriptions(t)
3963
3964 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3965
3966 //Req
3967 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
3968 restSubId := xappConn1.SendRESTSubsReq(t, params)
3969 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3970
3971 e2termConn1.RecvSubsReq(t)
3972
3973 mainCtrl.SetResetTestFlag(t, false)
3974
3975 mainCtrl.SimulateRestart(t)
3976 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
3977
3978 //Del
3979 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3980 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3981
3982 xappConn1.TestMsgChanEmpty(t)
3983 xappConn2.TestMsgChanEmpty(t)
3984 e2termConn1.TestMsgChanEmpty(t)
3985 mainCtrl.wait_registry_empty(t, 10)
3986
3987 mainCtrl.VerifyCounterValues(t)
3988}
3989
3990//-----------------------------------------------------------------------------
3991// TestRESTSubReqAndSubDelOkWithRestartInMiddle
3992//
3993// stub stub
3994// +-------+ +---------+ +---------+
3995// | xapp | | submgr | | e2term |
3996// +-------+ +---------+ +---------+
3997// | | |
3998// | RESTSubReq | |
3999// |---------------->| |
4000// | | |
4001// | RESTSubResp | |
4002// |<----------------| |
4003// | | SubReq |
4004// | |------------->|
4005// | | |
4006// | | SubResp |
4007// | |<-------------|
4008// | | |
4009// | RESTNotif | |
4010// |<----------------| |
4011// | | |
4012// | |
4013// | Submgr restart |
4014// | | |
4015// | RESTSubDelReq | |
4016// |---------------->| |
4017// | | |
4018// | | SubDelReq |
4019// | |------------->|
4020// | | |
4021// | | SubDelResp |
4022// | |<-------------|
4023// | | |
4024// | RESTSubDelResp | |
4025// |<----------------| |
4026//
4027//-----------------------------------------------------------------------------
4028func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4029 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4030
4031 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4032 Counter{cSubReqFromXapp, 1},
4033 Counter{cSubReqToE2, 1},
4034 Counter{cSubRespFromE2, 1},
4035 Counter{cSubRespToXapp, 1},
4036 Counter{cSubDelReqFromXapp, 1},
4037 Counter{cSubDelReqToE2, 1},
4038 Counter{cSubDelRespToXapp, 1},
4039 })
4040
4041 // Remove possible existing subscription
4042 mainCtrl.removeExistingSubscriptions(t)
4043
4044 var params *teststube2ap.RESTSubsReqParams = nil
4045
4046 // Create subscription
4047 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4048 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4049
4050 // Check subscription
4051 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4052
4053 // When SDL support for the REST Interface is added
4054 // the submgr restart statement below should be removed
4055 // from the comment.
4056
4057 // mainCtrl.SimulateRestart(t)
4058 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4059
4060 // Check subscription
4061 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4062
4063 // Delete subscription
4064 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4065
4066 //Wait that subs is cleaned
4067 waitSubsCleanup(t, e2SubsId, 10)
4068
4069 mainCtrl.VerifyCounterValues(t)
4070}
4071
4072//-----------------------------------------------------------------------------
4073// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4074//
4075// stub stub
4076// +-------+ +-------+ +---------+ +---------+
4077// | xapp2 | | xapp1 | | submgr | | e2term |
4078// +-------+ +-------+ +---------+ +---------+
4079// | | | |
4080// | | RESTSubReq1 | |
4081// | |---------------->| |
4082// | | | |
4083// | | RESTSubResp1 | |
4084// | |<----------------| |
4085// | | | |
4086// | | | SubReq1 |
4087// | | |------------->|
4088// | | | SubResp1 |
4089// | | |<-------------|
4090// | | RESTNotif1 | |
4091// | |<----------------| |
4092// | | | |
4093// | RESTSubReq2 | |
4094// |------------------------------>| |
4095// | | | |
4096// | RESTSubResp2 | |
4097// |<------------------------------| |
4098// | | | |
4099// | | RESTNotif2 | |
4100// |<------------------------------| |
4101// | | | |
4102// | | Submgr restart |
4103// | | | |
4104// | | RESTSubDelReq1 | |
4105// | |---------------->| |
4106// | | | |
4107// | | RESTSubDelResp1 | |
4108// | |<----------------| |
4109// | | | |
4110// | | Submgr restart |
4111// | | | |
4112// | RESTSubDelReq2 | |
4113// |------------------------------>| |
4114// | | | |
4115// | RESTSubDelResp2 | |
4116// |<------------------------------| |
4117// | | | |
4118// | | | SubDelReq2 |
4119// | | |------------->|
4120// | | | |
4121// | | | SubDelResp2 |
4122// | | |<-------------|
4123// | | | |
4124//
4125//-----------------------------------------------------------------------------
4126func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4127 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4128
4129 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4130 Counter{cSubReqFromXapp, 2},
4131 Counter{cSubReqToE2, 1},
4132 Counter{cSubRespFromE2, 1},
4133 Counter{cSubRespToXapp, 2},
4134 Counter{cMergedSubscriptions, 1},
4135 Counter{cUnmergedSubscriptions, 1},
4136 Counter{cSubDelReqFromXapp, 2},
4137 Counter{cSubDelReqToE2, 1},
4138 Counter{cSubDelRespFromE2, 1},
4139 Counter{cSubDelRespToXapp, 2},
4140 })
4141
4142 // Remove possible existing subscription
4143 mainCtrl.removeExistingSubscriptions(t)
4144
4145 var params *teststube2ap.RESTSubsReqParams = nil
4146
4147 // Create subscription 1
4148 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4149 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4150
4151 // Create subscription 2 with same action
4152 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4153 params.SetMeid("RAN_NAME_1")
4154 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4155 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4156 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4157 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4158 e2SubsId2 := <-xappConn2.RESTNotification
4159 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4160
4161 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4162
4163 // When SDL support for the REST Interface is added
4164 // the submgr restart statement below should be removed
4165 // from the comment.
4166
4167 // mainCtrl.SimulateRestart(t)
4168 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4169
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004170 // Delete subscription 1, and wait until it has removed the first endpoint
4171 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004172 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004173 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004174
4175 // When SDL support for the REST Interface is added
4176 // the submgr restart statement below should be removed
4177 // from the comment.
4178
4179 // mainCtrl.SimulateRestart(t)
4180 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004181 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4182
4183 // Delete subscription 2
4184 deleteXapp2Subscription(t, &restSubId2)
4185
4186 //Wait that subs is cleaned
4187 waitSubsCleanup(t, e2SubsId2, 10)
4188
4189 mainCtrl.VerifyCounterValues(t)
4190}
4191
4192//-----------------------------------------------------------------------------
4193// TestRESTReportSubReqAndSubDelOk
4194//
4195// stub stub
4196// +-------+ +---------+ +---------+
4197// | xapp | | submgr | | e2term |
4198// +-------+ +---------+ +---------+
4199// | | |
4200// | RestSubReq | |
4201// |---------------->| |
4202// | | |
4203// | RESTSubResp | |
4204// |<----------------| |
4205// | | |
4206// | | SubReq |
4207// | |------------->|
4208// | | |
4209// | | SubResp |
4210// | |<-------------|
4211// | RESTNotif | |
4212// |<----------------| |
4213// | | SubReq |
4214// | |------------->|
4215// | | |
4216// | | SubResp |
4217// | |<-------------|
4218// | RESTNotif | |
4219// |<----------------| |
4220// | ... | ... |
4221// | | |
4222// | | |
4223// | RESTSubDelReq | |
4224// |---------------->| |
4225// | | |
4226// | | SubDelReq |
4227// | |------------->|
4228// | | |
4229// | | SubDelResp |
4230// | |<-------------|
4231// | | |
4232// | RESTSubDelResp| |
4233// |<----------------| |
4234//
4235//-----------------------------------------------------------------------------
4236func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4237 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4238 subReqCount := 1
4239 parameterSet := 1 // E2SM-gNB-X2
4240 actionDefinitionPresent := true
4241 actionParamCount := 1
4242 testIndex := 1
4243 RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
4244}
4245
4246func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
4247 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
4248
4249 // Req
4250 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4251 restSubId := xappConn1.SendRESTSubsReq(t, params)
4252
4253 var e2SubsId []uint32
4254 for i := 0; i < subReqCount; i++ {
4255 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4256 xappConn1.ExpectRESTNotification(t, restSubId)
4257
4258 e2termConn1.SendSubsResp(t, crereq, cremsg)
4259 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4260 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4261 e2SubsId = append(e2SubsId, instanceId)
4262 resp, _ := xapp.Subscription.QuerySubscriptions()
4263 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4264 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4265 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4266
4267 }
4268
4269 // Del
4270 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4271
4272 for i := 0; i < subReqCount; i++ {
4273 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4275 }
4276
4277 // Wait that subs is cleaned
4278 for i := 0; i < subReqCount; i++ {
4279 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4280 }
4281
4282 xappConn1.TestMsgChanEmpty(t)
4283 e2termConn1.TestMsgChanEmpty(t)
4284 mainCtrl.wait_registry_empty(t, 10)
4285}
4286
4287/*
4288func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4289 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4290
4291 subReqCount := 2
4292 actionDefinitionPresent := true
4293 policyParamCount := 1
4294 testIndex := 1
4295 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4296
4297 subReqCount = 19
4298 actionDefinitionPresent = false
4299 policyParamCount = 0
4300 testIndex = 2
4301 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4302}
4303*/
4304func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
4305 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
4306
4307 // Req
4308 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4309 restSubId := xappConn1.SendRESTSubsReq(t, params)
4310 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
4311 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4312
4313 var e2SubsId []uint32
4314 for i := 0; i < subReqCount; i++ {
4315 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4316 xappConn1.ExpectRESTNotification(t, restSubId)
4317 e2termConn1.SendSubsResp(t, crereq, cremsg)
4318 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4319 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4320 e2SubsId = append(e2SubsId, instanceId)
4321 }
4322
4323 // Del
4324 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4325
4326 for i := 0; i < subReqCount; i++ {
4327 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4328 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4329 }
4330
4331 // Wait that subs is cleaned
4332 for i := 0; i < subReqCount; i++ {
4333 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4334 }
4335 xappConn1.TestMsgChanEmpty(t)
4336 e2termConn1.TestMsgChanEmpty(t)
4337 mainCtrl.wait_registry_empty(t, 10)
4338}
4339
archaggeafbf95f2021-04-14 08:54:05 +03004340func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4341
4342 subReqCount := 2
4343
4344 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4345 Counter{cSubReqFromXapp, 1},
4346 Counter{cSubReqToE2, 2},
4347 Counter{cSubRespFromE2, 2},
4348 Counter{cSubRespToXapp, 2},
4349 Counter{cSubDelReqFromXapp, 1},
4350 Counter{cSubDelReqToE2, 2},
4351 Counter{cSubDelRespFromE2, 2},
4352 Counter{cSubDelRespToXapp, 1},
4353 })
4354
4355 // Req
4356 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4357 restSubId := xappConn1.SendRESTSubsReq(t, params)
4358 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4359
4360 assert.Equal(t, len(e2SubsIds), 2)
4361
4362 // Del
4363 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4364 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4365
4366 xappConn1.TestMsgChanEmpty(t)
4367 e2termConn1.TestMsgChanEmpty(t)
4368 mainCtrl.wait_registry_empty(t, 10)
4369
4370 mainCtrl.VerifyCounterValues(t)
4371}
archaggeafbf95f2021-04-14 08:54:05 +03004372func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4373
4374 subReqCount := 19
4375
4376 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4377 Counter{cSubReqFromXapp, 1},
4378 Counter{cSubReqToE2, 19},
4379 Counter{cSubRespFromE2, 19},
4380 Counter{cSubRespToXapp, 19},
4381 Counter{cSubDelReqFromXapp, 1},
4382 Counter{cSubDelReqToE2, 19},
4383 Counter{cSubDelRespFromE2, 19},
4384 Counter{cSubDelRespToXapp, 1},
4385 })
4386
4387 // Req
4388 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4389 restSubId := xappConn1.SendRESTSubsReq(t, params)
4390 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4391
4392 assert.Equal(t, len(e2SubsIds), 19)
4393
4394 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4395 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4396
4397 xappConn1.TestMsgChanEmpty(t)
4398 e2termConn1.TestMsgChanEmpty(t)
4399 mainCtrl.wait_registry_empty(t, 10)
4400
4401 mainCtrl.VerifyCounterValues(t)
4402}
archaggeafbf95f2021-04-14 08:54:05 +03004403func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4404
4405 subReqCount := 2
4406 parameterSet := 1
4407 actionDefinitionPresent := true
4408 actionParamCount := 1
4409
4410 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4411 Counter{cSubReqFromXapp, 1},
4412 Counter{cSubReqToE2, uint64(subReqCount)},
4413 Counter{cSubRespFromE2, uint64(subReqCount)},
4414 Counter{cSubRespToXapp, uint64(subReqCount)},
4415 Counter{cSubDelReqFromXapp, 1},
4416 Counter{cSubDelReqToE2, uint64(subReqCount)},
4417 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4418 Counter{cSubDelRespToXapp, 1},
4419 })
4420
4421 // Req
4422 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4423 restSubId := xappConn1.SendRESTSubsReq(t, params)
4424 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4425
4426 assert.Equal(t, len(e2SubsIds), subReqCount)
4427
4428 // Del
4429 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4430 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4431
4432 xappConn1.TestMsgChanEmpty(t)
4433 e2termConn1.TestMsgChanEmpty(t)
4434 mainCtrl.wait_registry_empty(t, 10)
4435
4436 mainCtrl.VerifyCounterValues(t)
4437}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004438
archaggeafbf95f2021-04-14 08:54:05 +03004439func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4440
4441 subReqCount := 2
4442 parameterSet := 1
4443 actionDefinitionPresent := false
4444 actionParamCount := 0
4445
4446 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4447 Counter{cSubReqFromXapp, 1},
4448 Counter{cSubReqToE2, uint64(subReqCount)},
4449 Counter{cSubRespFromE2, uint64(subReqCount)},
4450 Counter{cSubRespToXapp, uint64(subReqCount)},
4451 Counter{cSubDelReqFromXapp, 1},
4452 Counter{cSubDelReqToE2, uint64(subReqCount)},
4453 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4454 Counter{cSubDelRespToXapp, 1},
4455 })
4456
4457 // Req
4458 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4459 restSubId := xappConn1.SendRESTSubsReq(t, params)
4460 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4461
4462 assert.Equal(t, len(e2SubsIds), subReqCount)
4463
4464 // Del
4465 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4466 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4467
4468 xappConn1.TestMsgChanEmpty(t)
4469 e2termConn1.TestMsgChanEmpty(t)
4470 mainCtrl.wait_registry_empty(t, 10)
4471
4472 mainCtrl.VerifyCounterValues(t)
4473}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004474
archaggeafbf95f2021-04-14 08:54:05 +03004475func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4476
4477 subReqCount := 19
4478 parameterSet := 1
4479 actionDefinitionPresent := false
4480 actionParamCount := 0
4481
4482 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4483 Counter{cSubReqFromXapp, 1},
4484 Counter{cSubReqToE2, uint64(subReqCount)},
4485 Counter{cSubRespFromE2, uint64(subReqCount)},
4486 Counter{cSubRespToXapp, uint64(subReqCount)},
4487 Counter{cSubDelReqFromXapp, 1},
4488 Counter{cSubDelReqToE2, uint64(subReqCount)},
4489 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4490 Counter{cSubDelRespToXapp, 1},
4491 })
4492
4493 // Req
4494 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4495 restSubId := xappConn1.SendRESTSubsReq(t, params)
4496 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4497
4498 assert.Equal(t, len(e2SubsIds), subReqCount)
4499
4500 // Del
4501 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4502 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4503
4504 xappConn1.TestMsgChanEmpty(t)
4505 e2termConn1.TestMsgChanEmpty(t)
4506 mainCtrl.wait_registry_empty(t, 10)
4507
4508 mainCtrl.VerifyCounterValues(t)
4509}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004510
4511func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4512 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4513
4514 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4515 Counter{cSubReqFromXapp, 2},
4516 Counter{cSubReqToE2, 2},
4517 Counter{cSubRespFromE2, 2},
4518 Counter{cSubRespToXapp, 2},
4519 Counter{cSubDelReqFromXapp, 2},
4520 Counter{cSubDelReqToE2, 2},
4521 Counter{cSubDelRespFromE2, 2},
4522 Counter{cSubDelRespToXapp, 2},
4523 })
4524
4525 // Req1
4526 var params *teststube2ap.RESTSubsReqParams = nil
4527
4528 //Subs Create
4529 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4530 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4531
4532 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4533
4534 // Req2
4535 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4536 params.SetMeid("RAN_NAME_1")
4537 eventTriggerDefinition := "1234"
4538 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4539
4540 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4541 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4542 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4543 xappConn2.ExpectRESTNotification(t, restSubId2)
4544 e2termConn1.SendSubsResp(t, crereq, cremsg)
4545 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4546
4547 deleteXapp1Subscription(t, &restSubId1)
4548 deleteXapp2Subscription(t, &restSubId2)
4549
4550 waitSubsCleanup(t, e2SubsId1, 10)
4551 waitSubsCleanup(t, e2SubsId2, 10)
4552
4553 mainCtrl.VerifyCounterValues(t)
4554
4555}
4556
4557func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4558 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4559
4560 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4561 Counter{cSubReqFromXapp, 2},
4562 Counter{cSubReqToE2, 2},
4563 Counter{cSubRespFromE2, 2},
4564 Counter{cSubRespToXapp, 2},
4565 Counter{cSubDelReqFromXapp, 2},
4566 Counter{cSubDelReqToE2, 2},
4567 Counter{cSubDelRespFromE2, 2},
4568 Counter{cSubDelRespToXapp, 2},
4569 })
4570
4571 // Req1
4572 var params *teststube2ap.RESTSubsReqParams = nil
4573
4574 //Subs Create
4575 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4576 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4577
4578 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4579
4580 // Req2
4581 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4582 params.SetMeid("RAN_NAME_1")
4583
4584 actionId := int64(1)
4585 actionType := "report"
4586 actionDefinition := "56781"
4587 subsequestActionType := "continue"
4588 timeToWait := "w10ms"
4589 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4590
4591 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4592 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4593 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4594 xappConn2.ExpectRESTNotification(t, restSubId2)
4595 e2termConn1.SendSubsResp(t, crereq, cremsg)
4596 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4597
4598 deleteXapp1Subscription(t, &restSubId1)
4599 deleteXapp2Subscription(t, &restSubId2)
4600
4601 waitSubsCleanup(t, e2SubsId1, 10)
4602 waitSubsCleanup(t, e2SubsId2, 10)
4603
4604 mainCtrl.VerifyCounterValues(t)
4605
4606}
4607
4608func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4609 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4610
4611 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4612 Counter{cSubReqFromXapp, 2},
4613 Counter{cSubReqToE2, 2},
4614 Counter{cSubRespFromE2, 2},
4615 Counter{cSubRespToXapp, 2},
4616 Counter{cSubDelReqFromXapp, 2},
4617 Counter{cSubDelReqToE2, 2},
4618 Counter{cSubDelRespFromE2, 2},
4619 Counter{cSubDelRespToXapp, 2},
4620 })
4621
4622 // Req1
4623 var params *teststube2ap.RESTSubsReqParams = nil
4624
4625 //Subs Create
4626 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4627 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4628
4629 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4630
4631 // Req2
4632 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4633 params.SetMeid("RAN_NAME_1")
4634 params.SetSubActionIDs(int64(2))
4635
4636 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4637 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4638 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4639 xappConn2.ExpectRESTNotification(t, restSubId2)
4640 e2termConn1.SendSubsResp(t, crereq, cremsg)
4641 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4642
4643 deleteXapp1Subscription(t, &restSubId1)
4644 deleteXapp2Subscription(t, &restSubId2)
4645
4646 waitSubsCleanup(t, e2SubsId1, 10)
4647 waitSubsCleanup(t, e2SubsId2, 10)
4648
4649 mainCtrl.VerifyCounterValues(t)
4650
4651}
4652
4653func TestRESTSubReqDiffActionType(t *testing.T) {
4654 CaseBegin("TestRESTSubReqDiffActionType")
4655
4656 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4657 Counter{cSubReqFromXapp, 2},
4658 Counter{cSubReqToE2, 2},
4659 Counter{cSubRespFromE2, 2},
4660 Counter{cSubRespToXapp, 2},
4661 Counter{cSubDelReqFromXapp, 2},
4662 Counter{cSubDelReqToE2, 2},
4663 Counter{cSubDelRespFromE2, 2},
4664 Counter{cSubDelRespToXapp, 2},
4665 })
4666
4667 // Req1
4668 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4669
4670 //Subs Create
4671 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4672 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4673
4674 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4675
4676 // Req2
4677 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4678 params.SetMeid("RAN_NAME_1")
4679
4680 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4681 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4682 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4683 xappConn2.ExpectRESTNotification(t, restSubId2)
4684 e2termConn1.SendSubsResp(t, crereq, cremsg)
4685 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4686
4687 deleteXapp1Subscription(t, &restSubId1)
4688 deleteXapp2Subscription(t, &restSubId2)
4689
4690 waitSubsCleanup(t, e2SubsId1, 10)
4691 waitSubsCleanup(t, e2SubsId2, 10)
4692
4693 mainCtrl.VerifyCounterValues(t)
4694
4695}
4696
4697func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4698 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4699
4700 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4701 Counter{cSubReqFromXapp, 2},
4702 Counter{cSubReqToE2, 2},
4703 Counter{cSubRespFromE2, 2},
4704 Counter{cSubRespToXapp, 2},
4705 Counter{cSubDelReqFromXapp, 2},
4706 Counter{cSubDelReqToE2, 2},
4707 Counter{cSubDelRespFromE2, 2},
4708 Counter{cSubDelRespToXapp, 2},
4709 })
4710
4711 // Req1
4712 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4713
4714 //Subs Create
4715 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4716 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4717
4718 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4719
4720 // Req2
4721 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4722 params.SetMeid("RAN_NAME_1")
4723
4724 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4725 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4726 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4727 xappConn2.ExpectRESTNotification(t, restSubId2)
4728 e2termConn1.SendSubsResp(t, crereq, cremsg)
4729 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4730
4731 deleteXapp1Subscription(t, &restSubId1)
4732 deleteXapp2Subscription(t, &restSubId2)
4733
4734 waitSubsCleanup(t, e2SubsId1, 10)
4735 waitSubsCleanup(t, e2SubsId2, 10)
4736
4737 mainCtrl.VerifyCounterValues(t)
4738
4739}
4740
4741func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4742 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4743
4744 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4745 Counter{cSubReqFromXapp, 2},
4746 Counter{cSubReqToE2, 2},
4747 Counter{cSubRespFromE2, 2},
4748 Counter{cSubRespToXapp, 2},
4749 Counter{cSubDelReqFromXapp, 2},
4750 Counter{cSubDelReqToE2, 2},
4751 Counter{cSubDelRespFromE2, 2},
4752 Counter{cSubDelRespToXapp, 2},
4753 })
4754
4755 // Req1
4756 var params *teststube2ap.RESTSubsReqParams = nil
4757
4758 //Subs Create
4759 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4760 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4761
4762 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4763
4764 // Req2
4765 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4766 params.SetMeid("RAN_NAME_1")
4767 actionDefinition := "5678"
4768 params.SetSubActionDefinition(actionDefinition)
4769
4770 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4771 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4772 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4773 xappConn2.ExpectRESTNotification(t, restSubId2)
4774 e2termConn1.SendSubsResp(t, crereq, cremsg)
4775 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4776
4777 deleteXapp1Subscription(t, &restSubId1)
4778 deleteXapp2Subscription(t, &restSubId2)
4779
4780 waitSubsCleanup(t, e2SubsId1, 10)
4781 waitSubsCleanup(t, e2SubsId2, 10)
4782
4783 mainCtrl.VerifyCounterValues(t)
4784
4785}
4786
4787func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
4788 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
4789
4790 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4791 Counter{cSubReqFromXapp, 2},
4792 Counter{cSubReqToE2, 2},
4793 Counter{cSubRespFromE2, 2},
4794 Counter{cSubRespToXapp, 2},
4795 Counter{cSubDelReqFromXapp, 2},
4796 Counter{cSubDelReqToE2, 2},
4797 Counter{cSubDelRespFromE2, 2},
4798 Counter{cSubDelRespToXapp, 2},
4799 })
4800
4801 // Req1
4802 var params *teststube2ap.RESTSubsReqParams = nil
4803
4804 //Subs Create
4805 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4806 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4807
4808 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4809
4810 // Req2
4811 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4812 params.SetMeid("RAN_NAME_1")
4813 actionDefinition := "56782"
4814 params.SetSubActionDefinition(actionDefinition)
4815
4816 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4817 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4818 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4819 xappConn2.ExpectRESTNotification(t, restSubId2)
4820 e2termConn1.SendSubsResp(t, crereq, cremsg)
4821 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4822
4823 deleteXapp1Subscription(t, &restSubId1)
4824 deleteXapp2Subscription(t, &restSubId2)
4825
4826 waitSubsCleanup(t, e2SubsId1, 10)
4827 waitSubsCleanup(t, e2SubsId2, 10)
4828
4829 mainCtrl.VerifyCounterValues(t)
4830
4831}
4832
4833func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
4834 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
4835
4836 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4837 Counter{cSubReqFromXapp, 2},
4838 Counter{cSubReqToE2, 2},
4839 Counter{cSubRespFromE2, 2},
4840 Counter{cSubRespToXapp, 2},
4841 Counter{cSubDelReqFromXapp, 2},
4842 Counter{cSubDelReqToE2, 2},
4843 Counter{cSubDelRespFromE2, 2},
4844 Counter{cSubDelRespToXapp, 2},
4845 })
4846
4847 // Req1
4848 var params *teststube2ap.RESTSubsReqParams = nil
4849
4850 //Subs Create
4851 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4852 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4853
4854 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4855
4856 // Req2
4857 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4858 params.SetMeid("RAN_NAME_1")
4859 params.SetTimeToWait("w200ms")
4860 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4861 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4862 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4863 xappConn2.ExpectRESTNotification(t, restSubId2)
4864 e2termConn1.SendSubsResp(t, crereq, cremsg)
4865 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4866
4867 deleteXapp1Subscription(t, &restSubId1)
4868 deleteXapp2Subscription(t, &restSubId2)
4869
4870 waitSubsCleanup(t, e2SubsId1, 10)
4871 waitSubsCleanup(t, e2SubsId2, 10)
4872
4873 mainCtrl.VerifyCounterValues(t)
4874
4875}
4876
archaggeafbf95f2021-04-14 08:54:05 +03004877////////////////////////////////////////////////////////////////////////////////////
4878// Services for UT cases
4879////////////////////////////////////////////////////////////////////////////////////
4880const subReqCount int = 1
4881const parameterSet = 1
4882const actionDefinitionPresent bool = true
4883const actionParamCount int = 1
4884const policyParamCount int = 1
4885const host string = "localhost"
4886
4887func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
4888 if params == nil {
4889 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4890 }
4891 restSubId := fromXappConn.SendRESTSubsReq(t, params)
4892 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
4893
4894 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
4895 fromXappConn.ExpectRESTNotification(t, restSubId)
4896 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
4897 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
4898 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4899
4900 return restSubId, e2SubsId
4901}
4902
4903func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
4904
4905 params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4906 if meid != "" {
4907 params.SetMeid(meid)
4908 }
4909 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4910 restSubId := xappConn2.SendRESTSubsReq(t, params)
4911 xappConn2.ExpectRESTNotification(t, restSubId)
4912 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
4913 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
4914 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4915
4916 return restSubId, e2SubsId
4917}
4918
4919func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
4920 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4921 restSubId := xappConn1.SendRESTSubsReq(t, params)
4922 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
4923
4924 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4925 xappConn1.ExpectRESTNotification(t, restSubId)
4926 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4927 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4928 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4929
4930 return restSubId, e2SubsId
4931}
4932
4933func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
4934 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4935 restSubId := xappConn1.SendRESTSubsReq(t, params)
4936
4937 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4938 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4939 fparams1.Set(crereq1)
4940 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4941
4942 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4943 xappConn1.ExpectRESTNotification(t, restSubId)
4944 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4945 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4946 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
4947
4948 return restSubId, e2SubsId
4949}
4950
4951func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
4952 fromXappConn.SendRESTSubsDelReq(t, restSubId)
4953 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
4954 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
4955}
4956
4957func deleteXapp1Subscription(t *testing.T, restSubId *string) {
4958 xappConn1.SendRESTSubsDelReq(t, restSubId)
4959 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4960 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4961}
4962
4963func deleteXapp2Subscription(t *testing.T, restSubId *string) {
4964 xappConn2.SendRESTSubsDelReq(t, restSubId)
4965 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4966 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4967}
4968
4969func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
4970 resp, _ := xapp.Subscription.QuerySubscriptions()
4971 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
4972 assert.Equal(t, resp[0].Meid, meid)
4973 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
4974}
4975
4976func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
4977 //Wait that subs is cleaned
4978 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
4979
4980 xappConn1.TestMsgChanEmpty(t)
4981 xappConn2.TestMsgChanEmpty(t)
4982 e2termConn1.TestMsgChanEmpty(t)
4983 mainCtrl.wait_registry_empty(t, timeout)
4984}
4985
4986func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
4987
4988 var e2SubsId []uint32
4989
4990 for i := 0; i < count; i++ {
4991 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
4992 crereq, cremsg := toE2termConn.RecvSubsReq(t)
4993 fromXappConn.ExpectRESTNotification(t, restSubId)
4994 toE2termConn.SendSubsResp(t, crereq, cremsg)
4995 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
4996 e2SubsId = append(e2SubsId, instanceId)
4997 xapp.Logger.Info("TEST: %v", e2SubsId)
4998 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
4999 <-time.After(100 * time.Millisecond)
5000 }
5001 return e2SubsId
5002}
5003
5004func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
5005
5006 for i := 0; i < len(e2SubsIds); i++ {
5007 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
5008 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5009 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5010 <-time.After(1 * time.Second)
5011 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
5012 <-time.After(100 * time.Millisecond)
5013 }
5014
5015 // Wait that subs is cleaned
5016 for i := 0; i < len(e2SubsIds); i++ {
5017 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
5018 }
5019
5020}