blob: 71bc92dad5ed89b3e9e8d73fa284666ff03301bf [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
2248 waiter := rtmgrHttp.AllocNextEvent(false)
2249 newSubsId := mainCtrl.get_registry_next_subid(t)
2250
2251 // Req
2252 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2253 restSubId := xappConn1.SendRESTSubsReq(t, params)
2254
2255 waiter.WaitResult(t)
2256
2257 xappConn1.ExpectRESTNotification(t, restSubId)
2258 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//-----------------------------------------------------------------------------
2427/*
2428func 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
2479 // Wait that subs is cleaned
2480 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2481
2482 // Del2
2483 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2484 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2485 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2486
2487 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2488
2489 mainCtrl.VerifyCounterValues(t)
2490}
2491*/
2492func TestRESTSubDelReqRetransmission(t *testing.T) {
2493 CaseBegin("TestRESTSubDelReqRetransmission")
2494
2495 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2496 Counter{cSubReqFromXapp, 1},
2497 Counter{cSubReqToE2, 1},
2498 Counter{cSubRespFromE2, 1},
2499 Counter{cSubRespToXapp, 1},
2500 Counter{cSubDelReqFromXapp, 2},
2501 Counter{cSubDelReqToE2, 1},
2502 Counter{cSubDelRespFromE2, 1},
2503 Counter{cSubDelRespToXapp, 1},
2504 })
2505
2506 var params *teststube2ap.RESTSubsReqParams = nil
2507
2508 //Subs Create
2509 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2510
2511 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2512
2513 //Subs Delete
2514 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2515 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2516
2517 seqBef := mainCtrl.get_msgcounter(t)
2518 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2519 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2520
2521 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2522
2523 waitSubsCleanup(t, e2SubsId, 10)
2524
2525 mainCtrl.VerifyCounterValues(t)
2526}
2527
2528//-----------------------------------------------------------------------------
2529// TestRESTSubReqDelReq
2530//
2531// stub stub
2532// +-------+ +---------+ +---------+
2533// | xapp | | submgr | | e2term |
2534// +-------+ +---------+ +---------+
2535// | | |
2536// | RESTSubReq | |
2537// |---------------->| |
2538// | | |
2539// | RESTSubResp | |
2540// |<----------------| |
2541// | | SubReq |
2542// | |------------->|
2543// | RESTSubDelReq | |
2544// |---------------->| |
2545// | RESTSubDelResp | |
2546// | unsuccess | |
2547// |<----------------| |
2548// | | SubResp |
2549// | |<-------------|
2550// | RESTNotif1 | |
2551// |<----------------| |
2552// | | |
2553// | [SUBS DELETE] |
2554// | | |
2555//
2556//-----------------------------------------------------------------------------
2557func TestRESTSubReqDelReq(t *testing.T) {
2558 CaseBegin("TestRESTSubReqDelReq")
2559
2560 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2561 Counter{cSubReqFromXapp, 1},
2562 Counter{cSubReqToE2, 1},
2563 Counter{cSubRespFromE2, 1},
2564 Counter{cSubRespToXapp, 1},
2565 Counter{cSubDelReqFromXapp, 2},
2566 Counter{cSubDelReqToE2, 1},
2567 Counter{cSubDelRespFromE2, 1},
2568 Counter{cSubDelRespToXapp, 1},
2569 })
2570
2571 const subReqCount int = 1
2572 const parameterSet = 1
2573 const actionDefinitionPresent bool = true
2574 const actionParamCount int = 1
2575
2576 // Req
2577 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2578 restSubId := xappConn1.SendRESTSubsReq(t, params)
2579
2580 // Del. This will fail as processing of the subscription
2581 // is still ongoing in submgr. Deletion is not allowed before
2582 // subscription creation has been completed.
2583 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2584 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2585 xappConn1.ExpectRESTNotification(t, restSubId)
2586 e2termConn1.SendSubsResp(t, crereq, cremsg)
2587 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2588
2589 // Retry del
2590 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2591
2592 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2593 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2594
2595 // Wait that subs is cleaned
2596 waitSubsCleanup(t, e2SubsId, 10)
2597 mainCtrl.VerifyCounterValues(t)
2598
2599}
2600
2601func TestRESTSubDelReqCollision(t *testing.T) {
2602 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2603}
2604
2605func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2606 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2607
2608 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2609 Counter{cSubReqFromXapp, 2},
2610 Counter{cSubReqToE2, 2},
2611 Counter{cSubRespFromE2, 2},
2612 Counter{cSubRespToXapp, 2},
2613 Counter{cSubDelReqFromXapp, 2},
2614 Counter{cSubDelReqToE2, 2},
2615 Counter{cSubDelRespFromE2, 2},
2616 Counter{cSubDelRespToXapp, 2},
2617 })
2618
2619 //Req1
2620 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2621 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2622 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2623
2624 //Req2
2625 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2626 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2627 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2628
2629 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2630 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2631
2632 //XappConn1 receives both of the responses
2633 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2634
2635 //Resp1
2636 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2637 //Resp2
2638 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2639
2640 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2641 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2642 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2643 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2644
2645 //Del1
2646 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2647 //Del2
2648 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2649
2650 //Wait that subs is cleaned
2651 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2652 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2653
2654 mainCtrl.VerifyCounterValues(t)
2655
2656}
2657
2658func TestRESTSameSubsDiffRan(t *testing.T) {
2659 CaseBegin("TestRESTSameSubsDiffRan")
2660
2661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2662 Counter{cSubReqFromXapp, 2},
2663 Counter{cSubReqToE2, 2},
2664 Counter{cSubRespFromE2, 2},
2665 Counter{cSubRespToXapp, 2},
2666 Counter{cSubDelReqFromXapp, 2},
2667 Counter{cSubDelReqToE2, 2},
2668 Counter{cSubDelRespFromE2, 2},
2669 Counter{cSubDelRespToXapp, 2},
2670 })
2671
2672 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2673 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2674 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2675
2676 params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2677 params.SetMeid("RAN_NAME_2")
2678 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2679 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2680
2681 //Del1
2682 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2683 //Del2
2684 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2685
2686 //Wait that subs is cleaned
2687 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2688 waitSubsCleanup(t, e2SubsId2, 10)
2689
2690 mainCtrl.VerifyCounterValues(t)
2691
2692}
2693
2694func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2695 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2696
2697 // Init counter check
2698 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2699 Counter{cSubReqFromXapp, 1},
2700 Counter{cSubReqToE2, 1},
2701 Counter{cSubReReqToE2, 1},
2702 Counter{cSubRespFromE2, 1},
2703 Counter{cSubRespToXapp, 1},
2704 Counter{cSubDelReqFromXapp, 1},
2705 Counter{cSubDelReqToE2, 1},
2706 Counter{cSubDelRespFromE2, 1},
2707 Counter{cSubDelRespToXapp, 1},
2708 })
2709
2710 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2711 restSubId := xappConn1.SendRESTSubsReq(t, params)
2712
2713 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2714
2715 // Catch the first message and ignore it
2716 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2717 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2718
2719 // The second request is being handled normally
2720 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2721 xappConn1.ExpectRESTNotification(t, restSubId)
2722 e2termConn1.SendSubsResp(t, crereq, cremsg)
2723 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2724
2725 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2726
2727 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2728
2729 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2730 //Wait that subs is cleaned
2731 waitSubsCleanup(t, e2SubsId, 10)
2732
2733 mainCtrl.VerifyCounterValues(t)
2734
2735}
2736
2737//-----------------------------------------------------------------------------
2738// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2739//
2740// stub stub
2741// +-------+ +---------+ +---------+
2742// | xapp | | submgr | | e2term |
2743// +-------+ +---------+ +---------+
2744// | | |
2745// | RESTSubReq | |
2746// |---------------->| |
2747// | | |
2748// | RESTSubResp | |
2749// |<----------------| |
2750// | | SubReq |
2751// | |------------->|
2752// | | |
2753// | | |
2754// | | SubReq |
2755// | |------------->|
2756// | | |
2757// | | SubDelReq |
2758// | |------------->|
2759// | | |
2760// | | |
2761// | | SubDelReq |
2762// | |------------->|
2763// | | |
2764// | | |
2765// | | SubDelResp |
2766// | |<-------------|
2767// | RESTNotif | |
2768// | unsuccess | |
2769// |<----------------| |
2770// | | |
2771// | [SUBS DELETE] |
2772// | | |
2773//
2774//-----------------------------------------------------------------------------
2775func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2776 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2777
2778 // Init counter check
2779 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2780 Counter{cSubReqFromXapp, 1},
2781 Counter{cSubReqToE2, 1},
2782 Counter{cSubReReqToE2, 1},
2783 Counter{cSubReqTimerExpiry, 2},
2784 Counter{cSubDelReqToE2, 1},
2785 Counter{cSubDelRespFromE2, 1},
2786 })
2787
2788 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2789 restSubId := xappConn1.SendRESTSubsReq(t, params)
2790 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2791
2792 e2termConn1.RecvSubsReq(t)
2793 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2794
2795 e2termConn1.RecvSubsReq(t)
2796 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2797
2798 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2799 xappConn1.ExpectRESTNotification(t, restSubId)
2800 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2801 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2802 xappConn1.WaitRESTNotification(t, restSubId)
2803
2804 // Wait that subs is cleaned
2805 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2806
2807 mainCtrl.VerifyCounterValues(t)
2808}
2809
2810func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2811 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2812
2813 // Init counter check
2814 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2815 Counter{cSubReqFromXapp, 1},
2816 Counter{cSubReqToE2, 1},
2817 Counter{cSubReReqToE2, 1},
2818 Counter{cSubReqTimerExpiry, 2},
2819 Counter{cSubDelReqToE2, 1},
2820 Counter{cSubDelReqTimerExpiry, 2},
2821 })
2822
2823 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2824 restSubId := xappConn1.SendRESTSubsReq(t, params)
2825 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2826
2827 e2termConn1.RecvSubsReq(t)
2828 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2829
2830 e2termConn1.RecvSubsReq(t)
2831 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2832
2833 e2termConn1.RecvSubsDelReq(t)
2834 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2835
2836 xappConn1.ExpectRESTNotification(t, restSubId)
2837 e2termConn1.RecvSubsDelReq(t)
2838 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2839
2840 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2841
2842 waitSubsCleanup(t, e2SubsId, 10)
2843
2844 mainCtrl.VerifyCounterValues(t)
2845
2846}
2847
2848//-----------------------------------------------------------------------------
2849// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2850//
2851// stub stub
2852// +-------+ +---------+ +---------+
2853// | xapp | | submgr | | e2term |
2854// +-------+ +---------+ +---------+
2855// | | |
2856// | RESTSubReq | |
2857// |---------------->| |
2858// | | |
2859// | RESTSubResp | |
2860// |<----------------| |
2861// | | SubReq |
2862// | |------------->|
2863// | | |
2864// | | |
2865// | | SubReq |
2866// | |------------->|
2867// | | |
2868// | | SubDelReq |
2869// | |------------->|
2870// | | |
2871// | | |
2872// | | SubDelReq |
2873// | |------------->|
2874// | | |
2875// | | |
2876// | | SubDelResp |
2877// | |<-------------|
2878// | RESTNotif | |
2879// | unsuccess | |
2880// |<----------------| |
2881// | | |
2882// | [SUBS DELETE] |
2883// | | |
2884//
2885//-----------------------------------------------------------------------------
2886func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
2887 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
2888
2889 // Init counter check
2890 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2891 Counter{cSubReqFromXapp, 1},
2892 Counter{cSubReqToE2, 1},
2893 Counter{cSubReReqToE2, 1},
2894 Counter{cSubReqTimerExpiry, 2},
2895 Counter{cSubDelReqToE2, 1},
2896 Counter{cSubDelReReqToE2, 1},
2897 Counter{cSubDelReqTimerExpiry, 2},
2898 })
2899
2900 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2901 restSubId := xappConn1.SendRESTSubsReq(t, params)
2902 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2903
2904 e2termConn1.RecvSubsReq(t)
2905 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2906
2907 e2termConn1.RecvSubsReq(t)
2908 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2909
2910 e2termConn1.RecvSubsDelReq(t)
2911 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2912
2913 xappConn1.ExpectRESTNotification(t, restSubId)
2914 e2termConn1.RecvSubsDelReq(t)
2915 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2916
2917 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2918
2919 waitSubsCleanup(t, e2SubsId, 10)
2920
2921 mainCtrl.VerifyCounterValues(t)
2922}
2923
2924//-----------------------------------------------------------------------------
2925// TestRESTSubReqSubFailRespInSubmgr
2926//
2927// stub stub
2928// +-------+ +---------+ +---------+
2929// | xapp | | submgr | | e2term |
2930// +-------+ +---------+ +---------+
2931// | | |
2932// | RESTSubReq | |
2933// |---------------->| |
2934// | | |
2935// | RESTSubResp | |
2936// |<----------------| |
2937// | | SubReq |
2938// | |------------->|
2939// | | |
2940// | | SubFail |
2941// | |<-------------|
2942// | | |
2943// | | SubDelReq |
2944// | |------------->|
2945// | | |
2946// | | SubDelResp |
2947// | |<-------------|
2948// | | |
2949// | RESTNotif | |
2950// | unsuccess | |
2951// |<----------------| |
2952// | | |
2953// | [SUBS DELETE] |
2954// | | |
2955//
2956//-----------------------------------------------------------------------------
2957func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
2958 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
2959
2960 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2961 Counter{cSubReqFromXapp, 1},
2962 Counter{cSubReqToE2, 1},
2963 Counter{cSubFailFromE2, 1},
2964 Counter{cSubRespToXapp, 1},
2965 Counter{cSubDelReqFromXapp, 1},
2966 })
2967
2968 const subReqCount int = 1
2969 const parameterSet = 1
2970 const actionDefinitionPresent bool = true
2971 const actionParamCount int = 1
2972
2973 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2974 restSubId := xappConn1.SendRESTSubsReq(t, params)
2975
2976 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2977 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2978 fparams1.Set(crereq1)
2979 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2980
2981 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2982 xappConn1.ExpectRESTNotification(t, restSubId)
2983 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2984 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2985 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2986
2987 // REST subscription sill there to be deleted
2988 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2989
2990 // Wait that subs is cleaned
2991 waitSubsCleanup(t, e2SubsId, 10)
2992
2993 mainCtrl.VerifyCounterValues(t)
2994
2995}
2996
2997//-----------------------------------------------------------------------------
2998// TestRESTSubDelReqRetryInSubmgr
2999//
3000// stub stub
3001// +-------+ +---------+ +---------+
3002// | xapp | | submgr | | e2term |
3003// +-------+ +---------+ +---------+
3004// | | |
3005// | [SUBS CREATE] |
3006// | | |
3007// | | |
3008// | RESTSubDelReq | |
3009// |---------------->| |
3010// | | |
3011// | RESTSubDelResp | |
3012// |<----------------| |
3013// | | SubDelReq |
3014// | |------------->|
3015// | | |
3016// | | SubDelReq |
3017// | |------------->|
3018// | | |
3019// | | SubDelResp |
3020// | |<-------------|
3021// | | |
3022//
3023//-----------------------------------------------------------------------------
3024func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3025 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3026
3027 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3028 Counter{cSubReqFromXapp, 1},
3029 Counter{cSubReqToE2, 1},
3030 Counter{cSubRespFromE2, 1},
3031 Counter{cSubRespToXapp, 1},
3032 Counter{cSubDelReqFromXapp, 1},
3033 Counter{cSubDelReqToE2, 1},
3034 Counter{cSubDelReReqToE2, 1},
3035 Counter{cSubDelRespFromE2, 1},
3036 Counter{cSubDelRespToXapp, 1},
3037 })
3038 // Req
3039 var params *teststube2ap.RESTSubsReqParams = nil
3040 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3041
3042 // Del
3043 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3044
3045 // E2t: Receive 1st SubsDelReq
3046 e2termConn1.RecvSubsDelReq(t)
3047
3048 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3049 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3050 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3051
3052 //Wait that subs is cleaned
3053 waitSubsCleanup(t, e2SubsId, 10)
3054
3055 mainCtrl.VerifyCounterValues(t)
3056}
3057
3058//-----------------------------------------------------------------------------
3059// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3060//
3061// stub stub
3062// +-------+ +---------+ +---------+
3063// | xapp | | submgr | | e2term |
3064// +-------+ +---------+ +---------+
3065// | | |
3066// | [SUBS CREATE] |
3067// | | |
3068// | | |
3069// | RESTSubDelReq | |
3070// |---------------->| |
3071// | | |
3072// | RESTSubDelResp | |
3073// |<----------------| |
3074// | | SubDelReq |
3075// | |------------->|
3076// | | |
3077// | | SubDelReq |
3078// | |------------->|
3079// | | |
3080// | | |
3081//
3082//-----------------------------------------------------------------------------
3083func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3084 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3085
3086 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3087 Counter{cSubReqFromXapp, 1},
3088 Counter{cSubReqToE2, 1},
3089 Counter{cSubRespFromE2, 1},
3090 Counter{cSubRespToXapp, 1},
3091 Counter{cSubDelReqFromXapp, 1},
3092 Counter{cSubDelReqToE2, 1},
3093 Counter{cSubDelReReqToE2, 1},
3094 Counter{cSubDelRespFromE2, 1},
3095 Counter{cSubDelRespToXapp, 1},
3096 })
3097
3098 // Req
3099 var params *teststube2ap.RESTSubsReqParams = nil
3100 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3101
3102 // Del
3103 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3104
3105 // E2t: Receive 1st SubsDelReq
3106 e2termConn1.RecvSubsDelReq(t)
3107
3108 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3109 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3110 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3111
3112 //Wait that subs is cleaned
3113 waitSubsCleanup(t, e2SubsId, 10)
3114
3115 mainCtrl.VerifyCounterValues(t)
3116}
3117
3118//-----------------------------------------------------------------------------
3119// TestRESTSubDelReqSubDelFailRespInSubmgr
3120//
3121// stub stub
3122// +-------+ +---------+ +---------+
3123// | xapp | | submgr | | e2term |
3124// +-------+ +---------+ +---------+
3125// | | |
3126// | [SUBS CREATE] |
3127// | | |
3128// | | |
3129// | RESTSubDelReq | |
3130// |---------------->| |
3131// | | |
3132// | RESTSubDelResp | |
3133// |<----------------| |
3134// | | SubDelReq |
3135// | |------------->|
3136// | | |
3137// | | SubDelFail |
3138// | |<-------------|
3139// | | |
3140//
3141//-----------------------------------------------------------------------------
3142func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3143 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3144
3145 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3146 Counter{cSubReqFromXapp, 1},
3147 Counter{cSubReqToE2, 1},
3148 Counter{cSubRespFromE2, 1},
3149 Counter{cSubRespToXapp, 1},
3150 Counter{cSubDelReqFromXapp, 1},
3151 Counter{cSubDelReqToE2, 1},
3152 Counter{cSubDelFailFromE2, 1},
3153 Counter{cSubDelRespToXapp, 1},
3154 })
3155
3156 // Req
3157 var params *teststube2ap.RESTSubsReqParams = nil
3158 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3159
3160 // Del
3161 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3162
3163 // E2t: Send receive SubsDelReq and send SubsDelFail
3164 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3165 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3166
3167 //Wait that subs is cleaned
3168 waitSubsCleanup(t, e2SubsId, 10)
3169
3170 mainCtrl.VerifyCounterValues(t)
3171}
3172
3173//-----------------------------------------------------------------------------
3174// TestRESTSubReqAndSubDelOkSameAction
3175//
3176// stub stub
3177// +-------+ +-------+ +---------+ +---------+
3178// | xapp2 | | xapp1 | | submgr | | e2term |
3179// +-------+ +-------+ +---------+ +---------+
3180// | | | |
3181// | | RESTSubReq1 | |
3182// | |---------------->| |
3183// | | | |
3184// | | RESTSubResp1 | |
3185// | |<----------------| |
3186// | | | |
3187// | | | SubReq1 |
3188// | | |------------->|
3189// | | | SubResp1 |
3190// | | |<-------------|
3191// | | RESTNotif1 | |
3192// | |<----------------| |
3193// | | | |
3194// | RESTSubReq2 | |
3195// |------------------------------>| |
3196// | | | |
3197// | RESTSubResp2 | |
3198// |<------------------------------| |
3199// | | | |
3200// | | RESTNotif2 | |
3201// |<------------------------------| |
3202// | | | |
3203// | | RESTSubDelReq1 | |
3204// | |---------------->| |
3205// | | | |
3206// | | RESTSubDelResp1 | |
3207// | |<----------------| |
3208// | | | |
3209// | RESTSubDelReq2 | |
3210// |------------------------------>| |
3211// | | | |
3212// | RESTSubDelResp2 | |
3213// |<------------------------------| |
3214// | | | |
3215// | | | SubDelReq2 |
3216// | | |------------->|
3217// | | | |
3218// | | | SubDelResp2 |
3219// | | |<-------------|
3220// | | | |
3221//
3222//-----------------------------------------------------------------------------
3223func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3224 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3225
3226 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3227 Counter{cSubReqFromXapp, 2},
3228 Counter{cSubReqToE2, 1},
3229 Counter{cSubRespFromE2, 1},
3230 Counter{cSubRespToXapp, 2},
3231 Counter{cMergedSubscriptions, 1},
3232 Counter{cUnmergedSubscriptions, 1},
3233 Counter{cSubDelReqFromXapp, 2},
3234 Counter{cSubDelReqToE2, 1},
3235 Counter{cSubDelRespFromE2, 1},
3236 Counter{cSubDelRespToXapp, 2},
3237 })
3238
3239 // Req1
3240 var params *teststube2ap.RESTSubsReqParams = nil
3241
3242 //Subs Create
3243 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3244 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3245
3246 // Req2
3247 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3248 params.SetMeid("RAN_NAME_1")
3249
3250 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3251 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
3252 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3253 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3254 e2SubsId2 := <-xappConn2.RESTNotification
3255 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3256
3257 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3258
3259 // Del1
3260 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3261
3262 // Del2
3263 deleteXapp2Subscription(t, &restSubId2)
3264
3265 //Wait that subs is cleaned
3266 waitSubsCleanup(t, e2SubsId2, 10)
3267
3268 mainCtrl.VerifyCounterValues(t)
3269}
3270
3271//-----------------------------------------------------------------------------
3272// TestSubReqAndSubDelOkSameActionParallel
3273//
3274// stub stub stub
3275// +-------+ +-------+ +---------+ +---------+
3276// | xapp2 | | xapp1 | | submgr | | e2term |
3277// +-------+ +-------+ +---------+ +---------+
3278// | | | |
3279// | | | |
3280// | | | |
3281// | | SubReq1 | |
3282// | |------------->| |
3283// | | | |
3284// | | | SubReq1 |
3285// | | |------------->|
3286// | SubReq2 | |
3287// |--------------------------->| |
3288// | | | SubResp1 |
3289// | | |<-------------|
3290// | | SubResp1 | |
3291// | |<-------------| |
3292// | | | SubReq2 |
3293// | | |------------->|
3294// | | | |
3295// | | | SubResp2 |
3296// | | |<-------------|
3297// | SubResp2 | |
3298// |<---------------------------| |
3299// | | | |
3300// | | SubDelReq 1 | |
3301// | |------------->| |
3302// | | | |
3303// | | SubDelResp 1 | |
3304// | |<-------------| |
3305// | | | |
3306// | SubDelReq 2 | |
3307// |--------------------------->| |
3308// | | | |
3309// | | | SubDelReq 2 |
3310// | | |------------->|
3311// | | | |
3312// | | | SubDelReq 2 |
3313// | | |------------->|
3314// | | | |
3315// | SubDelResp 2 | |
3316// |<---------------------------| |
3317//
3318func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3319 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3320
3321 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3322 Counter{cSubReqFromXapp, 2},
3323 Counter{cSubReqToE2, 2},
3324 Counter{cSubRespFromE2, 2},
3325 Counter{cSubRespToXapp, 2},
3326 Counter{cSubDelReqFromXapp, 2},
3327 Counter{cSubDelReqToE2, 2},
3328 Counter{cSubDelRespFromE2, 2},
3329 Counter{cSubDelRespToXapp, 2},
3330 })
3331
3332 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3333 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3334 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3335
3336 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3337 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3338
3339 xappConn1.ExpectRESTNotification(t, restSubId1)
3340 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3341 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3342
3343 xappConn2.ExpectRESTNotification(t, restSubId2)
3344 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3345 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3346 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3347
3348 // Del1
3349 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3350 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3351 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3352 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3353
3354 // Del2
3355 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3356 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3357 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3358
3359 waitSubsCleanup(t, e2SubsId2, 10)
3360
3361 mainCtrl.VerifyCounterValues(t)
3362}
3363
3364//-----------------------------------------------------------------------------
3365// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3366//
3367// stub stub stub
3368// +-------+ +-------+ +---------+ +---------+
3369// | xapp2 | | xapp1 | | submgr | | e2term |
3370// +-------+ +-------+ +---------+ +---------+
3371// | | | |
3372// | | | |
3373// | | | |
3374// | | RESTSubReq1 | |
3375// | |---------------->| |
3376// | | | |
3377// | | RESTSubResp1 | |
3378// | |<----------------| |
3379// | | | SubReq1 |
3380// | | |------------->|
3381// | RESTSubReq2 | |
3382// |------------------------------>| |
3383// | | | |
3384// | RESTSubDelResp2 | |
3385// |<------------------------------| |
3386// | | | SubReq1 |
3387// | | |------------->|
3388// | | | |
3389// | | | |
3390// | | | SubDelReq |
3391// | | |------------->|
3392// | | | |
3393// | | | SubDelResp |
3394// | | |<-------------|
3395// | | RESTNotif1 | |
3396// | | unsuccess | |
3397// | |<----------------| |
3398// | RESTNotif2 | |
3399// | | unsuccess | |
3400// |<------------------------------| |
3401// | | | |
3402// | | RESTSubDelReq1 | |
3403// | |---------------->| |
3404// | | | |
3405// | | RESTSubDelResp1 | |
3406// | |<----------------| |
3407// | | | |
3408// | RESTSubDelReq2 | |
3409// |------------------------------>| |
3410// | | | |
3411// | RESTSubDelResp2 | |
3412// |<------------------------------| |
3413//
3414//-----------------------------------------------------------------------------
3415func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3416 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3417
3418 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3419 Counter{cSubReqFromXapp, 2},
3420 Counter{cSubReqToE2, 1},
3421 Counter{cSubRespToXapp, 2},
3422 Counter{cSubDelReqFromXapp, 2},
3423 Counter{cSubDelReqToE2, 1},
3424 Counter{cSubDelRespFromE2, 1},
3425 Counter{cSubDelRespToXapp, 2},
3426 })
3427
3428 const subReqCount int = 1
3429 const parameterSet = 1
3430 const actionDefinitionPresent bool = true
3431 const actionParamCount int = 1
3432
3433 // Req1
3434 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3435 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3436 crereq1, _ := e2termConn1.RecvSubsReq(t)
3437
3438 // Req2
3439 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3440 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3441 params2.SetMeid("RAN_NAME_1")
3442 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3443 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3444
3445 //Req1 (retransmitted)
3446 e2termConn1.RecvSubsReq(t)
3447
3448 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3449 xappConn1.ExpectRESTNotification(t, restSubId1) // or restSubId2?
3450 // xappConn2.WaitRESTNotification(t)
3451 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3452
3453 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3454 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId1)
3455
3456 // e2SubsId2 := <-xappConn2.RESTNotification
3457 // xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId2)
3458
3459 // Del1
3460 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3461
3462 // Del2
3463 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3464
3465 //Wait that subs is cleaned
3466 waitSubsCleanup(t, e2SubsId1, 10)
3467
3468 mainCtrl.VerifyCounterValues(t)
3469}
3470
3471//-----------------------------------------------------------------------------
3472// TestRESTSubReqAndSubDelNokSameActionParallel
3473//
3474// stub stub stub
3475// +-------+ +-------+ +---------+ +---------+
3476// | xapp2 | | xapp1 | | submgr | | e2term |
3477// +-------+ +-------+ +---------+ +---------+
3478// | | | |
3479// | | | |
3480// | | | |
3481// | | RESTSubReq1 | |
3482// | |---------------->| |
3483// | | | |
3484// | | RESTSubResp1 | |
3485// | |<----------------| |
3486// | | | SubReq1 |
3487// | | |------------->|
3488// | RESTSubReq2 | |
3489// |------------------------------>| |
3490// | | | |
3491// | RESTSubDelResp2 | |
3492// |<------------------------------| |
3493// | | | SubFail1 |
3494// | | |<-------------|
3495// | | | |
3496// | | RESTNotif1 | |
3497// | | unsuccess | |
3498// | |<----------------| |
3499// | RESTNotif2 | |
3500// | | unsuccess | |
3501// |<------------------------------| |
3502// | | | SubDelReq |
3503// | | |------------->|
3504// | | | SubDelResp |
3505// | | |<-------------|
3506// | | | |
3507// | | RESTSubDelReq1 | |
3508// | |---------------->| |
3509// | | | |
3510// | | RESTSubDelResp1 | |
3511// | |<----------------| |
3512// | | | |
3513// | RESTSubDelReq2 | |
3514// |------------------------------>| |
3515// | | | |
3516// | RESTSubDelResp2 | |
3517// |<------------------------------| |
3518//
3519//-----------------------------------------------------------------------------
3520func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3521 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3522
3523 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3524 Counter{cSubReqFromXapp, 2},
3525 Counter{cSubReqToE2, 1},
3526 Counter{cSubFailFromE2, 1},
3527 Counter{cSubRespToXapp, 2},
3528 Counter{cSubDelReqFromXapp, 2},
3529 Counter{cSubDelReqToE2, 1},
3530 Counter{cSubDelRespFromE2, 1},
3531 Counter{cSubDelRespToXapp, 2},
3532 })
3533
3534 const subReqCount int = 1
3535 const parameterSet = 1
3536 const actionDefinitionPresent bool = true
3537 const actionParamCount int = 1
3538
3539 // Req1
3540 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3541 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3542 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3543
3544 // Req2
3545 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3546 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3547 params2.SetMeid("RAN_NAME_1")
3548 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3549 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3550
3551 // E2t: send SubsFail (first)
3552 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3553 fparams1.Set(crereq1)
3554 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3555
3556 // E2t: internal delete
3557 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3558 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3559 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3560
3561 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3562 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3563 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3564 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3565
3566 // Del1
3567 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3568
3569 // Del2
3570 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3571
3572 //Wait that subs is cleaned
3573 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3574 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3575
3576 mainCtrl.VerifyCounterValues(t)
3577}
3578
3579func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3580 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3581
3582 // Init counter check
3583 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3584 Counter{cSubReqFromXapp, 1},
3585 Counter{cSubReqToE2, 1},
3586 Counter{cSubRespFromE2, 1},
3587 Counter{cSubRespToXapp, 1},
3588 Counter{cSubDelReqFromXapp, 1},
3589 Counter{cSubDelReqToE2, 1},
3590 Counter{cSubDelRespFromE2, 1},
3591 Counter{cSubDelRespToXapp, 1},
3592 })
3593
3594 const subReqCount int = 1
3595 const parameterSet = 1
3596 const actionDefinitionPresent bool = true
3597 const actionParamCount int = 1
3598
3599 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3600 restSubId := xappConn1.SendRESTSubsReq(t, params)
3601 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3602
3603 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3604 xappConn1.ExpectRESTNotification(t, restSubId)
3605 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3606 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3607 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3608
3609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3610 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3611 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3612
3613 // Wait that subs is cleaned
3614 waitSubsCleanup(t, e2SubsId, 10)
3615 mainCtrl.VerifyCounterValues(t)
3616}
3617
3618//-----------------------------------------------------------------------------
3619// TestRESTSubReqPolicyChangeAndSubDelOk
3620//
3621// stub stub
3622// +-------+ +---------+ +---------+
3623// | xapp | | submgr | | e2term |
3624// +-------+ +---------+ +---------+
3625// | | |
3626// | RESTSubReq | |
3627// |---------------->| |
3628// | | |
3629// | RESTSubResp | |
3630// |<----------------| |
3631// | | SubReq |
3632// | |------------->|
3633// | | |
3634// | | SubResp |
3635// | |<-------------|
3636// | | |
3637// | RESTNotif | |
3638// |<----------------| |
3639// | | |
3640// | RESTSubReq | |
3641// |---------------->| |
3642// | | |
3643// | RESTSubResp | |
3644// |<----------------| |
3645// | | SubReq |
3646// | |------------->|
3647// | | |
3648// | | SubResp |
3649// | |<-------------|
3650// | | |
3651// | RESTNotif | |
3652// |<----------------| |
3653// | | |
3654// | RESTSubDelReq | |
3655// |---------------->| |
3656// | | |
3657// | | SubDelReq |
3658// | |------------->|
3659// | | |
3660// | | SubDelResp |
3661// | |<-------------|
3662// | | |
3663// | RESTSubDelResp | |
3664// |<----------------| |
3665//
3666//-----------------------------------------------------------------------------
3667func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3668 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3669
3670 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3671 Counter{cSubReqFromXapp, 2},
3672 Counter{cSubReqToE2, 2},
3673 Counter{cSubRespFromE2, 2},
3674 Counter{cSubRespToXapp, 2},
3675 Counter{cSubDelReqFromXapp, 1},
3676 Counter{cSubDelReqToE2, 1},
3677 Counter{cSubDelRespFromE2, 1},
3678 Counter{cSubDelRespToXapp, 1},
3679 })
3680
3681 const subReqCount int = 1
3682 const parameterSet = 1
3683 const actionDefinitionPresent bool = true
3684 const policyParamCount int = 1
3685
3686 // Req
3687 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3688 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3689
3690 // Policy change
3691 instanceId := int64(e2SubsId)
3692 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
3693 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3694 params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
3695 params.SetTimeToWait("w200ms")
3696 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3697
3698 // Del
3699 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3700
3701 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3702 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3703
3704 // Wait that subs is cleaned
3705 waitSubsCleanup(t, e2SubsId, 10)
3706 mainCtrl.VerifyCounterValues(t)
3707}
3708
3709//-----------------------------------------------------------------------------
3710// TestRESTSubReqAndSubDelOkTwoE2termParallel
3711//
3712// stub stub stub
3713// +-------+ +---------+ +---------+ +---------+
3714// | xapp | | submgr | | e2term1 | | e2term2 |
3715// +-------+ +---------+ +---------+ +---------+
3716// | | | |
3717// | | | |
3718// | | | |
3719// | RESTSubReq1 | | |
3720// |---------------->| | |
3721// | | | |
3722// | RESTSubResp1 | | |
3723// |<----------------| | |
3724// | | SubReq1 | |
3725// | |------------->| |
3726// | | | |
3727// | RESTSubReq2 | | |
3728// |---------------->| | |
3729// | | | |
3730// | RESTSubResp2 | | |
3731// |<----------------| | |
3732// | | SubReq2 | |
3733// | |---------------------------->|
3734// | | | |
3735// | | SubResp1 | |
3736// | |<-------------| |
3737// | RESTNotif1 | | |
3738// |<----------------| | |
3739// | | SubResp2 | |
3740// | |<----------------------------|
3741// | RESTNotif2 | | |
3742// |<----------------| | |
3743// | | | |
3744// | [SUBS 1 DELETE] | |
3745// | | | |
3746// | [SUBS 2 DELETE] | |
3747// | | | |
3748//
3749//-----------------------------------------------------------------------------
3750func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3751 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3752
3753 // Init counter check
3754 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3755 Counter{cSubReqFromXapp, 2},
3756 Counter{cSubReqToE2, 2},
3757 Counter{cSubRespFromE2, 2},
3758 Counter{cSubRespToXapp, 2},
3759 Counter{cSubDelReqFromXapp, 2},
3760 Counter{cSubDelReqToE2, 2},
3761 Counter{cSubDelRespFromE2, 2},
3762 Counter{cSubDelRespToXapp, 2},
3763 })
3764
3765 const subReqCount int = 1
3766 const parameterSet = 1
3767 const actionDefinitionPresent bool = true
3768 const actionParamCount int = 1
3769
3770 // Req1
3771 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3772 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3773 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3774
3775 // Req2
3776 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3777 params.SetMeid("RAN_NAME_11")
3778 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3779 // would not work as notification would not be received
3780 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3781 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3782
3783 // Resp1
3784 xappConn1.ExpectRESTNotification(t, restSubId1)
3785 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3786 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3787 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3788
3789 // Resp2
3790 xappConn2.ExpectRESTNotification(t, restSubId2)
3791 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3792 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3793 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3794
3795 // Delete1
3796 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3797 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3798 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3799
3800 // Wait that subs is cleaned
3801 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3802
3803 // Delete2
3804 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3805 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3806 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3807
3808 // Wait that subs is cleaned
3809 waitSubsCleanup(t, e2SubsId2, 10)
3810
3811 mainCtrl.VerifyCounterValues(t)
3812}
3813
3814//-----------------------------------------------------------------------------
3815// TestRESTSubReqAsn1EncodeFail
3816//
3817// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3818// stub stub
3819// +-------+ +---------+ +---------+
3820// | xapp | | submgr | | e2term |
3821// +-------+ +---------+ +---------+
3822// | | |
3823// | RESTSubReq | |
3824// |---------------->| |
3825// | | |
3826// | RESTSubResp | |
3827// |<----------------| |
3828// | RESTSubDelReq | |
3829// |---------------->| |
3830// | RESTSubDelResp | |
3831// | unsuccess | |
3832// |<----------------| |
3833// | | |
3834//
3835//-----------------------------------------------------------------------------
3836func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
3837 CaseBegin("TestRESTSubReqAsn1EncodeFail")
3838
3839 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
3840
3841}
3842
3843//-----------------------------------------------------------------------------
3844// TestRESTSubReqInsertAndSubDelOk
3845//
3846// stub stub
3847// +-------+ +---------+ +---------+
3848// | xapp | | submgr | | e2term |
3849// +-------+ +---------+ +---------+
3850// | | |
3851// | RestSubReq | |
3852// |---------------->| |
3853// | | |
3854// | RESTSubResp | |
3855// |<----------------| |
3856// | | |
3857// | | SubReq |
3858// | |------------->|
3859// | | |
3860// | | SubResp |
3861// | |<-------------|
3862// | RESTNotif | |
3863// |<----------------| |
3864// | ... | ... |
3865// | | |
3866// | RESTSubDelReq | |
3867// |---------------->| |
3868// | | |
3869// | | SubDelReq |
3870// | |------------->|
3871// | | |
3872// | | SubDelResp |
3873// | |<-------------|
3874// | | |
3875// | RESTSubDelResp| |
3876// |<----------------| |
3877//
3878//-----------------------------------------------------------------------------
3879func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
3880 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
3881
3882 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3883 Counter{cSubReqFromXapp, 1},
3884 Counter{cSubReqToE2, 1},
3885 Counter{cSubRespFromE2, 1},
3886 Counter{cSubRespToXapp, 1},
3887 Counter{cSubDelReqFromXapp, 1},
3888 Counter{cSubDelReqToE2, 1},
3889 Counter{cSubDelRespFromE2, 1},
3890 Counter{cSubDelRespToXapp, 1},
3891 })
3892
3893 const subReqCount int = 1
3894 const parameterSet int = 1
3895 const actionDefinitionPresent bool = true
3896 const actionParamCount int = 1
3897
3898 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3899 params.SetSubActionTypes("insert")
3900
3901 // Req
3902 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3903
3904 // Del
3905 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3906
3907 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3908 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3909
3910 // Wait that subs is cleaned
3911 waitSubsCleanup(t, e2SubsId, 10)
3912 mainCtrl.VerifyCounterValues(t)
3913}
3914
3915//-----------------------------------------------------------------------------
3916// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
3917//
3918// stub stub
3919// +-------+ +---------+ +---------+
3920// | xapp | | submgr | | e2term |
3921// +-------+ +---------+ +---------+
3922// | | |
3923// | RESTSubReq | |
3924// |------------->| |
3925// | | |
3926// | | SubReq |
3927// | |------------->|
3928// | | |
3929// | | SubResp |
3930// | <----|
3931// | |
3932// | Submgr restart |
3933// | |
3934// | | |
3935// | | SubDelReq |
3936// | |------------->|
3937// | | |
3938// | | SubDelResp |
3939// | |<-------------|
3940// | | |
3941//
3942//-----------------------------------------------------------------------------
3943func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
3944 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
3945
3946 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3947 Counter{cSubReqFromXapp, 1},
3948 Counter{cSubReqToE2, 1},
3949 Counter{cSubDelReqFromXapp, 1},
3950 Counter{cSubDelReqToE2, 1},
3951 Counter{cSubDelRespFromE2, 1},
3952 })
3953
3954 const subReqCount int = 1
3955 const parameterSet = 1
3956 const actionDefinitionPresent bool = true
3957 const actionParamCount int = 1
3958
3959 // Remove possible existing subscription
3960 mainCtrl.removeExistingSubscriptions(t)
3961
3962 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3963
3964 //Req
3965 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
3966 restSubId := xappConn1.SendRESTSubsReq(t, params)
3967 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3968
3969 e2termConn1.RecvSubsReq(t)
3970
3971 mainCtrl.SetResetTestFlag(t, false)
3972
3973 mainCtrl.SimulateRestart(t)
3974 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
3975
3976 //Del
3977 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3978 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3979
3980 xappConn1.TestMsgChanEmpty(t)
3981 xappConn2.TestMsgChanEmpty(t)
3982 e2termConn1.TestMsgChanEmpty(t)
3983 mainCtrl.wait_registry_empty(t, 10)
3984
3985 mainCtrl.VerifyCounterValues(t)
3986}
3987
3988//-----------------------------------------------------------------------------
3989// TestRESTSubReqAndSubDelOkWithRestartInMiddle
3990//
3991// stub stub
3992// +-------+ +---------+ +---------+
3993// | xapp | | submgr | | e2term |
3994// +-------+ +---------+ +---------+
3995// | | |
3996// | RESTSubReq | |
3997// |---------------->| |
3998// | | |
3999// | RESTSubResp | |
4000// |<----------------| |
4001// | | SubReq |
4002// | |------------->|
4003// | | |
4004// | | SubResp |
4005// | |<-------------|
4006// | | |
4007// | RESTNotif | |
4008// |<----------------| |
4009// | | |
4010// | |
4011// | Submgr restart |
4012// | | |
4013// | RESTSubDelReq | |
4014// |---------------->| |
4015// | | |
4016// | | SubDelReq |
4017// | |------------->|
4018// | | |
4019// | | SubDelResp |
4020// | |<-------------|
4021// | | |
4022// | RESTSubDelResp | |
4023// |<----------------| |
4024//
4025//-----------------------------------------------------------------------------
4026func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4027 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4028
4029 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4030 Counter{cSubReqFromXapp, 1},
4031 Counter{cSubReqToE2, 1},
4032 Counter{cSubRespFromE2, 1},
4033 Counter{cSubRespToXapp, 1},
4034 Counter{cSubDelReqFromXapp, 1},
4035 Counter{cSubDelReqToE2, 1},
4036 Counter{cSubDelRespToXapp, 1},
4037 })
4038
4039 // Remove possible existing subscription
4040 mainCtrl.removeExistingSubscriptions(t)
4041
4042 var params *teststube2ap.RESTSubsReqParams = nil
4043
4044 // Create subscription
4045 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4046 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4047
4048 // Check subscription
4049 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4050
4051 // When SDL support for the REST Interface is added
4052 // the submgr restart statement below should be removed
4053 // from the comment.
4054
4055 // mainCtrl.SimulateRestart(t)
4056 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4057
4058 // Check subscription
4059 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4060
4061 // Delete subscription
4062 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4063
4064 //Wait that subs is cleaned
4065 waitSubsCleanup(t, e2SubsId, 10)
4066
4067 mainCtrl.VerifyCounterValues(t)
4068}
4069
4070//-----------------------------------------------------------------------------
4071// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4072//
4073// stub stub
4074// +-------+ +-------+ +---------+ +---------+
4075// | xapp2 | | xapp1 | | submgr | | e2term |
4076// +-------+ +-------+ +---------+ +---------+
4077// | | | |
4078// | | RESTSubReq1 | |
4079// | |---------------->| |
4080// | | | |
4081// | | RESTSubResp1 | |
4082// | |<----------------| |
4083// | | | |
4084// | | | SubReq1 |
4085// | | |------------->|
4086// | | | SubResp1 |
4087// | | |<-------------|
4088// | | RESTNotif1 | |
4089// | |<----------------| |
4090// | | | |
4091// | RESTSubReq2 | |
4092// |------------------------------>| |
4093// | | | |
4094// | RESTSubResp2 | |
4095// |<------------------------------| |
4096// | | | |
4097// | | RESTNotif2 | |
4098// |<------------------------------| |
4099// | | | |
4100// | | Submgr restart |
4101// | | | |
4102// | | RESTSubDelReq1 | |
4103// | |---------------->| |
4104// | | | |
4105// | | RESTSubDelResp1 | |
4106// | |<----------------| |
4107// | | | |
4108// | | Submgr restart |
4109// | | | |
4110// | RESTSubDelReq2 | |
4111// |------------------------------>| |
4112// | | | |
4113// | RESTSubDelResp2 | |
4114// |<------------------------------| |
4115// | | | |
4116// | | | SubDelReq2 |
4117// | | |------------->|
4118// | | | |
4119// | | | SubDelResp2 |
4120// | | |<-------------|
4121// | | | |
4122//
4123//-----------------------------------------------------------------------------
4124func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4125 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4126
4127 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4128 Counter{cSubReqFromXapp, 2},
4129 Counter{cSubReqToE2, 1},
4130 Counter{cSubRespFromE2, 1},
4131 Counter{cSubRespToXapp, 2},
4132 Counter{cMergedSubscriptions, 1},
4133 Counter{cUnmergedSubscriptions, 1},
4134 Counter{cSubDelReqFromXapp, 2},
4135 Counter{cSubDelReqToE2, 1},
4136 Counter{cSubDelRespFromE2, 1},
4137 Counter{cSubDelRespToXapp, 2},
4138 })
4139
4140 // Remove possible existing subscription
4141 mainCtrl.removeExistingSubscriptions(t)
4142
4143 var params *teststube2ap.RESTSubsReqParams = nil
4144
4145 // Create subscription 1
4146 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4147 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4148
4149 // Create subscription 2 with same action
4150 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4151 params.SetMeid("RAN_NAME_1")
4152 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4153 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4154 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4155 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4156 e2SubsId2 := <-xappConn2.RESTNotification
4157 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4158
4159 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4160
4161 // When SDL support for the REST Interface is added
4162 // the submgr restart statement below should be removed
4163 // from the comment.
4164
4165 // mainCtrl.SimulateRestart(t)
4166 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4167
4168 // Delete subscription 1
4169 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4170
4171 // When SDL support for the REST Interface is added
4172 // the submgr restart statement below should be removed
4173 // from the comment.
4174
4175 // mainCtrl.SimulateRestart(t)
4176 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4177
4178 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4179
4180 // Delete subscription 2
4181 deleteXapp2Subscription(t, &restSubId2)
4182
4183 //Wait that subs is cleaned
4184 waitSubsCleanup(t, e2SubsId2, 10)
4185
4186 mainCtrl.VerifyCounterValues(t)
4187}
4188
4189//-----------------------------------------------------------------------------
4190// TestRESTReportSubReqAndSubDelOk
4191//
4192// stub stub
4193// +-------+ +---------+ +---------+
4194// | xapp | | submgr | | e2term |
4195// +-------+ +---------+ +---------+
4196// | | |
4197// | RestSubReq | |
4198// |---------------->| |
4199// | | |
4200// | RESTSubResp | |
4201// |<----------------| |
4202// | | |
4203// | | SubReq |
4204// | |------------->|
4205// | | |
4206// | | SubResp |
4207// | |<-------------|
4208// | RESTNotif | |
4209// |<----------------| |
4210// | | SubReq |
4211// | |------------->|
4212// | | |
4213// | | SubResp |
4214// | |<-------------|
4215// | RESTNotif | |
4216// |<----------------| |
4217// | ... | ... |
4218// | | |
4219// | | |
4220// | RESTSubDelReq | |
4221// |---------------->| |
4222// | | |
4223// | | SubDelReq |
4224// | |------------->|
4225// | | |
4226// | | SubDelResp |
4227// | |<-------------|
4228// | | |
4229// | RESTSubDelResp| |
4230// |<----------------| |
4231//
4232//-----------------------------------------------------------------------------
4233func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4234 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4235 subReqCount := 1
4236 parameterSet := 1 // E2SM-gNB-X2
4237 actionDefinitionPresent := true
4238 actionParamCount := 1
4239 testIndex := 1
4240 RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
4241}
4242
4243func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
4244 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
4245
4246 // Req
4247 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4248 restSubId := xappConn1.SendRESTSubsReq(t, params)
4249
4250 var e2SubsId []uint32
4251 for i := 0; i < subReqCount; i++ {
4252 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4253 xappConn1.ExpectRESTNotification(t, restSubId)
4254
4255 e2termConn1.SendSubsResp(t, crereq, cremsg)
4256 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4257 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4258 e2SubsId = append(e2SubsId, instanceId)
4259 resp, _ := xapp.Subscription.QuerySubscriptions()
4260 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4261 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4262 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4263
4264 }
4265
4266 // Del
4267 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4268
4269 for i := 0; i < subReqCount; i++ {
4270 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4271 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4272 }
4273
4274 // Wait that subs is cleaned
4275 for i := 0; i < subReqCount; i++ {
4276 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4277 }
4278
4279 xappConn1.TestMsgChanEmpty(t)
4280 e2termConn1.TestMsgChanEmpty(t)
4281 mainCtrl.wait_registry_empty(t, 10)
4282}
4283
4284/*
4285func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4286 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4287
4288 subReqCount := 2
4289 actionDefinitionPresent := true
4290 policyParamCount := 1
4291 testIndex := 1
4292 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4293
4294 subReqCount = 19
4295 actionDefinitionPresent = false
4296 policyParamCount = 0
4297 testIndex = 2
4298 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4299}
4300*/
4301func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
4302 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
4303
4304 // Req
4305 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4306 restSubId := xappConn1.SendRESTSubsReq(t, params)
4307 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
4308 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4309
4310 var e2SubsId []uint32
4311 for i := 0; i < subReqCount; i++ {
4312 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4313 xappConn1.ExpectRESTNotification(t, restSubId)
4314 e2termConn1.SendSubsResp(t, crereq, cremsg)
4315 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4316 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4317 e2SubsId = append(e2SubsId, instanceId)
4318 }
4319
4320 // Del
4321 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4322
4323 for i := 0; i < subReqCount; i++ {
4324 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4325 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4326 }
4327
4328 // Wait that subs is cleaned
4329 for i := 0; i < subReqCount; i++ {
4330 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4331 }
4332 xappConn1.TestMsgChanEmpty(t)
4333 e2termConn1.TestMsgChanEmpty(t)
4334 mainCtrl.wait_registry_empty(t, 10)
4335}
4336
4337/*
4338func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4339
4340 subReqCount := 2
4341
4342 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4343 Counter{cSubReqFromXapp, 1},
4344 Counter{cSubReqToE2, 2},
4345 Counter{cSubRespFromE2, 2},
4346 Counter{cSubRespToXapp, 2},
4347 Counter{cSubDelReqFromXapp, 1},
4348 Counter{cSubDelReqToE2, 2},
4349 Counter{cSubDelRespFromE2, 2},
4350 Counter{cSubDelRespToXapp, 1},
4351 })
4352
4353 // Req
4354 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4355 restSubId := xappConn1.SendRESTSubsReq(t, params)
4356 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4357
4358 assert.Equal(t, len(e2SubsIds), 2)
4359
4360 // Del
4361 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4362 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4363
4364 xappConn1.TestMsgChanEmpty(t)
4365 e2termConn1.TestMsgChanEmpty(t)
4366 mainCtrl.wait_registry_empty(t, 10)
4367
4368 mainCtrl.VerifyCounterValues(t)
4369}
4370*/
4371/*
4372func 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}
4403*/
4404/*
4405func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4406
4407 subReqCount := 2
4408 parameterSet := 1
4409 actionDefinitionPresent := true
4410 actionParamCount := 1
4411
4412 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4413 Counter{cSubReqFromXapp, 1},
4414 Counter{cSubReqToE2, uint64(subReqCount)},
4415 Counter{cSubRespFromE2, uint64(subReqCount)},
4416 Counter{cSubRespToXapp, uint64(subReqCount)},
4417 Counter{cSubDelReqFromXapp, 1},
4418 Counter{cSubDelReqToE2, uint64(subReqCount)},
4419 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4420 Counter{cSubDelRespToXapp, 1},
4421 })
4422
4423 // Req
4424 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4425 restSubId := xappConn1.SendRESTSubsReq(t, params)
4426 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4427
4428 assert.Equal(t, len(e2SubsIds), subReqCount)
4429
4430 // Del
4431 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4432 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4433
4434 xappConn1.TestMsgChanEmpty(t)
4435 e2termConn1.TestMsgChanEmpty(t)
4436 mainCtrl.wait_registry_empty(t, 10)
4437
4438 mainCtrl.VerifyCounterValues(t)
4439}
4440*/
4441/*
4442func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4443
4444 subReqCount := 2
4445 parameterSet := 1
4446 actionDefinitionPresent := false
4447 actionParamCount := 0
4448
4449 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4450 Counter{cSubReqFromXapp, 1},
4451 Counter{cSubReqToE2, uint64(subReqCount)},
4452 Counter{cSubRespFromE2, uint64(subReqCount)},
4453 Counter{cSubRespToXapp, uint64(subReqCount)},
4454 Counter{cSubDelReqFromXapp, 1},
4455 Counter{cSubDelReqToE2, uint64(subReqCount)},
4456 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4457 Counter{cSubDelRespToXapp, 1},
4458 })
4459
4460 // Req
4461 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4462 restSubId := xappConn1.SendRESTSubsReq(t, params)
4463 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4464
4465 assert.Equal(t, len(e2SubsIds), subReqCount)
4466
4467 // Del
4468 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4469 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4470
4471 xappConn1.TestMsgChanEmpty(t)
4472 e2termConn1.TestMsgChanEmpty(t)
4473 mainCtrl.wait_registry_empty(t, 10)
4474
4475 mainCtrl.VerifyCounterValues(t)
4476}
4477*/
4478/*
4479func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4480
4481 subReqCount := 19
4482 parameterSet := 1
4483 actionDefinitionPresent := false
4484 actionParamCount := 0
4485
4486 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4487 Counter{cSubReqFromXapp, 1},
4488 Counter{cSubReqToE2, uint64(subReqCount)},
4489 Counter{cSubRespFromE2, uint64(subReqCount)},
4490 Counter{cSubRespToXapp, uint64(subReqCount)},
4491 Counter{cSubDelReqFromXapp, 1},
4492 Counter{cSubDelReqToE2, uint64(subReqCount)},
4493 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4494 Counter{cSubDelRespToXapp, 1},
4495 })
4496
4497 // Req
4498 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4499 restSubId := xappConn1.SendRESTSubsReq(t, params)
4500 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4501
4502 assert.Equal(t, len(e2SubsIds), subReqCount)
4503
4504 // Del
4505 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4506 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4507
4508 xappConn1.TestMsgChanEmpty(t)
4509 e2termConn1.TestMsgChanEmpty(t)
4510 mainCtrl.wait_registry_empty(t, 10)
4511
4512 mainCtrl.VerifyCounterValues(t)
4513}
4514*/
4515////////////////////////////////////////////////////////////////////////////////////
4516// Services for UT cases
4517////////////////////////////////////////////////////////////////////////////////////
4518const subReqCount int = 1
4519const parameterSet = 1
4520const actionDefinitionPresent bool = true
4521const actionParamCount int = 1
4522const policyParamCount int = 1
4523const host string = "localhost"
4524
4525func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
4526 if params == nil {
4527 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4528 }
4529 restSubId := fromXappConn.SendRESTSubsReq(t, params)
4530 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
4531
4532 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
4533 fromXappConn.ExpectRESTNotification(t, restSubId)
4534 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
4535 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
4536 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4537
4538 return restSubId, e2SubsId
4539}
4540
4541func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
4542
4543 params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4544 if meid != "" {
4545 params.SetMeid(meid)
4546 }
4547 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4548 restSubId := xappConn2.SendRESTSubsReq(t, params)
4549 xappConn2.ExpectRESTNotification(t, restSubId)
4550 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
4551 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
4552 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4553
4554 return restSubId, e2SubsId
4555}
4556
4557func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
4558 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4559 restSubId := xappConn1.SendRESTSubsReq(t, params)
4560 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
4561
4562 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4563 xappConn1.ExpectRESTNotification(t, restSubId)
4564 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4565 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4566 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4567
4568 return restSubId, e2SubsId
4569}
4570
4571func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
4572 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4573 restSubId := xappConn1.SendRESTSubsReq(t, params)
4574
4575 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4576 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4577 fparams1.Set(crereq1)
4578 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4579
4580 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4581 xappConn1.ExpectRESTNotification(t, restSubId)
4582 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4583 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4584 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
4585
4586 return restSubId, e2SubsId
4587}
4588
4589func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
4590 fromXappConn.SendRESTSubsDelReq(t, restSubId)
4591 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
4592 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
4593}
4594
4595func deleteXapp1Subscription(t *testing.T, restSubId *string) {
4596 xappConn1.SendRESTSubsDelReq(t, restSubId)
4597 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4598 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4599}
4600
4601func deleteXapp2Subscription(t *testing.T, restSubId *string) {
4602 xappConn2.SendRESTSubsDelReq(t, restSubId)
4603 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4604 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4605}
4606
4607func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
4608 resp, _ := xapp.Subscription.QuerySubscriptions()
4609 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
4610 assert.Equal(t, resp[0].Meid, meid)
4611 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
4612}
4613
4614func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
4615 //Wait that subs is cleaned
4616 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
4617
4618 xappConn1.TestMsgChanEmpty(t)
4619 xappConn2.TestMsgChanEmpty(t)
4620 e2termConn1.TestMsgChanEmpty(t)
4621 mainCtrl.wait_registry_empty(t, timeout)
4622}
4623
4624func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
4625
4626 var e2SubsId []uint32
4627
4628 for i := 0; i < count; i++ {
4629 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
4630 crereq, cremsg := toE2termConn.RecvSubsReq(t)
4631 fromXappConn.ExpectRESTNotification(t, restSubId)
4632 toE2termConn.SendSubsResp(t, crereq, cremsg)
4633 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
4634 e2SubsId = append(e2SubsId, instanceId)
4635 xapp.Logger.Info("TEST: %v", e2SubsId)
4636 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
4637 <-time.After(100 * time.Millisecond)
4638 }
4639 return e2SubsId
4640}
4641
4642func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
4643
4644 for i := 0; i < len(e2SubsIds); i++ {
4645 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
4646 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
4647 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
4648 <-time.After(1 * time.Second)
4649 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
4650 <-time.After(100 * time.Millisecond)
4651 }
4652
4653 // Wait that subs is cleaned
4654 for i := 0; i < len(e2SubsIds); i++ {
4655 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
4656 }
4657
4658}