blob: f4c71594d5fc9f3f9193f7edab133c4d3d296a7a [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// | | | |
108func TestSubReqAndRouteUpdateNok(t *testing.T) {
109 CaseBegin("TestSubReqAndRouteUpdateNok")
110
111 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200112 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
113 Counter{cSubReqFromXapp, 2},
114 Counter{cSubReqToE2, 1},
115 Counter{cSubRespFromE2, 1},
116 Counter{cSubRespToXapp, 1},
117 Counter{cRouteCreateUpdateFail, 1},
118 Counter{cSubDelReqFromXapp, 1},
119 Counter{cSubDelReqToE2, 1},
120 Counter{cSubDelRespFromE2, 1},
121 Counter{cSubDelRespToXapp, 1},
122 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200123
124 cretrans := xappConn1.SendSubsReq(t, nil, nil)
125 crereq, cremsg := e2termConn1.RecvSubsReq(t)
126 e2termConn1.SendSubsResp(t, crereq, cremsg)
127 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
128
129 resp, _ := xapp.Subscription.QuerySubscriptions()
130 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
131 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
132 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
133
134 waiter := rtmgrHttp.AllocNextEvent(false)
135 newSubsId := mainCtrl.get_registry_next_subid(t)
136 xappConn2.SendSubsReq(t, nil, nil)
137 waiter.WaitResult(t)
138
139 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
140 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
141
142 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
143 xappConn1.RecvSubsDelResp(t, deltrans)
144
145 //Wait that subs is cleaned
146 mainCtrl.wait_subs_clean(t, newSubsId, 10)
147 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
148
149 xappConn1.TestMsgChanEmpty(t)
150 xappConn2.TestMsgChanEmpty(t)
151 e2termConn1.TestMsgChanEmpty(t)
152 mainCtrl.wait_registry_empty(t, 10)
153
154 mainCtrl.VerifyCounterValues(t)
155}
156
157//-----------------------------------------------------------------------------
158// TestSubDelReqAndRouteDeleteNok
159//
160// stub stub
161// +-------+ +---------+ +---------+ +---------+
162// | xapp | | submgr | | e2term | | rtmgr |
163// +-------+ +---------+ +---------+ +---------+
164// | | | |
165// | [SUBS CREATE] | |
166// | | | |
167// | | | |
168// | | | |
169// | SubDelReq | | |
170// |------------->| | |
171// | | SubDelReq | |
172// | |------------->| |
173// | | SubDelRsp | |
174// | |<-------------| |
175// | SubDelRsp | | |
176// |<-------------| | |
177// | | RouteDelete | |
178// | |---------------------------->|
179// | | | |
180// | | RouteDelete | |
181// | | status:400 | |
182// | |<----------------------------|
183// | | | |
184func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
185 CaseBegin("TestSubDelReqAndRouteDeleteNok")
186
187 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200188 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
189 Counter{cSubReqFromXapp, 1},
190 Counter{cSubReqToE2, 1},
191 Counter{cSubRespFromE2, 1},
192 Counter{cSubRespToXapp, 1},
193 Counter{cSubDelReqFromXapp, 1},
194 Counter{cRouteDeleteFail, 1},
195 Counter{cSubDelReqToE2, 1},
196 Counter{cSubDelRespFromE2, 1},
197 Counter{cSubDelRespToXapp, 1},
198 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200199
200 cretrans := xappConn1.SendSubsReq(t, nil, nil)
201 crereq, cremsg := e2termConn1.RecvSubsReq(t)
202 e2termConn1.SendSubsResp(t, crereq, cremsg)
203 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
204
205 resp, _ := xapp.Subscription.QuerySubscriptions()
206 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
207 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
208 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
209
210 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
211 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
212
213 waiter := rtmgrHttp.AllocNextEvent(false)
214 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
215 waiter.WaitResult(t)
216
217 xappConn1.RecvSubsDelResp(t, deltrans)
218
219 //Wait that subs is cleaned
220 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
221
222 xappConn1.TestMsgChanEmpty(t)
223 xappConn2.TestMsgChanEmpty(t)
224 e2termConn1.TestMsgChanEmpty(t)
225 mainCtrl.wait_registry_empty(t, 10)
226
227 mainCtrl.VerifyCounterValues(t)
228}
229
230//-----------------------------------------------------------------------------
231// TestSubMergeDelAndRouteUpdateNok
232// stub stub
233// +-------+ +-------+ +---------+ +---------+
234// | xapp2 | | xapp1 | | submgr | | e2term |
235// +-------+ +-------+ +---------+ +---------+
236// | | | |
237// | | | |
238// | | | |
239// | | SubReq1 | |
240// | |------------->| |
241// | | | |
242// | | | SubReq1 |
243// | | |------------->|
244// | | | SubResp1 |
245// | | |<-------------|
246// | | SubResp1 | |
247// | |<-------------| |
248// | | | |
249// | SubReq2 | |
250// |--------------------------->| |
251// | | | |
252// | SubResp2 | |
253// |<---------------------------| |
254// | | | |
255// | | SubDelReq 1 | |
256// | |------------->| |
257// | | | RouteUpdate |
258// | | |-----> rtmgr |
259// | | | |
260// | | | RouteUpdate |
261// | | | status:400 |
262// | | |<----- rtmgr |
263// | | | |
264// | | SubDelResp 1 | |
265// | |<-------------| |
266// | | | |
267// | SubDelReq 2 | |
268// |--------------------------->| |
269// | | | |
270// | | | SubDelReq 2 |
271// | | |------------->|
272// | | | |
273// | | | SubDelReq 2 |
274// | | |------------->|
275// | | | |
276// | SubDelResp 2 | |
277// |<---------------------------| |
278//
279//-----------------------------------------------------------------------------
280func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
281 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
282
283 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
285 Counter{cSubReqFromXapp, 2},
286 Counter{cSubReqToE2, 1},
287 Counter{cSubRespFromE2, 1},
288 Counter{cSubRespToXapp, 2},
289 Counter{cSubDelReqFromXapp, 2},
290 Counter{cRouteDeleteUpdateFail, 1},
291 Counter{cSubDelReqToE2, 1},
292 Counter{cSubDelRespFromE2, 1},
293 Counter{cSubDelRespToXapp, 2},
294 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200295
296 //Req1
297 rparams1 := &teststube2ap.E2StubSubsReqParams{}
298 rparams1.Init()
299 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
300 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
301 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
302 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
303
304 //Req2
305 rparams2 := &teststube2ap.E2StubSubsReqParams{}
306 rparams2.Init()
307 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
308 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
309
310 resp, _ := xapp.Subscription.QuerySubscriptions()
311 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
312 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
313 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
314
315 //Del1
316 waiter := rtmgrHttp.AllocNextEvent(false)
317 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
318 waiter.WaitResult(t)
319
320 xappConn1.RecvSubsDelResp(t, deltrans1)
321
322 //Del2
323 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
324 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
325 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
326 xappConn2.RecvSubsDelResp(t, deltrans2)
327 //Wait that subs is cleaned
328 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
329
330 xappConn1.TestMsgChanEmpty(t)
331 xappConn2.TestMsgChanEmpty(t)
332 e2termConn1.TestMsgChanEmpty(t)
333 mainCtrl.wait_registry_empty(t, 10)
334
335 mainCtrl.VerifyCounterValues(t)
336}
337
338//-----------------------------------------------------------------------------
339
340//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200341// TestSubReqAndSubDelOk
342//
343// stub stub
344// +-------+ +---------+ +---------+
345// | xapp | | submgr | | e2term |
346// +-------+ +---------+ +---------+
347// | | |
348// | SubReq | |
349// |------------->| |
350// | | |
351// | | SubReq |
352// | |------------->|
353// | | |
354// | | SubResp |
355// | |<-------------|
356// | | |
357// | SubResp | |
358// |<-------------| |
359// | | |
360// | | |
361// | SubDelReq | |
362// |------------->| |
363// | | |
364// | | SubDelReq |
365// | |------------->|
366// | | |
367// | | SubDelResp |
368// | |<-------------|
369// | | |
370// | SubDelResp | |
371// |<-------------| |
372//
373//-----------------------------------------------------------------------------
374func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200375 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200376
Anssi Mannila4abf1802021-01-28 13:06:46 +0200377 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200378 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
379 Counter{cSubReqFromXapp, 1},
380 Counter{cSubReqToE2, 1},
381 Counter{cSubRespFromE2, 1},
382 Counter{cSubRespToXapp, 1},
383 Counter{cSubDelReqFromXapp, 1},
384 Counter{cSubDelReqToE2, 1},
385 Counter{cSubDelRespFromE2, 1},
386 Counter{cSubDelRespToXapp, 1},
387 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200388
389 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200390 crereq, cremsg := e2termConn1.RecvSubsReq(t)
391 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200392 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200393
394 resp, _ := xapp.Subscription.QuerySubscriptions()
395 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
396 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
397 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
398
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200399 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200400 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200401
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200402 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200403 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200404
405 //Wait that subs is cleaned
406 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
407
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200408 xappConn1.TestMsgChanEmpty(t)
409 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200410 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200411 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200412
413 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200414}
415
416//-----------------------------------------------------------------------------
417// TestSubReqRetransmission
418//
419// stub stub
420// +-------+ +---------+ +---------+
421// | xapp | | submgr | | e2term |
422// +-------+ +---------+ +---------+
423// | | |
424// | SubReq | |
425// |------------->| |
426// | | |
427// | | SubReq |
428// | |------------->|
429// | | |
430// | SubReq | |
431// | (retrans) | |
432// |------------->| |
433// | | |
434// | | SubResp |
435// | |<-------------|
436// | | |
437// | SubResp | |
438// |<-------------| |
439// | | |
440// | [SUBS DELETE] |
441// | | |
442//
443//-----------------------------------------------------------------------------
444func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200445 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200446
447 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200448 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200449 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200450
451 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200452 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200453 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
454
Juha Hyttinen1683f912020-04-17 10:39:57 +0300455 // hack as there is no real way to see has message be handled.
456 // Previuos counter check just tells that is has been received by submgr
457 // --> artificial delay
458 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200459 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200460 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200461
462 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200463 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200464 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
465 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200466 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200467
468 //Wait that subs is cleaned
469 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
470
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200471 xappConn1.TestMsgChanEmpty(t)
472 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200473 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200474 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200475}
476
477//-----------------------------------------------------------------------------
478// TestSubDelReqRetransmission
479//
480// stub stub
481// +-------+ +---------+ +---------+
482// | xapp | | submgr | | e2term |
483// +-------+ +---------+ +---------+
484// | | |
485// | [SUBS CREATE] |
486// | | |
487// | | |
488// | SubDelReq | |
489// |------------->| |
490// | | |
491// | | SubDelReq |
492// | |------------->|
493// | | |
494// | SubDelReq | |
495// | (same sub) | |
496// | (same xid) | |
497// |------------->| |
498// | | |
499// | | SubDelResp |
500// | |<-------------|
501// | | |
502// | SubDelResp | |
503// |<-------------| |
504//
505//-----------------------------------------------------------------------------
506func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200507 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200508
509 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200510 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200511 crereq, cremsg := e2termConn1.RecvSubsReq(t)
512 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200513 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200514
515 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200516 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200517 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200518
519 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200520 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200521 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
522
Juha Hyttinen1683f912020-04-17 10:39:57 +0300523 // hack as there is no real way to see has message be handled.
524 // Previuos counter check just tells that is has been received by submgr
525 // --> artificial delay
526 <-time.After(1 * time.Second)
527
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200528 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200529 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200530
531 //Wait that subs is cleaned
532 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
533
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200534 xappConn1.TestMsgChanEmpty(t)
535 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200536 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200537 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200538}
539
540//-----------------------------------------------------------------------------
541// TestSubDelReqCollision
542//
543// stub stub
544// +-------+ +---------+ +---------+
545// | xapp | | submgr | | e2term |
546// +-------+ +---------+ +---------+
547// | | |
548// | [SUBS CREATE] |
549// | | |
550// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200551// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200552// |------------->| |
553// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200554// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200555// | |------------->|
556// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200557// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200558// | (same sub) | |
559// | (diff xid) | |
560// |------------->| |
561// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200562// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200563// | |<-------------|
564// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200565// | SubDelResp 1 | |
566// |<-------------| |
567// | | |
568// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200569// |<-------------| |
570//
571//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200572
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200574 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200575
576 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200577 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200578 crereq, cremsg := e2termConn1.RecvSubsReq(t)
579 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200580 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200581
582 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200583 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200584 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200585
Juha Hyttinen3944a222020-01-24 11:51:46 +0200586 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200587 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200588 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
589 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200590 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
591
Juha Hyttinen1683f912020-04-17 10:39:57 +0300592 // hack as there is no real way to see has message be handled.
593 // Previuos counter check just tells that is has been received by submgr
594 // --> artificial delay
595 <-time.After(1 * time.Second)
596
Juha Hyttinen3944a222020-01-24 11:51:46 +0200597 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200598 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200599
600 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200601 xappConn1.RecvSubsDelResp(t, nil)
602 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200603
604 //Wait that subs is cleaned
605 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
606
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200607 xappConn1.TestMsgChanEmpty(t)
608 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200609 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200610 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200611}
612
613//-----------------------------------------------------------------------------
614// TestSubReqAndSubDelOkTwoParallel
615//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200616// stub stub stub
617// +-------+ +-------+ +---------+ +---------+
618// | xapp | | xapp | | submgr | | e2term |
619// +-------+ +-------+ +---------+ +---------+
620// | | | |
621// | | | |
622// | | | |
623// | | SubReq1 | |
624// | |------------->| |
625// | | | |
626// | | | SubReq1 |
627// | | |------------->|
628// | | | |
629// | SubReq2 | |
630// |------------------------>| |
631// | | | |
632// | | | SubReq2 |
633// | | |------------->|
634// | | | |
635// | | | SubResp1 |
636// | | |<-------------|
637// | | SubResp1 | |
638// | |<-------------| |
639// | | | |
640// | | | SubResp2 |
641// | | |<-------------|
642// | SubResp2 | |
643// |<------------------------| |
644// | | | |
645// | | [SUBS 1 DELETE] |
646// | | | |
647// | | [SUBS 2 DELETE] |
648// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200649//
650//-----------------------------------------------------------------------------
651func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200652 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200653
654 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200655 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200656 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200657 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200658 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200659
660 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200661 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200662 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300663
664 rparams2.Req.EventTriggerDefinition.Data.Length = 1
665 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
666 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
667
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200668 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200669 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200670
671 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200672 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200673 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200674
675 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200676 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200677 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200678
679 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200680 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200681 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
682 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200683 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200684 //Wait that subs is cleaned
685 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
686
687 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200688 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200689 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
690 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200691 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200692 //Wait that subs is cleaned
693 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
694
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200695 xappConn1.TestMsgChanEmpty(t)
696 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200697 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200698 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200699}
700
701//-----------------------------------------------------------------------------
702// TestSameSubsDiffRan
703// Same subscription to different RANs
704//
705// stub stub
706// +-------+ +---------+ +---------+
707// | xapp | | submgr | | e2term |
708// +-------+ +---------+ +---------+
709// | | |
710// | | |
711// | | |
712// | SubReq(r1) | |
713// |------------->| |
714// | | |
715// | | SubReq(r1) |
716// | |------------->|
717// | | |
718// | | SubResp(r1) |
719// | |<-------------|
720// | | |
721// | SubResp(r1) | |
722// |<-------------| |
723// | | |
724// | SubReq(r2) | |
725// |------------->| |
726// | | |
727// | | SubReq(r2) |
728// | |------------->|
729// | | |
730// | | SubResp(r2) |
731// | |<-------------|
732// | | |
733// | SubResp(r2) | |
734// |<-------------| |
735// | | |
736// | [SUBS r1 DELETE] |
737// | | |
738// | [SUBS r2 DELETE] |
739// | | |
740//
741//-----------------------------------------------------------------------------
742func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200743 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200744
745 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200746 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
747 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200748 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
749 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200750 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200751
752 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200753 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
754 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200755 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
756 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200757 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200758
759 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200760 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
761 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200762 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
763 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200764 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200765 //Wait that subs is cleaned
766 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
767
768 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200769 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
770 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200771 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
772 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200773 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200774 //Wait that subs is cleaned
775 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
776
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200777 xappConn1.TestMsgChanEmpty(t)
778 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200779 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200780 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200781}
782
783//-----------------------------------------------------------------------------
784// TestSubReqRetryInSubmgr
785//
786// stub stub
787// +-------+ +---------+ +---------+
788// | xapp | | submgr | | e2term |
789// +-------+ +---------+ +---------+
790// | | |
791// | SubReq | |
792// |------------->| |
793// | | |
794// | | SubReq |
795// | |------------->|
796// | | |
797// | | |
798// | | SubReq |
799// | |------------->|
800// | | |
801// | | SubResp |
802// | |<-------------|
803// | | |
804// | SubResp | |
805// |<-------------| |
806// | | |
807// | [SUBS DELETE] |
808// | | |
809//
810//-----------------------------------------------------------------------------
811
812func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200813 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200814
815 // Init counter check
816 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
817 Counter{cSubReqFromXapp, 1},
818 Counter{cSubReqToE2, 1},
819 Counter{cSubReReqToE2, 1},
820 Counter{cSubRespFromE2, 1},
821 Counter{cSubRespToXapp, 1},
822 Counter{cSubDelReqFromXapp, 1},
823 Counter{cSubDelReqToE2, 1},
824 Counter{cSubDelRespFromE2, 1},
825 Counter{cSubDelRespToXapp, 1},
826 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200827
828 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200829 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200830
831 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200832 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200833
834 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200835 crereq, cremsg := e2termConn1.RecvSubsReq(t)
836 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200837
838 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200839 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200840
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200842 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
843 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200844 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200845
846 // Wait that subs is cleaned
847 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
848
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200849 xappConn1.TestMsgChanEmpty(t)
850 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200851 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200852 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200853
854 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200855}
856
857//-----------------------------------------------------------------------------
858// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
859//
860// stub stub
861// +-------+ +---------+ +---------+
862// | xapp | | submgr | | e2term |
863// +-------+ +---------+ +---------+
864// | | |
865// | SubReq | |
866// |------------->| |
867// | | |
868// | | SubReq |
869// | |------------->|
870// | | |
871// | | |
872// | | SubReq |
873// | |------------->|
874// | | |
875// | | SubDelReq |
876// | |------------->|
877// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200878// | | SubDelResp |
879// | |<-------------|
880// | | |
881//
882//-----------------------------------------------------------------------------
883
884func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200885 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200886
887 // Init counter check
888 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
889 Counter{cSubReqFromXapp, 1},
890 Counter{cSubReqToE2, 1},
891 Counter{cSubReReqToE2, 1},
892 Counter{cSubReqTimerExpiry, 2},
893 Counter{cSubDelReqToE2, 1},
894 Counter{cSubDelRespFromE2, 1},
895 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200896
897 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200898 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200899
900 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200901 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200902
903 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200904 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200905
906 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200907 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
908 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200909
910 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300911 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200912
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200913 xappConn1.TestMsgChanEmpty(t)
914 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200915 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200916 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200917
918 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200919}
920
921//-----------------------------------------------------------------------------
922// TestSubReqTwoRetriesNoRespAtAllInSubmgr
923//
924// stub stub
925// +-------+ +---------+ +---------+
926// | xapp | | submgr | | e2term |
927// +-------+ +---------+ +---------+
928// | | |
929// | SubReq | |
930// |------------->| |
931// | | |
932// | | SubReq |
933// | |------------->|
934// | | |
935// | | |
936// | | SubReq |
937// | |------------->|
938// | | |
939// | | SubDelReq |
940// | |------------->|
941// | | |
942// | | |
943// | | SubDelReq |
944// | |------------->|
945// | | |
946// | | |
947//
948//-----------------------------------------------------------------------------
949
950func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200951 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200952
953 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
954 Counter{cSubReqFromXapp, 1},
955 Counter{cSubReqToE2, 1},
956 Counter{cSubReReqToE2, 1},
957 Counter{cSubReqTimerExpiry, 2},
958 Counter{cSubDelReqToE2, 1},
959 Counter{cSubDelReReqToE2, 1},
960 Counter{cSubDelReqTimerExpiry, 2},
961 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200962
963 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200964 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200965
966 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200967 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200968
969 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200970 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200971
972 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200973 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200974
975 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200976 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200977
978 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300979 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200980
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200981 xappConn1.TestMsgChanEmpty(t)
982 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200983 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200984 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200985
986 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200987}
988
989//-----------------------------------------------------------------------------
990// TestSubReqSubFailRespInSubmgr
991//
992// stub stub
993// +-------+ +---------+ +---------+
994// | xapp | | submgr | | e2term |
995// +-------+ +---------+ +---------+
996// | | |
997// | SubReq | |
998// |------------->| |
999// | | |
1000// | | SubReq |
1001// | |------------->|
1002// | | |
1003// | | SubFail |
1004// | |<-------------|
1005// | | |
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001006// | | SubDelReq |
1007// | |------------->|
1008// | | |
1009// | | SubDelResp |
1010// | |<-------------|
1011// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001012// | SubFail | |
1013// |<-------------| |
1014// | | |
1015//
1016//-----------------------------------------------------------------------------
1017
1018func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001019 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001020
1021 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1022 Counter{cSubReqFromXapp, 1},
1023 Counter{cSubReqToE2, 1},
1024 Counter{cSubFailFromE2, 1},
1025 Counter{cSubDelReqToE2, 1},
1026 Counter{cSubDelRespFromE2, 1},
1027 Counter{cSubFailToXapp, 1},
1028 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001029
1030 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001031 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001032
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001033 // E2t: Receive SubsReq and send SubsFail (first)
1034 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1035 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1036 fparams1.Set(crereq1)
1037 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1038
1039 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1040 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1041 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1042
1043 // Xapp: Receive SubsFail
1044 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1045
1046 // Wait that subs is cleaned
1047 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1048
1049 xappConn1.TestMsgChanEmpty(t)
1050 xappConn2.TestMsgChanEmpty(t)
1051 e2termConn1.TestMsgChanEmpty(t)
1052 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001053
1054 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001055}
1056
1057//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001058// TestSubDelReqRetryInSubmgr
1059//
1060// stub stub
1061// +-------+ +---------+ +---------+
1062// | xapp | | submgr | | e2term |
1063// +-------+ +---------+ +---------+
1064// | | |
1065// | [SUBS CREATE] |
1066// | | |
1067// | | |
1068// | SubDelReq | |
1069// |------------->| |
1070// | | |
1071// | | SubDelReq |
1072// | |------------->|
1073// | | |
1074// | | SubDelReq |
1075// | |------------->|
1076// | | |
1077// | | SubDelResp |
1078// | |<-------------|
1079// | | |
1080// | SubDelResp | |
1081// |<-------------| |
1082//
1083//-----------------------------------------------------------------------------
1084
1085func TestSubDelReqRetryInSubmgr(t *testing.T) {
1086
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001087 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001088
1089 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001090 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001091 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1092 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001093 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001094
1095 // Subs Delete
1096 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001097 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001098
1099 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001100 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001101
1102 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001103 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1104 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001105
1106 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001107 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001108
1109 // Wait that subs is cleaned
1110 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1111
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001112 xappConn1.TestMsgChanEmpty(t)
1113 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001114 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001115 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001116}
1117
1118//-----------------------------------------------------------------------------
1119// TestSubDelReqTwoRetriesNoRespInSubmgr
1120//
1121// stub stub
1122// +-------+ +---------+ +---------+
1123// | xapp | | submgr | | e2term |
1124// +-------+ +---------+ +---------+
1125// | | |
1126// | [SUBS CREATE] |
1127// | | |
1128// | | |
1129// | SubDelReq | |
1130// |------------->| |
1131// | | |
1132// | | SubDelReq |
1133// | |------------->|
1134// | | |
1135// | | SubDelReq |
1136// | |------------->|
1137// | | |
1138// | | |
1139// | SubDelResp | |
1140// |<-------------| |
1141//
1142//-----------------------------------------------------------------------------
1143
1144func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1145
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001146 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147
1148 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001149 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001150 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1151 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001152 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001153
1154 // Subs Delete
1155 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001156 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001157
1158 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001159 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001160
1161 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001162 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001163
1164 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001165 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001166
1167 // Wait that subs is cleaned
1168 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1169
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001170 xappConn1.TestMsgChanEmpty(t)
1171 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001172 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001173 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001174}
1175
1176//-----------------------------------------------------------------------------
1177// TestSubDelReqSubDelFailRespInSubmgr
1178//
1179// stub stub
1180// +-------+ +---------+ +---------+
1181// | xapp | | submgr | | e2term |
1182// +-------+ +---------+ +---------+
1183// | | |
1184// | [SUBS CREATE] |
1185// | | |
1186// | | |
1187// | SubDelReq | |
1188// |------------->| |
1189// | | |
1190// | | SubDelReq |
1191// | |------------->|
1192// | | |
1193// | | SubDelFail |
1194// | |<-------------|
1195// | | |
1196// | SubDelResp | |
1197// |<-------------| |
1198// | | |
1199//
1200//-----------------------------------------------------------------------------
1201
1202func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001203 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001204
1205 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1206 Counter{cSubReqFromXapp, 1},
1207 Counter{cSubReqToE2, 1},
1208 Counter{cSubRespFromE2, 1},
1209 Counter{cSubRespToXapp, 1},
1210 Counter{cSubDelReqFromXapp, 1},
1211 Counter{cSubDelReqToE2, 1},
1212 Counter{cSubDelFailFromE2, 1},
1213 Counter{cSubDelRespToXapp, 1},
1214 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001215
1216 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001218 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1219 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001220 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001221
1222 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001223 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001224
1225 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001226 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1227 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001228
1229 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001230 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001231
1232 // Wait that subs is cleaned
1233 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1234
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001235 xappConn1.TestMsgChanEmpty(t)
1236 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001237 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001238 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001239
1240 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001241}
1242
1243//-----------------------------------------------------------------------------
1244// TestSubReqAndSubDelOkSameAction
1245//
1246// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001247// +-------+ +-------+ +---------+ +---------+
1248// | xapp2 | | xapp1 | | submgr | | e2term |
1249// +-------+ +-------+ +---------+ +---------+
1250// | | | |
1251// | | | |
1252// | | | |
1253// | | SubReq1 | |
1254// | |------------->| |
1255// | | | |
1256// | | | SubReq1 |
1257// | | |------------->|
1258// | | | SubResp1 |
1259// | | |<-------------|
1260// | | SubResp1 | |
1261// | |<-------------| |
1262// | | | |
1263// | SubReq2 | |
1264// |--------------------------->| |
1265// | | | |
1266// | SubResp2 | |
1267// |<---------------------------| |
1268// | | | |
1269// | | SubDelReq 1 | |
1270// | |------------->| |
1271// | | | |
1272// | | SubDelResp 1 | |
1273// | |<-------------| |
1274// | | | |
1275// | SubDelReq 2 | |
1276// |--------------------------->| |
1277// | | | |
1278// | | | SubDelReq 2 |
1279// | | |------------->|
1280// | | | |
1281// | | | SubDelReq 2 |
1282// | | |------------->|
1283// | | | |
1284// | SubDelResp 2 | |
1285// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001286//
1287//-----------------------------------------------------------------------------
1288func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001289 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001290
Anssi Mannila4abf1802021-01-28 13:06:46 +02001291 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001292 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1293 Counter{cSubReqFromXapp, 2},
1294 Counter{cSubReqToE2, 1},
1295 Counter{cSubRespFromE2, 1},
1296 Counter{cSubRespToXapp, 2},
1297 Counter{cMergedSubscriptions, 1},
1298 Counter{cUnmergedSubscriptions, 1},
1299 Counter{cSubDelReqFromXapp, 2},
1300 Counter{cSubDelReqToE2, 1},
1301 Counter{cSubDelRespFromE2, 1},
1302 Counter{cSubDelRespToXapp, 2},
1303 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001304
Juha Hyttinen3944a222020-01-24 11:51:46 +02001305 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001306 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001307 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001308 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001309 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1310 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001311 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001312
1313 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001314 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001315 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001316 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001317 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1318 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001320
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001321 resp, _ := xapp.Subscription.QuerySubscriptions()
1322 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1323 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1324 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
1325
Juha Hyttinen3944a222020-01-24 11:51:46 +02001326 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001327 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001328 //e2termConn1.RecvSubsDelReq(t)
1329 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001330 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001331 //Wait that subs is cleaned
1332 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1333
1334 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001336 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1337 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001338 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001339 //Wait that subs is cleaned
1340 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1341
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001342 xappConn1.TestMsgChanEmpty(t)
1343 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001344 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001345 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001346
1347 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001348}
1349
1350//-----------------------------------------------------------------------------
1351// TestSubReqAndSubDelOkSameActionParallel
1352//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001353// stub stub stub
1354// +-------+ +-------+ +---------+ +---------+
1355// | xapp2 | | xapp1 | | submgr | | e2term |
1356// +-------+ +-------+ +---------+ +---------+
1357// | | | |
1358// | | | |
1359// | | | |
1360// | | SubReq1 | |
1361// | |------------->| |
1362// | | | |
1363// | | | SubReq1 |
1364// | | |------------->|
1365// | SubReq2 | |
1366// |--------------------------->| |
1367// | | | SubResp1 |
1368// | | |<-------------|
1369// | | SubResp1 | |
1370// | |<-------------| |
1371// | | | |
1372// | SubResp2 | |
1373// |<---------------------------| |
1374// | | | |
1375// | | SubDelReq 1 | |
1376// | |------------->| |
1377// | | | |
1378// | | SubDelResp 1 | |
1379// | |<-------------| |
1380// | | | |
1381// | SubDelReq 2 | |
1382// |--------------------------->| |
1383// | | | |
1384// | | | SubDelReq 2 |
1385// | | |------------->|
1386// | | | |
1387// | | | SubDelReq 2 |
1388// | | |------------->|
1389// | | | |
1390// | SubDelResp 2 | |
1391// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001392//
1393//-----------------------------------------------------------------------------
1394func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001395 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001396
1397 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001398 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001399 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001400 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001401 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001402
1403 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001404 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001405 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001406 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001407
1408 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001409 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001410 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001411
1412 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001413 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001414
1415 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001416 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1417 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001418
1419 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001420 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001421 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1422 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001423 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001424
1425 //Wait that subs is cleaned
1426 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1427
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001428 xappConn1.TestMsgChanEmpty(t)
1429 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001430 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001431 mainCtrl.wait_registry_empty(t, 10)
1432}
1433
1434//-----------------------------------------------------------------------------
1435// TestSubReqAndSubDelNokSameActionParallel
1436//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001437// stub stub stub
1438// +-------+ +-------+ +---------+ +---------+
1439// | xapp2 | | xapp1 | | submgr | | e2term |
1440// +-------+ +-------+ +---------+ +---------+
1441// | | | |
1442// | | | |
1443// | | | |
1444// | | SubReq1 | |
1445// | |------------->| |
1446// | | | |
1447// | | | SubReq1 |
1448// | | |------------->|
1449// | SubReq2 | |
1450// |--------------------------->| |
1451// | | | SubFail1 |
1452// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001453// | | | |
1454// | | | SubDelReq |
1455// | | |------------->|
1456// | | | SubDelResp |
1457// | | |<-------------|
1458// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001459// | | SubFail1 | |
1460// | |<-------------| |
1461// | | | |
1462// | SubFail2 | |
1463// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001464//
1465//-----------------------------------------------------------------------------
1466func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001467 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001468
1469 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001470 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001471 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001472 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001473
1474 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001475 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001476
1477 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001478 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001479 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001480 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001482 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001483
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001484 // E2t: send SubsFail (first)
1485 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1486 fparams1.Set(crereq1)
1487 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1488
1489 // E2t: internal delete
1490 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1491 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001492
1493 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001494 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001495 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001496 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001497
1498 //Wait that subs is cleaned
1499 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1500
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001501 xappConn1.TestMsgChanEmpty(t)
1502 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001503 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001504 mainCtrl.wait_registry_empty(t, 10)
1505}
1506
1507//-----------------------------------------------------------------------------
1508// TestSubReqAndSubDelNoAnswerSameActionParallel
1509//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001510// stub stub stub
1511// +-------+ +-------+ +---------+ +---------+
1512// | xapp2 | | xapp1 | | submgr | | e2term |
1513// +-------+ +-------+ +---------+ +---------+
1514// | | | |
1515// | | | |
1516// | | | |
1517// | | SubReq1 | |
1518// | |------------->| |
1519// | | | |
1520// | | | SubReq1 |
1521// | | |------------->|
1522// | | SubReq2 | |
1523// |--------------------------->| |
1524// | | | |
1525// | | | SubReq1 |
1526// | | |------------->|
1527// | | | |
1528// | | | |
1529// | | | SubDelReq |
1530// | | |------------->|
1531// | | | |
1532// | | | SubDelResp |
1533// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001534//
1535//-----------------------------------------------------------------------------
1536func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001537 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001538
1539 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001540 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001541 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001542 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001543
Juha Hyttinen1683f912020-04-17 10:39:57 +03001544 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001545
1546 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001547 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001548 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001549 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001550 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001551 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001552
1553 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001554 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001555
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001556 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1557 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001558
1559 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001560 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001561
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001562 xappConn1.TestMsgChanEmpty(t)
1563 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001564 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001565 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001566}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001567
1568//----------------------------- Policy cases ---------------------------------
1569//-----------------------------------------------------------------------------
1570// TestSubReqPolicyAndSubDelOk
1571//
1572// stub stub
1573// +-------+ +---------+ +---------+
1574// | xapp | | submgr | | e2term |
1575// +-------+ +---------+ +---------+
1576// | | |
1577// | SubReq | |
1578// |------------->| |
1579// | | |
1580// | | SubReq |
1581// | |------------->|
1582// | | |
1583// | | SubResp |
1584// | |<-------------|
1585// | | |
1586// | SubResp | |
1587// |<-------------| |
1588// | | |
1589// | | |
1590// | SubDelReq | |
1591// |------------->| |
1592// | | |
1593// | | SubDelReq |
1594// | |------------->|
1595// | | |
1596// | | SubDelResp |
1597// | |<-------------|
1598// | | |
1599// | SubDelResp | |
1600// |<-------------| |
1601//
1602//-----------------------------------------------------------------------------
1603func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1604 CaseBegin("TestSubReqAndSubDelOk")
1605
1606 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1607 rparams1.Init()
1608 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1609 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1610
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001611 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1612 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001613 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1614 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001615 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001616
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001617 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001618 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001619
1620 //Wait that subs is cleaned
1621 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1622
1623 xappConn1.TestMsgChanEmpty(t)
1624 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001625 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001626 mainCtrl.wait_registry_empty(t, 10)
1627}
1628
1629//-----------------------------------------------------------------------------
1630// TestSubReqPolicyChangeAndSubDelOk
1631//
1632// stub stub
1633// +-------+ +---------+ +---------+
1634// | xapp | | submgr | | e2term |
1635// +-------+ +---------+ +---------+
1636// | | |
1637// | SubReq | |
1638// |------------->| |
1639// | | |
1640// | | SubReq |
1641// | |------------->|
1642// | | |
1643// | | SubResp |
1644// | |<-------------|
1645// | | |
1646// | SubResp | |
1647// |<-------------| |
1648// | | |
1649// | SubReq | |
1650// |------------->| |
1651// | | |
1652// | | SubReq |
1653// | |------------->|
1654// | | |
1655// | | SubResp |
1656// | |<-------------|
1657// | | |
1658// | SubResp | |
1659// |<-------------| |
1660// | | |
1661// | SubDelReq | |
1662// |------------->| |
1663// | | |
1664// | | SubDelReq |
1665// | |------------->|
1666// | | |
1667// | | SubDelResp |
1668// | |<-------------|
1669// | | |
1670// | SubDelResp | |
1671// |<-------------| |
1672//
1673//-----------------------------------------------------------------------------
1674
1675func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1676 CaseBegin("TestSubReqAndSubDelOk")
1677
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001678 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1679 rparams1.Init()
1680 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1681 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001682
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001683 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1684 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001685 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1686
1687 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001688 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001689 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1690 xappConn1.SendSubsReq(t, rparams1, cretrans)
1691
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001692 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1693 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001694 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1695 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001696 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001697
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001698 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001699 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001700
1701 //Wait that subs is cleaned
1702 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1703
1704 xappConn1.TestMsgChanEmpty(t)
1705 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001706 e2termConn1.TestMsgChanEmpty(t)
1707 mainCtrl.wait_registry_empty(t, 10)
1708}
1709
1710//-----------------------------------------------------------------------------
1711// TestSubReqAndSubDelOkTwoE2termParallel
1712//
1713// stub stub stub
1714// +-------+ +---------+ +---------+ +---------+
1715// | xapp | | submgr | | e2term1 | | e2term2 |
1716// +-------+ +---------+ +---------+ +---------+
1717// | | | |
1718// | | | |
1719// | | | |
1720// | SubReq1 | | |
1721// |------------->| | |
1722// | | | |
1723// | | SubReq1 | |
1724// | |------------->| |
1725// | | | |
1726// | SubReq2 | | |
1727// |------------->| | |
1728// | | | |
1729// | | SubReq2 | |
1730// | |---------------------------->|
1731// | | | |
1732// | | SubResp1 | |
1733// | |<-------------| |
1734// | SubResp1 | | |
1735// |<-------------| | |
1736// | | SubResp2 | |
1737// | |<----------------------------|
1738// | SubResp2 | | |
1739// |<-------------| | |
1740// | | | |
1741// | [SUBS 1 DELETE] | |
1742// | | | |
1743// | [SUBS 2 DELETE] | |
1744// | | | |
1745//
1746//-----------------------------------------------------------------------------
1747func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1748 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1749
1750 //Req1
1751 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1752 xappConn1.SendSubsReq(t, nil, cretrans1)
1753 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1754
1755 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1756 xappConn1.SendSubsReq(t, nil, cretrans2)
1757 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1758
1759 //Resp1
1760 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1761 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1762
1763 //Resp2
1764 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1765 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1766
1767 //Del1
1768 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1769 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1770 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1771 xappConn1.RecvSubsDelResp(t, deltrans1)
1772 //Wait that subs is cleaned
1773 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1774
1775 //Del2
1776 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1777 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1778 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1779 xappConn1.RecvSubsDelResp(t, deltrans2)
1780 //Wait that subs is cleaned
1781 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1782
1783 xappConn1.TestMsgChanEmpty(t)
1784 xappConn2.TestMsgChanEmpty(t)
1785 e2termConn1.TestMsgChanEmpty(t)
1786 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001787 mainCtrl.wait_registry_empty(t, 10)
1788}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001789
1790//-----------------------------------------------------------------------------
1791// TestSubReqInsertAndSubDelOk
1792//
1793// stub stub
1794// +-------+ +---------+ +---------+
1795// | xapp | | submgr | | e2term |
1796// +-------+ +---------+ +---------+
1797// | | |
1798// | SubReq | |
1799// |------------->| |
1800// | | |
1801// | | SubReq |
1802// | |------------->|
1803// | | |
1804// | | SubResp |
1805// | |<-------------|
1806// | | |
1807// | SubResp | |
1808// |<-------------| |
1809// | | |
1810// | | |
1811// | SubDelReq | |
1812// |------------->| |
1813// | | |
1814// | | SubDelReq |
1815// | |------------->|
1816// | | |
1817// | | SubDelResp |
1818// | |<-------------|
1819// | | |
1820// | SubDelResp | |
1821// |<-------------| |
1822//
1823//-----------------------------------------------------------------------------
1824func TestSubReqInsertAndSubDelOk(t *testing.T) {
1825 CaseBegin("TestInsertSubReqAndSubDelOk")
1826
1827 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1828 rparams1.Init()
1829 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1830 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1831
1832 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1833 e2termConn1.SendSubsResp(t, crereq, cremsg)
1834 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1835 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1836 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1837
1838 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1839 xappConn1.RecvSubsDelResp(t, deltrans)
1840
1841 //Wait that subs is cleaned
1842 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1843
1844 xappConn1.TestMsgChanEmpty(t)
1845 xappConn2.TestMsgChanEmpty(t)
1846 e2termConn1.TestMsgChanEmpty(t)
1847 mainCtrl.wait_registry_empty(t, 10)
1848}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001849
1850//-----------------------------------------------------------------------------
1851// TestSubReqRetransmissionWithSameSubIdDiffXid
1852//
1853// This case simulates case where xApp restarts and starts sending same
1854// subscription requests which have already subscribed successfully
1855
1856// stub stub
1857// +-------+ +---------+ +---------+
1858// | xapp | | submgr | | e2term |
1859// +-------+ +---------+ +---------+
1860// | | |
1861// | SubReq | |
1862// |------------->| |
1863// | | |
1864// | | SubReq |
1865// | |------------->|
1866// | | |
1867// | | SubResp |
1868// | |<-------------|
1869// | | |
1870// | SubResp | |
1871// |<-------------| |
1872// | | |
1873// | xApp restart | |
1874// | | |
1875// | SubReq | |
1876// | (retrans with same xApp generated subid but diff xid)
1877// |------------->| |
1878// | | |
1879// | SubResp | |
1880// |<-------------| |
1881// | | |
1882// | [SUBS DELETE] |
1883// | | |
1884//
1885//-----------------------------------------------------------------------------
1886func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1887 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1888
1889 //Subs Create
1890 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1891 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1892 e2termConn1.SendSubsResp(t, crereq, cremsg)
1893 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1894
1895 // xApp restart here
1896 // --> artificial delay
1897 <-time.After(1 * time.Second)
1898
1899 //Subs Create
1900 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1901 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1902
1903 //Subs Delete
1904 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1905 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1906 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1907 xappConn1.RecvSubsDelResp(t, deltrans)
1908
1909 //Wait that subs is cleaned
1910 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1911
1912 xappConn1.TestMsgChanEmpty(t)
1913 xappConn2.TestMsgChanEmpty(t)
1914 e2termConn1.TestMsgChanEmpty(t)
1915 mainCtrl.wait_registry_empty(t, 10)
1916}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001917
1918//-----------------------------------------------------------------------------
1919// TestSubReqNokAndSubDelOkWithRestartInMiddle
1920//
1921// stub stub
1922// +-------+ +---------+ +---------+
1923// | xapp | | submgr | | e2term |
1924// +-------+ +---------+ +---------+
1925// | | |
1926// | SubReq | |
1927// |------------->| |
1928// | | |
1929// | | SubReq |
1930// | |------------->|
1931// | | |
1932// | | SubResp |
1933// | <----|
1934// | |
1935// | Submgr restart |
1936// | |
1937// | | |
1938// | | SubDelReq |
1939// | |------------->|
1940// | | |
1941// | | SubDelResp |
1942// | |<-------------|
1943// | | |
1944//
1945//-----------------------------------------------------------------------------
1946
1947func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1948 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1949
1950 // Remove possible existing subscrition
1951 mainCtrl.removeExistingSubscriptions(t)
1952
1953 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1954 xappConn1.SendSubsReq(t, nil, nil)
1955 e2termConn1.RecvSubsReq(t)
1956 mainCtrl.SetResetTestFlag(t, false)
1957
1958 resp, _ := xapp.Subscription.QuerySubscriptions()
1959 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1960 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
1961 e2SubsId := uint32(resp[0].SubscriptionID)
1962 t.Logf("e2SubsId = %v", e2SubsId)
1963
1964 mainCtrl.SimulateRestart(t) // This will trigger sending of SubDelReq
1965
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")
2027 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
2028
2029 mainCtrl.SimulateRestart(t)
2030
2031 // Check that subscription is restored correctly after restart
2032 resp, _ = xapp.Subscription.QuerySubscriptions()
2033 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2034 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2035 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
2036
2037 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2038 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2039 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2040 xappConn1.RecvSubsDelResp(t, deltrans)
2041
2042 //Wait that subs is cleaned
2043 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2044
2045 xappConn1.TestMsgChanEmpty(t)
2046 xappConn2.TestMsgChanEmpty(t)
2047 e2termConn1.TestMsgChanEmpty(t)
2048 mainCtrl.wait_registry_empty(t, 10)
2049}
2050
2051//-----------------------------------------------------------------------------
2052// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2053//
2054// stub stub
2055// +-------+ +-------+ +---------+ +---------+
2056// | xapp2 | | xapp1 | | submgr | | e2term |
2057// +-------+ +-------+ +---------+ +---------+
2058// | | | |
2059// | | | |
2060// | | | |
2061// | | SubReq1 | |
2062// | |------------->| |
2063// | | | |
2064// | | | SubReq1 |
2065// | | |------------->|
2066// | | | SubResp1 |
2067// | | |<-------------|
2068// | | SubResp1 | |
2069// | |<-------------| |
2070// | | | |
2071// | |
2072// | submgr restart |
2073// | |
2074// | | | |
2075// | | | |
2076// | SubReq2 | |
2077// |--------------------------->| |
2078// | | | |
2079// | SubResp2 | |
2080// |<---------------------------| |
2081// | | | |
2082// | | SubDelReq 1 | |
2083// | |------------->| |
2084// | | | |
2085// | | SubDelResp 1 | |
2086// | |<-------------| |
2087// | | | |
2088// | | | |
2089// | |
2090// | submgr restart |
2091// | |
2092// | | | |
2093// | SubDelReq 2 | |
2094// |--------------------------->| |
2095// | | | |
2096// | | | SubDelReq 2 |
2097// | | |------------->|
2098// | | | |
2099// | | | SubDelReq 2 |
2100// | | |------------->|
2101// | | | |
2102// | SubDelResp 2 | |
2103// |<---------------------------| |
2104//
2105//-----------------------------------------------------------------------------
2106
2107func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2108 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2109
2110 //Req1
2111 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2112 rparams1.Init()
2113 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2114 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2115 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2116 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2117
2118 //Req2
2119 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2120 rparams2.Init()
2121 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2122 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2123
2124 // Check subscription
2125 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2126 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2127 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2128 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
2129
2130 mainCtrl.SimulateRestart(t)
2131
2132 // Check that subscription is restored correctly after restart
2133 resp, _ = xapp.Subscription.QuerySubscriptions()
2134 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2135 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2136 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
2137
2138 //Del1
2139 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2140 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2141 xappConn1.RecvSubsDelResp(t, deltrans1)
2142 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2143
2144 mainCtrl.SimulateRestart(t)
2145 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2146
2147 //Del2
2148 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2149 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2150
2151 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2152 xappConn2.RecvSubsDelResp(t, deltrans2)
2153
2154 //Wait that subs is cleaned
2155 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2156
2157 xappConn1.TestMsgChanEmpty(t)
2158 xappConn2.TestMsgChanEmpty(t)
2159 e2termConn1.TestMsgChanEmpty(t)
2160 mainCtrl.wait_registry_empty(t, 10)
2161}