blob: 81464b8cb68c8cc93ef177c0c19fc550ac64f5a6 [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")
archaggea5c58bc2021-04-14 08:54:05 +0300132 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200133
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")
archaggea5c58bc2021-04-14 08:54:05 +0300208 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200209
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")
archaggea5c58bc2021-04-14 08:54:05 +0300313 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200314
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")
archaggea5c58bc2021-04-14 08:54:05 +0300397 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200398
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// | | |
1006// | SubFail | |
1007// |<-------------| |
1008// | | |
1009//
1010//-----------------------------------------------------------------------------
1011
1012func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001013 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001014
1015 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1016 Counter{cSubReqFromXapp, 1},
1017 Counter{cSubReqToE2, 1},
1018 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001019 Counter{cSubFailToXapp, 1},
1020 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001021
1022 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001023 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001024
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001025 // E2t: Receive SubsReq and send SubsFail (first)
1026 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1027 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1028 fparams1.Set(crereq1)
1029 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1030
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001031 // Xapp: Receive SubsFail
1032 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1033
1034 // Wait that subs is cleaned
1035 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1036
1037 xappConn1.TestMsgChanEmpty(t)
1038 xappConn2.TestMsgChanEmpty(t)
1039 e2termConn1.TestMsgChanEmpty(t)
1040 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001041
1042 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001043}
1044
1045//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001046// TestSubDelReqRetryInSubmgr
1047//
1048// stub stub
1049// +-------+ +---------+ +---------+
1050// | xapp | | submgr | | e2term |
1051// +-------+ +---------+ +---------+
1052// | | |
1053// | [SUBS CREATE] |
1054// | | |
1055// | | |
1056// | SubDelReq | |
1057// |------------->| |
1058// | | |
1059// | | SubDelReq |
1060// | |------------->|
1061// | | |
1062// | | SubDelReq |
1063// | |------------->|
1064// | | |
1065// | | SubDelResp |
1066// | |<-------------|
1067// | | |
1068// | SubDelResp | |
1069// |<-------------| |
1070//
1071//-----------------------------------------------------------------------------
1072
1073func TestSubDelReqRetryInSubmgr(t *testing.T) {
1074
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001075 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001076
1077 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001078 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001079 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1080 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001081 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001082
1083 // Subs Delete
1084 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001085 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001086
1087 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001088 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001089
1090 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001091 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1092 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001093
1094 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001095 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001096
1097 // Wait that subs is cleaned
1098 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1099
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001100 xappConn1.TestMsgChanEmpty(t)
1101 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001102 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001103 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001104}
1105
1106//-----------------------------------------------------------------------------
1107// TestSubDelReqTwoRetriesNoRespInSubmgr
1108//
1109// stub stub
1110// +-------+ +---------+ +---------+
1111// | xapp | | submgr | | e2term |
1112// +-------+ +---------+ +---------+
1113// | | |
1114// | [SUBS CREATE] |
1115// | | |
1116// | | |
1117// | SubDelReq | |
1118// |------------->| |
1119// | | |
1120// | | SubDelReq |
1121// | |------------->|
1122// | | |
1123// | | SubDelReq |
1124// | |------------->|
1125// | | |
1126// | | |
1127// | SubDelResp | |
1128// |<-------------| |
1129//
1130//-----------------------------------------------------------------------------
1131
1132func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1133
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001134 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001135
1136 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001137 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001138 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1139 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001140 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001141
1142 // Subs Delete
1143 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001144 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001145
1146 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001147 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001148
1149 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001150 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001151
1152 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001153 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001154
1155 // Wait that subs is cleaned
1156 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1157
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001158 xappConn1.TestMsgChanEmpty(t)
1159 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001160 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001161 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001162}
1163
1164//-----------------------------------------------------------------------------
1165// TestSubDelReqSubDelFailRespInSubmgr
1166//
1167// stub stub
1168// +-------+ +---------+ +---------+
1169// | xapp | | submgr | | e2term |
1170// +-------+ +---------+ +---------+
1171// | | |
1172// | [SUBS CREATE] |
1173// | | |
1174// | | |
1175// | SubDelReq | |
1176// |------------->| |
1177// | | |
1178// | | SubDelReq |
1179// | |------------->|
1180// | | |
1181// | | SubDelFail |
1182// | |<-------------|
1183// | | |
1184// | SubDelResp | |
1185// |<-------------| |
1186// | | |
1187//
1188//-----------------------------------------------------------------------------
1189
1190func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001191 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001192
1193 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1194 Counter{cSubReqFromXapp, 1},
1195 Counter{cSubReqToE2, 1},
1196 Counter{cSubRespFromE2, 1},
1197 Counter{cSubRespToXapp, 1},
1198 Counter{cSubDelReqFromXapp, 1},
1199 Counter{cSubDelReqToE2, 1},
1200 Counter{cSubDelFailFromE2, 1},
1201 Counter{cSubDelRespToXapp, 1},
1202 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001203
1204 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001205 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001206 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1207 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001208 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001209
1210 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212
1213 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001214 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1215 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001216
1217 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001219
1220 // Wait that subs is cleaned
1221 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1222
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001223 xappConn1.TestMsgChanEmpty(t)
1224 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001225 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001226 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001227
1228 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001229}
1230
1231//-----------------------------------------------------------------------------
1232// TestSubReqAndSubDelOkSameAction
1233//
1234// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001235// +-------+ +-------+ +---------+ +---------+
1236// | xapp2 | | xapp1 | | submgr | | e2term |
1237// +-------+ +-------+ +---------+ +---------+
1238// | | | |
1239// | | | |
1240// | | | |
1241// | | SubReq1 | |
1242// | |------------->| |
1243// | | | |
1244// | | | SubReq1 |
1245// | | |------------->|
1246// | | | SubResp1 |
1247// | | |<-------------|
1248// | | SubResp1 | |
1249// | |<-------------| |
1250// | | | |
1251// | SubReq2 | |
1252// |--------------------------->| |
1253// | | | |
1254// | SubResp2 | |
1255// |<---------------------------| |
1256// | | | |
1257// | | SubDelReq 1 | |
1258// | |------------->| |
1259// | | | |
1260// | | SubDelResp 1 | |
1261// | |<-------------| |
1262// | | | |
1263// | SubDelReq 2 | |
1264// |--------------------------->| |
1265// | | | |
1266// | | | SubDelReq 2 |
1267// | | |------------->|
1268// | | | |
1269// | | | SubDelReq 2 |
1270// | | |------------->|
1271// | | | |
1272// | SubDelResp 2 | |
1273// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001274//
1275//-----------------------------------------------------------------------------
1276func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001277 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001278
Anssi Mannila4abf1802021-01-28 13:06:46 +02001279 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001280 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1281 Counter{cSubReqFromXapp, 2},
1282 Counter{cSubReqToE2, 1},
1283 Counter{cSubRespFromE2, 1},
1284 Counter{cSubRespToXapp, 2},
1285 Counter{cMergedSubscriptions, 1},
1286 Counter{cUnmergedSubscriptions, 1},
1287 Counter{cSubDelReqFromXapp, 2},
1288 Counter{cSubDelReqToE2, 1},
1289 Counter{cSubDelRespFromE2, 1},
1290 Counter{cSubDelRespToXapp, 2},
1291 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001292
Juha Hyttinen3944a222020-01-24 11:51:46 +02001293 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001294 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001295 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001296 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001297 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1298 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001299 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001300
1301 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001302 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001303 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001304 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001305 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1306 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001307 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001308
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001309 resp, _ := xapp.Subscription.QuerySubscriptions()
1310 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1311 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001312 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001313
Juha Hyttinen3944a222020-01-24 11:51:46 +02001314 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001315 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001316 //e2termConn1.RecvSubsDelReq(t)
1317 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001319 //Wait that subs is cleaned
1320 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1321
1322 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001323 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001324 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1325 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001326 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001327 //Wait that subs is cleaned
1328 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1329
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001330 xappConn1.TestMsgChanEmpty(t)
1331 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001332 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001333 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001334
1335 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001336}
1337
1338//-----------------------------------------------------------------------------
1339// TestSubReqAndSubDelOkSameActionParallel
1340//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001341// stub stub stub
1342// +-------+ +-------+ +---------+ +---------+
1343// | xapp2 | | xapp1 | | submgr | | e2term |
1344// +-------+ +-------+ +---------+ +---------+
1345// | | | |
1346// | | | |
1347// | | | |
1348// | | SubReq1 | |
1349// | |------------->| |
1350// | | | |
1351// | | | SubReq1 |
1352// | | |------------->|
1353// | SubReq2 | |
1354// |--------------------------->| |
1355// | | | SubResp1 |
1356// | | |<-------------|
1357// | | SubResp1 | |
1358// | |<-------------| |
1359// | | | |
1360// | SubResp2 | |
1361// |<---------------------------| |
1362// | | | |
1363// | | SubDelReq 1 | |
1364// | |------------->| |
1365// | | | |
1366// | | SubDelResp 1 | |
1367// | |<-------------| |
1368// | | | |
1369// | SubDelReq 2 | |
1370// |--------------------------->| |
1371// | | | |
1372// | | | SubDelReq 2 |
1373// | | |------------->|
1374// | | | |
1375// | | | SubDelReq 2 |
1376// | | |------------->|
1377// | | | |
1378// | SubDelResp 2 | |
1379// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001380//
1381//-----------------------------------------------------------------------------
1382func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001383 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001384
1385 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001386 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001387 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001388 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001389 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001390
1391 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001392 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001393 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001394 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001395
1396 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001397 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001398 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001399
1400 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001401 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001402
1403 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001404 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1405 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001406
1407 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001408 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001409 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1410 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001411 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001412
1413 //Wait that subs is cleaned
1414 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1415
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001416 xappConn1.TestMsgChanEmpty(t)
1417 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001418 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001419 mainCtrl.wait_registry_empty(t, 10)
1420}
1421
1422//-----------------------------------------------------------------------------
1423// TestSubReqAndSubDelNokSameActionParallel
1424//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001425// stub stub stub
1426// +-------+ +-------+ +---------+ +---------+
1427// | xapp2 | | xapp1 | | submgr | | e2term |
1428// +-------+ +-------+ +---------+ +---------+
1429// | | | |
1430// | | | |
1431// | | | |
1432// | | SubReq1 | |
1433// | |------------->| |
1434// | | | |
1435// | | | SubReq1 |
1436// | | |------------->|
1437// | SubReq2 | |
1438// |--------------------------->| |
1439// | | | SubFail1 |
1440// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001441// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001442// | | SubFail1 | |
1443// | |<-------------| |
1444// | | | |
1445// | SubFail2 | |
1446// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001447//
1448//-----------------------------------------------------------------------------
1449func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001450 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001451
1452 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001453 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001454 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001455 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001456
1457 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001458 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001459
1460 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001461 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001462 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001463 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001464 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001465 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001466
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001467 // E2t: send SubsFail (first)
1468 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1469 fparams1.Set(crereq1)
1470 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1471
Juha Hyttinen3944a222020-01-24 11:51:46 +02001472 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001473 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001474 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001475 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001476
1477 //Wait that subs is cleaned
1478 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1479
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001480 xappConn1.TestMsgChanEmpty(t)
1481 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001482 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001483 mainCtrl.wait_registry_empty(t, 10)
1484}
1485
1486//-----------------------------------------------------------------------------
1487// TestSubReqAndSubDelNoAnswerSameActionParallel
1488//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001489// stub stub stub
1490// +-------+ +-------+ +---------+ +---------+
1491// | xapp2 | | xapp1 | | submgr | | e2term |
1492// +-------+ +-------+ +---------+ +---------+
1493// | | | |
1494// | | | |
1495// | | | |
1496// | | SubReq1 | |
1497// | |------------->| |
1498// | | | |
1499// | | | SubReq1 |
1500// | | |------------->|
1501// | | SubReq2 | |
1502// |--------------------------->| |
1503// | | | |
1504// | | | SubReq1 |
1505// | | |------------->|
1506// | | | |
1507// | | | |
1508// | | | SubDelReq |
1509// | | |------------->|
1510// | | | |
1511// | | | SubDelResp |
1512// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001513//
1514//-----------------------------------------------------------------------------
1515func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001516 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001517
1518 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001519 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001520 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001521 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001522
Juha Hyttinen1683f912020-04-17 10:39:57 +03001523 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001524
1525 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001526 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001527 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001528 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001529 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001530 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001531
1532 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001533 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001534
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001535 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1536 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001537
1538 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001539 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001540
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001541 xappConn1.TestMsgChanEmpty(t)
1542 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001543 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001544 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001545}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001546
1547//----------------------------- Policy cases ---------------------------------
1548//-----------------------------------------------------------------------------
1549// TestSubReqPolicyAndSubDelOk
1550//
1551// stub stub
1552// +-------+ +---------+ +---------+
1553// | xapp | | submgr | | e2term |
1554// +-------+ +---------+ +---------+
1555// | | |
1556// | SubReq | |
1557// |------------->| |
1558// | | |
1559// | | SubReq |
1560// | |------------->|
1561// | | |
1562// | | SubResp |
1563// | |<-------------|
1564// | | |
1565// | SubResp | |
1566// |<-------------| |
1567// | | |
1568// | | |
1569// | SubDelReq | |
1570// |------------->| |
1571// | | |
1572// | | SubDelReq |
1573// | |------------->|
1574// | | |
1575// | | SubDelResp |
1576// | |<-------------|
1577// | | |
1578// | SubDelResp | |
1579// |<-------------| |
1580//
1581//-----------------------------------------------------------------------------
1582func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1583 CaseBegin("TestSubReqAndSubDelOk")
1584
1585 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1586 rparams1.Init()
1587 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1588 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1589
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001590 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1591 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001592 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1593 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001594 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001595
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001596 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001597 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001598
1599 //Wait that subs is cleaned
1600 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1601
1602 xappConn1.TestMsgChanEmpty(t)
1603 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001604 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001605 mainCtrl.wait_registry_empty(t, 10)
1606}
1607
1608//-----------------------------------------------------------------------------
1609// TestSubReqPolicyChangeAndSubDelOk
1610//
1611// stub stub
1612// +-------+ +---------+ +---------+
1613// | xapp | | submgr | | e2term |
1614// +-------+ +---------+ +---------+
1615// | | |
1616// | SubReq | |
1617// |------------->| |
1618// | | |
1619// | | SubReq |
1620// | |------------->|
1621// | | |
1622// | | SubResp |
1623// | |<-------------|
1624// | | |
1625// | SubResp | |
1626// |<-------------| |
1627// | | |
1628// | SubReq | |
1629// |------------->| |
1630// | | |
1631// | | SubReq |
1632// | |------------->|
1633// | | |
1634// | | SubResp |
1635// | |<-------------|
1636// | | |
1637// | SubResp | |
1638// |<-------------| |
1639// | | |
1640// | SubDelReq | |
1641// |------------->| |
1642// | | |
1643// | | SubDelReq |
1644// | |------------->|
1645// | | |
1646// | | SubDelResp |
1647// | |<-------------|
1648// | | |
1649// | SubDelResp | |
1650// |<-------------| |
1651//
1652//-----------------------------------------------------------------------------
1653
1654func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1655 CaseBegin("TestSubReqAndSubDelOk")
1656
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001657 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1658 rparams1.Init()
1659 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1660 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001661
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001662 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1663 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001664 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1665
1666 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001667 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001668 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1669 xappConn1.SendSubsReq(t, rparams1, cretrans)
1670
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001671 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1672 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001673 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1674 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001675 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001676
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001677 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001678 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001679
1680 //Wait that subs is cleaned
1681 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1682
1683 xappConn1.TestMsgChanEmpty(t)
1684 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001685 e2termConn1.TestMsgChanEmpty(t)
1686 mainCtrl.wait_registry_empty(t, 10)
1687}
1688
1689//-----------------------------------------------------------------------------
1690// TestSubReqAndSubDelOkTwoE2termParallel
1691//
1692// stub stub stub
1693// +-------+ +---------+ +---------+ +---------+
1694// | xapp | | submgr | | e2term1 | | e2term2 |
1695// +-------+ +---------+ +---------+ +---------+
1696// | | | |
1697// | | | |
1698// | | | |
1699// | SubReq1 | | |
1700// |------------->| | |
1701// | | | |
1702// | | SubReq1 | |
1703// | |------------->| |
1704// | | | |
1705// | SubReq2 | | |
1706// |------------->| | |
1707// | | | |
1708// | | SubReq2 | |
1709// | |---------------------------->|
1710// | | | |
1711// | | SubResp1 | |
1712// | |<-------------| |
1713// | SubResp1 | | |
1714// |<-------------| | |
1715// | | SubResp2 | |
1716// | |<----------------------------|
1717// | SubResp2 | | |
1718// |<-------------| | |
1719// | | | |
1720// | [SUBS 1 DELETE] | |
1721// | | | |
1722// | [SUBS 2 DELETE] | |
1723// | | | |
1724//
1725//-----------------------------------------------------------------------------
1726func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1727 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1728
1729 //Req1
1730 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1731 xappConn1.SendSubsReq(t, nil, cretrans1)
1732 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1733
1734 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1735 xappConn1.SendSubsReq(t, nil, cretrans2)
1736 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1737
1738 //Resp1
1739 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1740 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1741
1742 //Resp2
1743 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1744 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1745
1746 //Del1
1747 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1748 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1749 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1750 xappConn1.RecvSubsDelResp(t, deltrans1)
1751 //Wait that subs is cleaned
1752 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1753
1754 //Del2
1755 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1756 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1757 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1758 xappConn1.RecvSubsDelResp(t, deltrans2)
1759 //Wait that subs is cleaned
1760 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1761
1762 xappConn1.TestMsgChanEmpty(t)
1763 xappConn2.TestMsgChanEmpty(t)
1764 e2termConn1.TestMsgChanEmpty(t)
1765 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001766 mainCtrl.wait_registry_empty(t, 10)
1767}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001768
1769//-----------------------------------------------------------------------------
1770// TestSubReqInsertAndSubDelOk
1771//
1772// stub stub
1773// +-------+ +---------+ +---------+
1774// | xapp | | submgr | | e2term |
1775// +-------+ +---------+ +---------+
1776// | | |
1777// | SubReq | |
1778// |------------->| |
1779// | | |
1780// | | SubReq |
1781// | |------------->|
1782// | | |
1783// | | SubResp |
1784// | |<-------------|
1785// | | |
1786// | SubResp | |
1787// |<-------------| |
1788// | | |
1789// | | |
1790// | SubDelReq | |
1791// |------------->| |
1792// | | |
1793// | | SubDelReq |
1794// | |------------->|
1795// | | |
1796// | | SubDelResp |
1797// | |<-------------|
1798// | | |
1799// | SubDelResp | |
1800// |<-------------| |
1801//
1802//-----------------------------------------------------------------------------
1803func TestSubReqInsertAndSubDelOk(t *testing.T) {
1804 CaseBegin("TestInsertSubReqAndSubDelOk")
1805
1806 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1807 rparams1.Init()
1808 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1809 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1810
1811 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1812 e2termConn1.SendSubsResp(t, crereq, cremsg)
1813 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1814 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1815 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1816
1817 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1818 xappConn1.RecvSubsDelResp(t, deltrans)
1819
1820 //Wait that subs is cleaned
1821 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1822
1823 xappConn1.TestMsgChanEmpty(t)
1824 xappConn2.TestMsgChanEmpty(t)
1825 e2termConn1.TestMsgChanEmpty(t)
1826 mainCtrl.wait_registry_empty(t, 10)
1827}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001828
1829//-----------------------------------------------------------------------------
1830// TestSubReqRetransmissionWithSameSubIdDiffXid
1831//
1832// This case simulates case where xApp restarts and starts sending same
1833// subscription requests which have already subscribed successfully
1834
1835// stub stub
1836// +-------+ +---------+ +---------+
1837// | xapp | | submgr | | e2term |
1838// +-------+ +---------+ +---------+
1839// | | |
1840// | SubReq | |
1841// |------------->| |
1842// | | |
1843// | | SubReq |
1844// | |------------->|
1845// | | |
1846// | | SubResp |
1847// | |<-------------|
1848// | | |
1849// | SubResp | |
1850// |<-------------| |
1851// | | |
1852// | xApp restart | |
1853// | | |
1854// | SubReq | |
1855// | (retrans with same xApp generated subid but diff xid)
1856// |------------->| |
1857// | | |
1858// | SubResp | |
1859// |<-------------| |
1860// | | |
1861// | [SUBS DELETE] |
1862// | | |
1863//
1864//-----------------------------------------------------------------------------
1865func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1866 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1867
1868 //Subs Create
1869 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1870 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1871 e2termConn1.SendSubsResp(t, crereq, cremsg)
1872 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1873
1874 // xApp restart here
1875 // --> artificial delay
1876 <-time.After(1 * time.Second)
1877
1878 //Subs Create
1879 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1880 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1881
1882 //Subs Delete
1883 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1884 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1885 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1886 xappConn1.RecvSubsDelResp(t, deltrans)
1887
1888 //Wait that subs is cleaned
1889 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1890
1891 xappConn1.TestMsgChanEmpty(t)
1892 xappConn2.TestMsgChanEmpty(t)
1893 e2termConn1.TestMsgChanEmpty(t)
1894 mainCtrl.wait_registry_empty(t, 10)
1895}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001896
1897//-----------------------------------------------------------------------------
1898// TestSubReqNokAndSubDelOkWithRestartInMiddle
1899//
1900// stub stub
1901// +-------+ +---------+ +---------+
1902// | xapp | | submgr | | e2term |
1903// +-------+ +---------+ +---------+
1904// | | |
1905// | SubReq | |
1906// |------------->| |
1907// | | |
1908// | | SubReq |
1909// | |------------->|
1910// | | |
1911// | | SubResp |
1912// | <----|
1913// | |
1914// | Submgr restart |
1915// | |
1916// | | |
1917// | | SubDelReq |
1918// | |------------->|
1919// | | |
1920// | | SubDelResp |
1921// | |<-------------|
1922// | | |
1923//
1924//-----------------------------------------------------------------------------
1925
1926func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1927 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1928
1929 // Remove possible existing subscrition
1930 mainCtrl.removeExistingSubscriptions(t)
1931
1932 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1933 xappConn1.SendSubsReq(t, nil, nil)
1934 e2termConn1.RecvSubsReq(t)
1935 mainCtrl.SetResetTestFlag(t, false)
1936
1937 resp, _ := xapp.Subscription.QuerySubscriptions()
1938 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001939 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02001940 e2SubsId := uint32(resp[0].SubscriptionID)
1941 t.Logf("e2SubsId = %v", e2SubsId)
1942
1943 mainCtrl.SimulateRestart(t) // This will trigger sending of SubDelReq
1944
1945 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1946 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1947
1948 // Wait that subs is cleaned
1949 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1950
1951 xappConn1.TestMsgChanEmpty(t)
1952 xappConn2.TestMsgChanEmpty(t)
1953 e2termConn1.TestMsgChanEmpty(t)
1954 mainCtrl.wait_registry_empty(t, 10)
1955}
1956
1957//-----------------------------------------------------------------------------
1958// TestSubReqAndSubDelOkWithRestartInMiddle
1959//
1960// stub stub
1961// +-------+ +---------+ +---------+
1962// | xapp | | submgr | | e2term |
1963// +-------+ +---------+ +---------+
1964// | | |
1965// | SubReq | |
1966// |------------->| |
1967// | | |
1968// | | SubReq |
1969// | |------------->|
1970// | | |
1971// | | SubResp |
1972// | |<-------------|
1973// | | |
1974// | SubResp | |
1975// |<-------------| |
1976// | | |
1977// | |
1978// | Submgr restart |
1979// | |
1980// | SubDelReq | |
1981// |------------->| |
1982// | | |
1983// | | SubDelReq |
1984// | |------------->|
1985// | | |
1986// | | SubDelResp |
1987// | |<-------------|
1988// | | |
1989// | SubDelResp | |
1990// |<-------------| |
1991//
1992//-----------------------------------------------------------------------------
1993
1994func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
1995 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
1996
1997 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1998 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1999 e2termConn1.SendSubsResp(t, crereq, cremsg)
2000 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2001
2002 // Check subscription
2003 resp, _ := xapp.Subscription.QuerySubscriptions()
2004 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2005 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002006 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002007
2008 mainCtrl.SimulateRestart(t)
2009
2010 // Check that subscription is restored correctly after restart
2011 resp, _ = xapp.Subscription.QuerySubscriptions()
2012 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2013 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002014 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002015
2016 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2017 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2018 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2019 xappConn1.RecvSubsDelResp(t, deltrans)
2020
2021 //Wait that subs is cleaned
2022 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2023
2024 xappConn1.TestMsgChanEmpty(t)
2025 xappConn2.TestMsgChanEmpty(t)
2026 e2termConn1.TestMsgChanEmpty(t)
2027 mainCtrl.wait_registry_empty(t, 10)
2028}
2029
2030//-----------------------------------------------------------------------------
2031// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2032//
2033// stub stub
2034// +-------+ +-------+ +---------+ +---------+
2035// | xapp2 | | xapp1 | | submgr | | e2term |
2036// +-------+ +-------+ +---------+ +---------+
2037// | | | |
2038// | | | |
2039// | | | |
2040// | | SubReq1 | |
2041// | |------------->| |
2042// | | | |
2043// | | | SubReq1 |
2044// | | |------------->|
2045// | | | SubResp1 |
2046// | | |<-------------|
2047// | | SubResp1 | |
2048// | |<-------------| |
2049// | | | |
2050// | |
2051// | submgr restart |
2052// | |
2053// | | | |
2054// | | | |
2055// | SubReq2 | |
2056// |--------------------------->| |
2057// | | | |
2058// | SubResp2 | |
2059// |<---------------------------| |
2060// | | | |
2061// | | SubDelReq 1 | |
2062// | |------------->| |
2063// | | | |
2064// | | SubDelResp 1 | |
2065// | |<-------------| |
2066// | | | |
2067// | | | |
2068// | |
2069// | submgr restart |
2070// | |
2071// | | | |
2072// | SubDelReq 2 | |
2073// |--------------------------->| |
2074// | | | |
2075// | | | SubDelReq 2 |
2076// | | |------------->|
2077// | | | |
2078// | | | SubDelReq 2 |
2079// | | |------------->|
2080// | | | |
2081// | SubDelResp 2 | |
2082// |<---------------------------| |
2083//
2084//-----------------------------------------------------------------------------
2085
2086func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2087 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2088
2089 //Req1
2090 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2091 rparams1.Init()
2092 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2093 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2094 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2095 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2096
2097 //Req2
2098 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2099 rparams2.Init()
2100 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2101 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2102
2103 // Check subscription
2104 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2105 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2106 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002107 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002108
2109 mainCtrl.SimulateRestart(t)
2110
2111 // Check that subscription is restored correctly after restart
2112 resp, _ = xapp.Subscription.QuerySubscriptions()
2113 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2114 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002115 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002116
2117 //Del1
2118 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2119 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2120 xappConn1.RecvSubsDelResp(t, deltrans1)
2121 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2122
2123 mainCtrl.SimulateRestart(t)
2124 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2125
2126 //Del2
2127 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2128 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2129
2130 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2131 xappConn2.RecvSubsDelResp(t, deltrans2)
2132
2133 //Wait that subs is cleaned
2134 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2135
2136 xappConn1.TestMsgChanEmpty(t)
2137 xappConn2.TestMsgChanEmpty(t)
2138 e2termConn1.TestMsgChanEmpty(t)
2139 mainCtrl.wait_registry_empty(t, 10)
2140}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002141
2142//-----------------------------------------------------------------------------
2143// Test debug GET and POST requests
2144//
2145// curl
2146// +-------+ +---------+
2147// | user | | submgr |
2148// +-------+ +---------+
2149// | |
2150// | GET/POST Req |
2151// |------------->|
2152// | Resp |
2153// |<-------------|
2154// | |
2155
2156func TestGetSubscriptions(t *testing.T) {
2157
2158 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2159}
2160
2161func TestGetSymptomData(t *testing.T) {
2162
2163 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2164}
2165
2166func TestPostdeleteSubId(t *testing.T) {
2167
2168 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2169}
2170
2171func TestPostEmptyDb(t *testing.T) {
2172
2173 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2174}