blob: e1d3424a42934520908e8b58264165eb3bdc504e [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
59 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
60 mainCtrl.SetTimesCounterWillBeAdded(cRouteCreateFail, 1)
61 mainCtrl.GetCounterValuesBefore(t)
62
Juha Hyttinenfa015662020-01-24 10:05:18 +020063 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +030064 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020065 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020066 waiter.WaitResult(t)
67
68 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020069 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020070
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020071 xappConn1.TestMsgChanEmpty(t)
72 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020073 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020074 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +020075
76 <-time.After(1 * time.Second)
77 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +020078}
79
80//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +020081// TestSubReqAndRouteUpdateNok
82
83// stub stub
84// +-------+ +-------+ +---------+ +---------+
85// | xapp2 | | xapp1 | | submgr | | rtmgr |
86// +-------+ +-------+ +---------+ +---------+
87// | | | |
88// | [SUBS CREATE] | |
89// | | | |
90// | | | |
91// | | | |
92// | SubReq (mergeable) | |
93// |--------------------------->| | |
94// | | | |
95// | | | RouteUpdate |
96// | | |------------->|
97// | | | |
98// | | | RouteUpdate |
99// | | | status:400 |
100// | | |<-------------|
101// | | | |
102// | [SUBS INT DELETE] | |
103// | | | |
104// | | | |
105// | [SUBS DELETE] | |
106// | | | |
107func TestSubReqAndRouteUpdateNok(t *testing.T) {
108 CaseBegin("TestSubReqAndRouteUpdateNok")
109
110 // Init counter check
111 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 2)
112 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
113 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
114 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 1)
115 mainCtrl.SetTimesCounterWillBeAdded(cRouteCreateUpdateFail, 1)
116
117 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 1)
118 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
119 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
120 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 1)
121 mainCtrl.GetCounterValuesBefore(t)
122
123 cretrans := xappConn1.SendSubsReq(t, nil, nil)
124 crereq, cremsg := e2termConn1.RecvSubsReq(t)
125 e2termConn1.SendSubsResp(t, crereq, cremsg)
126 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
127
128 resp, _ := xapp.Subscription.QuerySubscriptions()
129 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
130 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
131 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
132
133 waiter := rtmgrHttp.AllocNextEvent(false)
134 newSubsId := mainCtrl.get_registry_next_subid(t)
135 xappConn2.SendSubsReq(t, nil, nil)
136 waiter.WaitResult(t)
137
138 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
139 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
140
141 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
142 xappConn1.RecvSubsDelResp(t, deltrans)
143
144 //Wait that subs is cleaned
145 mainCtrl.wait_subs_clean(t, newSubsId, 10)
146 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
147
148 xappConn1.TestMsgChanEmpty(t)
149 xappConn2.TestMsgChanEmpty(t)
150 e2termConn1.TestMsgChanEmpty(t)
151 mainCtrl.wait_registry_empty(t, 10)
152
153 mainCtrl.VerifyCounterValues(t)
154}
155
156//-----------------------------------------------------------------------------
157// TestSubDelReqAndRouteDeleteNok
158//
159// stub stub
160// +-------+ +---------+ +---------+ +---------+
161// | xapp | | submgr | | e2term | | rtmgr |
162// +-------+ +---------+ +---------+ +---------+
163// | | | |
164// | [SUBS CREATE] | |
165// | | | |
166// | | | |
167// | | | |
168// | SubDelReq | | |
169// |------------->| | |
170// | | SubDelReq | |
171// | |------------->| |
172// | | SubDelRsp | |
173// | |<-------------| |
174// | SubDelRsp | | |
175// |<-------------| | |
176// | | RouteDelete | |
177// | |---------------------------->|
178// | | | |
179// | | RouteDelete | |
180// | | status:400 | |
181// | |<----------------------------|
182// | | | |
183func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
184 CaseBegin("TestSubDelReqAndRouteDeleteNok")
185
186 // Init counter check
187 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
188 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
189 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
190 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 1)
191
192 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 1)
193 mainCtrl.SetTimesCounterWillBeAdded(cRouteDeleteFail, 1)
194 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
195 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
196 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 1)
197 mainCtrl.GetCounterValuesBefore(t)
198
199 cretrans := xappConn1.SendSubsReq(t, nil, nil)
200 crereq, cremsg := e2termConn1.RecvSubsReq(t)
201 e2termConn1.SendSubsResp(t, crereq, cremsg)
202 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
203
204 resp, _ := xapp.Subscription.QuerySubscriptions()
205 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
206 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
207 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
208
209 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
210 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
211
212 waiter := rtmgrHttp.AllocNextEvent(false)
213 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
214 waiter.WaitResult(t)
215
216 xappConn1.RecvSubsDelResp(t, deltrans)
217
218 //Wait that subs is cleaned
219 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
220
221 xappConn1.TestMsgChanEmpty(t)
222 xappConn2.TestMsgChanEmpty(t)
223 e2termConn1.TestMsgChanEmpty(t)
224 mainCtrl.wait_registry_empty(t, 10)
225
226 mainCtrl.VerifyCounterValues(t)
227}
228
229//-----------------------------------------------------------------------------
230// TestSubMergeDelAndRouteUpdateNok
231// stub stub
232// +-------+ +-------+ +---------+ +---------+
233// | xapp2 | | xapp1 | | submgr | | e2term |
234// +-------+ +-------+ +---------+ +---------+
235// | | | |
236// | | | |
237// | | | |
238// | | SubReq1 | |
239// | |------------->| |
240// | | | |
241// | | | SubReq1 |
242// | | |------------->|
243// | | | SubResp1 |
244// | | |<-------------|
245// | | SubResp1 | |
246// | |<-------------| |
247// | | | |
248// | SubReq2 | |
249// |--------------------------->| |
250// | | | |
251// | SubResp2 | |
252// |<---------------------------| |
253// | | | |
254// | | SubDelReq 1 | |
255// | |------------->| |
256// | | | RouteUpdate |
257// | | |-----> rtmgr |
258// | | | |
259// | | | RouteUpdate |
260// | | | status:400 |
261// | | |<----- rtmgr |
262// | | | |
263// | | SubDelResp 1 | |
264// | |<-------------| |
265// | | | |
266// | SubDelReq 2 | |
267// |--------------------------->| |
268// | | | |
269// | | | SubDelReq 2 |
270// | | |------------->|
271// | | | |
272// | | | SubDelReq 2 |
273// | | |------------->|
274// | | | |
275// | SubDelResp 2 | |
276// |<---------------------------| |
277//
278//-----------------------------------------------------------------------------
279func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
280 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
281
282 // Init counter check
283 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 2)
284 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
285 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
286 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 2)
287
288 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 2)
289 mainCtrl.SetTimesCounterWillBeAdded(cRouteDeleteUpdateFail, 1)
290 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
291 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
292 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 2)
293 mainCtrl.GetCounterValuesBefore(t)
294
295 //Req1
296 rparams1 := &teststube2ap.E2StubSubsReqParams{}
297 rparams1.Init()
298 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
299 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
300 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
301 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
302
303 //Req2
304 rparams2 := &teststube2ap.E2StubSubsReqParams{}
305 rparams2.Init()
306 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
307 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
308
309 resp, _ := xapp.Subscription.QuerySubscriptions()
310 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
311 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
312 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
313
314 //Del1
315 waiter := rtmgrHttp.AllocNextEvent(false)
316 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
317 waiter.WaitResult(t)
318
319 xappConn1.RecvSubsDelResp(t, deltrans1)
320
321 //Del2
322 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
323 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
324 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
325 xappConn2.RecvSubsDelResp(t, deltrans2)
326 //Wait that subs is cleaned
327 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
328
329 xappConn1.TestMsgChanEmpty(t)
330 xappConn2.TestMsgChanEmpty(t)
331 e2termConn1.TestMsgChanEmpty(t)
332 mainCtrl.wait_registry_empty(t, 10)
333
334 mainCtrl.VerifyCounterValues(t)
335}
336
337//-----------------------------------------------------------------------------
338
339//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200340// TestSubReqAndSubDelOk
341//
342// stub stub
343// +-------+ +---------+ +---------+
344// | xapp | | submgr | | e2term |
345// +-------+ +---------+ +---------+
346// | | |
347// | SubReq | |
348// |------------->| |
349// | | |
350// | | SubReq |
351// | |------------->|
352// | | |
353// | | SubResp |
354// | |<-------------|
355// | | |
356// | SubResp | |
357// |<-------------| |
358// | | |
359// | | |
360// | SubDelReq | |
361// |------------->| |
362// | | |
363// | | SubDelReq |
364// | |------------->|
365// | | |
366// | | SubDelResp |
367// | |<-------------|
368// | | |
369// | SubDelResp | |
370// |<-------------| |
371//
372//-----------------------------------------------------------------------------
373func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200374 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200375
Anssi Mannila4abf1802021-01-28 13:06:46 +0200376 // Init counter check
377 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
378 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
379 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
380 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200381
Anssi Mannila4abf1802021-01-28 13:06:46 +0200382 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 1)
383 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
384 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
385 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 1)
386 mainCtrl.GetCounterValuesBefore(t)
387
388 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200389 crereq, cremsg := e2termConn1.RecvSubsReq(t)
390 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200391 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200392
393 resp, _ := xapp.Subscription.QuerySubscriptions()
394 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
395 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
396 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
397
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200398 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200399 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200400
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200401 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200402 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200403
404 //Wait that subs is cleaned
405 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
406
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200407 xappConn1.TestMsgChanEmpty(t)
408 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200409 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200410 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200411
412 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200413}
414
415//-----------------------------------------------------------------------------
416// TestSubReqRetransmission
417//
418// stub stub
419// +-------+ +---------+ +---------+
420// | xapp | | submgr | | e2term |
421// +-------+ +---------+ +---------+
422// | | |
423// | SubReq | |
424// |------------->| |
425// | | |
426// | | SubReq |
427// | |------------->|
428// | | |
429// | SubReq | |
430// | (retrans) | |
431// |------------->| |
432// | | |
433// | | SubResp |
434// | |<-------------|
435// | | |
436// | SubResp | |
437// |<-------------| |
438// | | |
439// | [SUBS DELETE] |
440// | | |
441//
442//-----------------------------------------------------------------------------
443func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200444 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200445
446 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200447 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200448 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200449
450 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200451 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200452 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
453
Juha Hyttinen1683f912020-04-17 10:39:57 +0300454 // hack as there is no real way to see has message be handled.
455 // Previuos counter check just tells that is has been received by submgr
456 // --> artificial delay
457 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200458 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200459 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200460
461 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200462 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200463 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
464 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200465 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200466
467 //Wait that subs is cleaned
468 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
469
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200470 xappConn1.TestMsgChanEmpty(t)
471 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200472 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200473 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200474}
475
476//-----------------------------------------------------------------------------
477// TestSubDelReqRetransmission
478//
479// stub stub
480// +-------+ +---------+ +---------+
481// | xapp | | submgr | | e2term |
482// +-------+ +---------+ +---------+
483// | | |
484// | [SUBS CREATE] |
485// | | |
486// | | |
487// | SubDelReq | |
488// |------------->| |
489// | | |
490// | | SubDelReq |
491// | |------------->|
492// | | |
493// | SubDelReq | |
494// | (same sub) | |
495// | (same xid) | |
496// |------------->| |
497// | | |
498// | | SubDelResp |
499// | |<-------------|
500// | | |
501// | SubDelResp | |
502// |<-------------| |
503//
504//-----------------------------------------------------------------------------
505func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200506 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200507
508 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200509 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200510 crereq, cremsg := e2termConn1.RecvSubsReq(t)
511 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200512 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200513
514 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200515 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200516 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200517
518 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200519 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200520 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
521
Juha Hyttinen1683f912020-04-17 10:39:57 +0300522 // hack as there is no real way to see has message be handled.
523 // Previuos counter check just tells that is has been received by submgr
524 // --> artificial delay
525 <-time.After(1 * time.Second)
526
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200527 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200528 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200529
530 //Wait that subs is cleaned
531 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
532
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200533 xappConn1.TestMsgChanEmpty(t)
534 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200535 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200536 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200537}
538
539//-----------------------------------------------------------------------------
540// TestSubDelReqCollision
541//
542// stub stub
543// +-------+ +---------+ +---------+
544// | xapp | | submgr | | e2term |
545// +-------+ +---------+ +---------+
546// | | |
547// | [SUBS CREATE] |
548// | | |
549// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200550// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200551// |------------->| |
552// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200553// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200554// | |------------->|
555// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200556// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200557// | (same sub) | |
558// | (diff xid) | |
559// |------------->| |
560// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200561// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200562// | |<-------------|
563// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200564// | SubDelResp 1 | |
565// |<-------------| |
566// | | |
567// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200568// |<-------------| |
569//
570//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200571
Juha Hyttinenfa015662020-01-24 10:05:18 +0200572func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200573 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200574
575 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200576 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200577 crereq, cremsg := e2termConn1.RecvSubsReq(t)
578 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200579 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200580
581 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200582 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200583 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200584
Juha Hyttinen3944a222020-01-24 11:51:46 +0200585 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200586 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200587 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
588 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200589 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
590
Juha Hyttinen1683f912020-04-17 10:39:57 +0300591 // hack as there is no real way to see has message be handled.
592 // Previuos counter check just tells that is has been received by submgr
593 // --> artificial delay
594 <-time.After(1 * time.Second)
595
Juha Hyttinen3944a222020-01-24 11:51:46 +0200596 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200597 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200598
599 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200600 xappConn1.RecvSubsDelResp(t, nil)
601 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200602
603 //Wait that subs is cleaned
604 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
605
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200606 xappConn1.TestMsgChanEmpty(t)
607 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200608 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200609 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200610}
611
612//-----------------------------------------------------------------------------
613// TestSubReqAndSubDelOkTwoParallel
614//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200615// stub stub stub
616// +-------+ +-------+ +---------+ +---------+
617// | xapp | | xapp | | submgr | | e2term |
618// +-------+ +-------+ +---------+ +---------+
619// | | | |
620// | | | |
621// | | | |
622// | | SubReq1 | |
623// | |------------->| |
624// | | | |
625// | | | SubReq1 |
626// | | |------------->|
627// | | | |
628// | SubReq2 | |
629// |------------------------>| |
630// | | | |
631// | | | SubReq2 |
632// | | |------------->|
633// | | | |
634// | | | SubResp1 |
635// | | |<-------------|
636// | | SubResp1 | |
637// | |<-------------| |
638// | | | |
639// | | | SubResp2 |
640// | | |<-------------|
641// | SubResp2 | |
642// |<------------------------| |
643// | | | |
644// | | [SUBS 1 DELETE] |
645// | | | |
646// | | [SUBS 2 DELETE] |
647// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200648//
649//-----------------------------------------------------------------------------
650func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200651 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200652
653 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200654 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200655 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200656 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200657 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200658
659 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200660 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200661 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300662
663 rparams2.Req.EventTriggerDefinition.Data.Length = 1
664 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
665 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
666
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200667 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200668 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200669
670 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200671 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200672 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200673
674 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200675 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200676 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200677
678 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200679 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200680 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
681 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200682 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200683 //Wait that subs is cleaned
684 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
685
686 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200687 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200688 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
689 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200690 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200691 //Wait that subs is cleaned
692 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
693
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200694 xappConn1.TestMsgChanEmpty(t)
695 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200696 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200697 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200698}
699
700//-----------------------------------------------------------------------------
701// TestSameSubsDiffRan
702// Same subscription to different RANs
703//
704// stub stub
705// +-------+ +---------+ +---------+
706// | xapp | | submgr | | e2term |
707// +-------+ +---------+ +---------+
708// | | |
709// | | |
710// | | |
711// | SubReq(r1) | |
712// |------------->| |
713// | | |
714// | | SubReq(r1) |
715// | |------------->|
716// | | |
717// | | SubResp(r1) |
718// | |<-------------|
719// | | |
720// | SubResp(r1) | |
721// |<-------------| |
722// | | |
723// | SubReq(r2) | |
724// |------------->| |
725// | | |
726// | | SubReq(r2) |
727// | |------------->|
728// | | |
729// | | SubResp(r2) |
730// | |<-------------|
731// | | |
732// | SubResp(r2) | |
733// |<-------------| |
734// | | |
735// | [SUBS r1 DELETE] |
736// | | |
737// | [SUBS r2 DELETE] |
738// | | |
739//
740//-----------------------------------------------------------------------------
741func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200742 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200743
744 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200745 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
746 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200747 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
748 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200749 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200750
751 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200752 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
753 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200754 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
755 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200756 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200757
758 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200759 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
760 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200761 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
762 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200763 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200764 //Wait that subs is cleaned
765 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
766
767 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200768 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
769 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200770 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
771 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200772 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200773 //Wait that subs is cleaned
774 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
775
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200776 xappConn1.TestMsgChanEmpty(t)
777 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200778 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200779 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200780}
781
782//-----------------------------------------------------------------------------
783// TestSubReqRetryInSubmgr
784//
785// stub stub
786// +-------+ +---------+ +---------+
787// | xapp | | submgr | | e2term |
788// +-------+ +---------+ +---------+
789// | | |
790// | SubReq | |
791// |------------->| |
792// | | |
793// | | SubReq |
794// | |------------->|
795// | | |
796// | | |
797// | | SubReq |
798// | |------------->|
799// | | |
800// | | SubResp |
801// | |<-------------|
802// | | |
803// | SubResp | |
804// |<-------------| |
805// | | |
806// | [SUBS DELETE] |
807// | | |
808//
809//-----------------------------------------------------------------------------
810
811func TestSubReqRetryInSubmgr(t *testing.T) {
812
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200813 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila4abf1802021-01-28 13:06:46 +0200814 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
815 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
816 mainCtrl.SetTimesCounterWillBeAdded(cSubReReqToE2, 1)
817 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
818 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 1)
819 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 1)
820 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
821 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
822 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 1)
823 mainCtrl.GetCounterValuesBefore(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200824
825 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200826 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200827
828 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200829 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200830
831 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200832 crereq, cremsg := e2termConn1.RecvSubsReq(t)
833 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200834
835 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200836 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200837
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200838 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200839 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
840 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200842
843 // Wait that subs is cleaned
844 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
845
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 xappConn1.TestMsgChanEmpty(t)
847 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200848 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200849 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200850
851 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200852}
853
854//-----------------------------------------------------------------------------
855// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
856//
857// stub stub
858// +-------+ +---------+ +---------+
859// | xapp | | submgr | | e2term |
860// +-------+ +---------+ +---------+
861// | | |
862// | SubReq | |
863// |------------->| |
864// | | |
865// | | SubReq |
866// | |------------->|
867// | | |
868// | | |
869// | | SubReq |
870// | |------------->|
871// | | |
872// | | SubDelReq |
873// | |------------->|
874// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200875// | | SubDelResp |
876// | |<-------------|
877// | | |
878//
879//-----------------------------------------------------------------------------
880
881func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
882
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200883 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila4abf1802021-01-28 13:06:46 +0200884 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
885 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
886 mainCtrl.SetTimesCounterWillBeAdded(cSubReReqToE2, 1)
887 mainCtrl.SetTimesCounterWillBeAdded(cSubReqTimerExpiry, 2)
888 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
889 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
890 mainCtrl.GetCounterValuesBefore(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200891
892 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200893 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200894
895 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200896 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200897
898 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200899 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200900
901 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200902 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
903 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200904
905 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300906 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200907
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200908 xappConn1.TestMsgChanEmpty(t)
909 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200910 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200911 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200912
913 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914}
915
916//-----------------------------------------------------------------------------
917// TestSubReqTwoRetriesNoRespAtAllInSubmgr
918//
919// stub stub
920// +-------+ +---------+ +---------+
921// | xapp | | submgr | | e2term |
922// +-------+ +---------+ +---------+
923// | | |
924// | SubReq | |
925// |------------->| |
926// | | |
927// | | SubReq |
928// | |------------->|
929// | | |
930// | | |
931// | | SubReq |
932// | |------------->|
933// | | |
934// | | SubDelReq |
935// | |------------->|
936// | | |
937// | | |
938// | | SubDelReq |
939// | |------------->|
940// | | |
941// | | |
942//
943//-----------------------------------------------------------------------------
944
945func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
946
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200947 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila4abf1802021-01-28 13:06:46 +0200948 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
949 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
950 mainCtrl.SetTimesCounterWillBeAdded(cSubReReqToE2, 1)
951 mainCtrl.SetTimesCounterWillBeAdded(cSubReqTimerExpiry, 2)
952 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
953 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqTimerExpiry, 2)
954 mainCtrl.GetCounterValuesBefore(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200955
956 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200957 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200958
959 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200960 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200961
962 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200963 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200964
965 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200966 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200967
968 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200969 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200970
971 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300972 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200973
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200974 xappConn1.TestMsgChanEmpty(t)
975 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200976 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200977 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200978
979 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200980}
981
982//-----------------------------------------------------------------------------
983// TestSubReqSubFailRespInSubmgr
984//
985// stub stub
986// +-------+ +---------+ +---------+
987// | xapp | | submgr | | e2term |
988// +-------+ +---------+ +---------+
989// | | |
990// | SubReq | |
991// |------------->| |
992// | | |
993// | | SubReq |
994// | |------------->|
995// | | |
996// | | SubFail |
997// | |<-------------|
998// | | |
Juha Hyttinenf28853b2020-03-09 14:02:50 +0200999// | | SubDelReq |
1000// | |------------->|
1001// | | |
1002// | | SubDelResp |
1003// | |<-------------|
1004// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005// | SubFail | |
1006// |<-------------| |
1007// | | |
1008//
1009//-----------------------------------------------------------------------------
1010
1011func TestSubReqSubFailRespInSubmgr(t *testing.T) {
1012
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001013 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila4abf1802021-01-28 13:06:46 +02001014 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
1015 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
1016 mainCtrl.SetTimesCounterWillBeAdded(cSubFailFromE2, 1)
1017 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
1018 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
1019 mainCtrl.SetTimesCounterWillBeAdded(cSubFailToXapp, 1)
1020 mainCtrl.GetCounterValuesBefore(t)
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
1031 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1032 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1033 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1034
1035 // Xapp: Receive SubsFail
1036 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1037
1038 // Wait that subs is cleaned
1039 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1040
1041 xappConn1.TestMsgChanEmpty(t)
1042 xappConn2.TestMsgChanEmpty(t)
1043 e2termConn1.TestMsgChanEmpty(t)
1044 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001045
1046 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001047}
1048
1049//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001050// TestSubDelReqRetryInSubmgr
1051//
1052// stub stub
1053// +-------+ +---------+ +---------+
1054// | xapp | | submgr | | e2term |
1055// +-------+ +---------+ +---------+
1056// | | |
1057// | [SUBS CREATE] |
1058// | | |
1059// | | |
1060// | SubDelReq | |
1061// |------------->| |
1062// | | |
1063// | | SubDelReq |
1064// | |------------->|
1065// | | |
1066// | | SubDelReq |
1067// | |------------->|
1068// | | |
1069// | | SubDelResp |
1070// | |<-------------|
1071// | | |
1072// | SubDelResp | |
1073// |<-------------| |
1074//
1075//-----------------------------------------------------------------------------
1076
1077func TestSubDelReqRetryInSubmgr(t *testing.T) {
1078
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001079 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001080
1081 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001082 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001083 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1084 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001085 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001086
1087 // Subs Delete
1088 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001089 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001090
1091 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001092 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001093
1094 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001095 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1096 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001097
1098 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001099 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001100
1101 // Wait that subs is cleaned
1102 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1103
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001104 xappConn1.TestMsgChanEmpty(t)
1105 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001106 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001107 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001108}
1109
1110//-----------------------------------------------------------------------------
1111// TestSubDelReqTwoRetriesNoRespInSubmgr
1112//
1113// stub stub
1114// +-------+ +---------+ +---------+
1115// | xapp | | submgr | | e2term |
1116// +-------+ +---------+ +---------+
1117// | | |
1118// | [SUBS CREATE] |
1119// | | |
1120// | | |
1121// | SubDelReq | |
1122// |------------->| |
1123// | | |
1124// | | SubDelReq |
1125// | |------------->|
1126// | | |
1127// | | SubDelReq |
1128// | |------------->|
1129// | | |
1130// | | |
1131// | SubDelResp | |
1132// |<-------------| |
1133//
1134//-----------------------------------------------------------------------------
1135
1136func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1137
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001138 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001139
1140 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001141 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001142 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1143 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001144 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001145
1146 // Subs Delete
1147 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001148 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001149
1150 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001151 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152
1153 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001154 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001155
1156 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001157 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001158
1159 // Wait that subs is cleaned
1160 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1161
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001162 xappConn1.TestMsgChanEmpty(t)
1163 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001164 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001165 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001166}
1167
1168//-----------------------------------------------------------------------------
1169// TestSubDelReqSubDelFailRespInSubmgr
1170//
1171// stub stub
1172// +-------+ +---------+ +---------+
1173// | xapp | | submgr | | e2term |
1174// +-------+ +---------+ +---------+
1175// | | |
1176// | [SUBS CREATE] |
1177// | | |
1178// | | |
1179// | SubDelReq | |
1180// |------------->| |
1181// | | |
1182// | | SubDelReq |
1183// | |------------->|
1184// | | |
1185// | | SubDelFail |
1186// | |<-------------|
1187// | | |
1188// | SubDelResp | |
1189// |<-------------| |
1190// | | |
1191//
1192//-----------------------------------------------------------------------------
1193
1194func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
1195
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001196 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila4abf1802021-01-28 13:06:46 +02001197 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 1)
1198 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
1199 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
1200 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 1)
1201 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 1)
1202 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
1203 mainCtrl.SetTimesCounterWillBeAdded(cSubDelFailFromE2, 1)
1204 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 1)
1205 mainCtrl.GetCounterValuesBefore(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001206
1207 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001208 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001209 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1210 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212
1213 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001214 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001215
1216 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001217 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1218 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001219
1220 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001221 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001222
1223 // Wait that subs is cleaned
1224 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1225
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001226 xappConn1.TestMsgChanEmpty(t)
1227 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001228 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001229 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001230
1231 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001232}
1233
1234//-----------------------------------------------------------------------------
1235// TestSubReqAndSubDelOkSameAction
1236//
1237// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001238// +-------+ +-------+ +---------+ +---------+
1239// | xapp2 | | xapp1 | | submgr | | e2term |
1240// +-------+ +-------+ +---------+ +---------+
1241// | | | |
1242// | | | |
1243// | | | |
1244// | | SubReq1 | |
1245// | |------------->| |
1246// | | | |
1247// | | | SubReq1 |
1248// | | |------------->|
1249// | | | SubResp1 |
1250// | | |<-------------|
1251// | | SubResp1 | |
1252// | |<-------------| |
1253// | | | |
1254// | SubReq2 | |
1255// |--------------------------->| |
1256// | | | |
1257// | SubResp2 | |
1258// |<---------------------------| |
1259// | | | |
1260// | | SubDelReq 1 | |
1261// | |------------->| |
1262// | | | |
1263// | | SubDelResp 1 | |
1264// | |<-------------| |
1265// | | | |
1266// | SubDelReq 2 | |
1267// |--------------------------->| |
1268// | | | |
1269// | | | SubDelReq 2 |
1270// | | |------------->|
1271// | | | |
1272// | | | SubDelReq 2 |
1273// | | |------------->|
1274// | | | |
1275// | SubDelResp 2 | |
1276// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001277//
1278//-----------------------------------------------------------------------------
1279func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001280 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001281
Anssi Mannila4abf1802021-01-28 13:06:46 +02001282 // Init counter check
1283 mainCtrl.SetTimesCounterWillBeAdded(cSubReqFromXapp, 2)
1284 mainCtrl.SetTimesCounterWillBeAdded(cSubReqToE2, 1)
1285 mainCtrl.SetTimesCounterWillBeAdded(cSubRespFromE2, 1)
1286 mainCtrl.SetTimesCounterWillBeAdded(cSubRespToXapp, 2)
1287 mainCtrl.SetTimesCounterWillBeAdded(cMergedSubscriptions, 1)
1288 mainCtrl.SetTimesCounterWillBeAdded(cUnmergedSubscriptions, 1)
1289 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqFromXapp, 2)
1290 mainCtrl.SetTimesCounterWillBeAdded(cSubDelReqToE2, 1)
1291 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespFromE2, 1)
1292 mainCtrl.SetTimesCounterWillBeAdded(cSubDelRespToXapp, 2)
1293 mainCtrl.GetCounterValuesBefore(t)
1294
Juha Hyttinen3944a222020-01-24 11:51:46 +02001295 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001296 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001297 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001298 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001299 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1300 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001301 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001302
1303 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001304 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001305 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001306 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001307 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1308 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001309 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001310
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001311 resp, _ := xapp.Subscription.QuerySubscriptions()
1312 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1313 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1314 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
1315
Juha Hyttinen3944a222020-01-24 11:51:46 +02001316 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001317 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001318 //e2termConn1.RecvSubsDelReq(t)
1319 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001320 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001321 //Wait that subs is cleaned
1322 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1323
1324 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001325 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001326 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1327 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001328 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001329 //Wait that subs is cleaned
1330 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1331
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001332 xappConn1.TestMsgChanEmpty(t)
1333 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001334 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001335 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001336
1337 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001338}
1339
1340//-----------------------------------------------------------------------------
1341// TestSubReqAndSubDelOkSameActionParallel
1342//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001343// stub stub stub
1344// +-------+ +-------+ +---------+ +---------+
1345// | xapp2 | | xapp1 | | submgr | | e2term |
1346// +-------+ +-------+ +---------+ +---------+
1347// | | | |
1348// | | | |
1349// | | | |
1350// | | SubReq1 | |
1351// | |------------->| |
1352// | | | |
1353// | | | SubReq1 |
1354// | | |------------->|
1355// | SubReq2 | |
1356// |--------------------------->| |
1357// | | | SubResp1 |
1358// | | |<-------------|
1359// | | SubResp1 | |
1360// | |<-------------| |
1361// | | | |
1362// | SubResp2 | |
1363// |<---------------------------| |
1364// | | | |
1365// | | SubDelReq 1 | |
1366// | |------------->| |
1367// | | | |
1368// | | SubDelResp 1 | |
1369// | |<-------------| |
1370// | | | |
1371// | SubDelReq 2 | |
1372// |--------------------------->| |
1373// | | | |
1374// | | | SubDelReq 2 |
1375// | | |------------->|
1376// | | | |
1377// | | | SubDelReq 2 |
1378// | | |------------->|
1379// | | | |
1380// | SubDelResp 2 | |
1381// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001382//
1383//-----------------------------------------------------------------------------
1384func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001385 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001386
1387 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001388 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001389 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001390 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001391 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001392
1393 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001394 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001395 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001396 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001397
1398 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001399 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001400 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001401
1402 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001403 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001404
1405 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001406 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1407 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408
1409 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001410 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001411 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1412 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001413 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001414
1415 //Wait that subs is cleaned
1416 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1417
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001418 xappConn1.TestMsgChanEmpty(t)
1419 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001420 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001421 mainCtrl.wait_registry_empty(t, 10)
1422}
1423
1424//-----------------------------------------------------------------------------
1425// TestSubReqAndSubDelNokSameActionParallel
1426//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001427// stub stub stub
1428// +-------+ +-------+ +---------+ +---------+
1429// | xapp2 | | xapp1 | | submgr | | e2term |
1430// +-------+ +-------+ +---------+ +---------+
1431// | | | |
1432// | | | |
1433// | | | |
1434// | | SubReq1 | |
1435// | |------------->| |
1436// | | | |
1437// | | | SubReq1 |
1438// | | |------------->|
1439// | SubReq2 | |
1440// |--------------------------->| |
1441// | | | SubFail1 |
1442// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001443// | | | |
1444// | | | SubDelReq |
1445// | | |------------->|
1446// | | | SubDelResp |
1447// | | |<-------------|
1448// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001449// | | SubFail1 | |
1450// | |<-------------| |
1451// | | | |
1452// | SubFail2 | |
1453// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001454//
1455//-----------------------------------------------------------------------------
1456func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001457 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001458
1459 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001460 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001461 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001462 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001463
1464 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001465 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001466
1467 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001468 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001469 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001470 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001471 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001472 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001473
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001474 // E2t: send SubsFail (first)
1475 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1476 fparams1.Set(crereq1)
1477 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1478
1479 // E2t: internal delete
1480 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1481 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001482
1483 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001484 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001485 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001487
1488 //Wait that subs is cleaned
1489 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1490
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001491 xappConn1.TestMsgChanEmpty(t)
1492 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001493 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001494 mainCtrl.wait_registry_empty(t, 10)
1495}
1496
1497//-----------------------------------------------------------------------------
1498// TestSubReqAndSubDelNoAnswerSameActionParallel
1499//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001500// stub stub stub
1501// +-------+ +-------+ +---------+ +---------+
1502// | xapp2 | | xapp1 | | submgr | | e2term |
1503// +-------+ +-------+ +---------+ +---------+
1504// | | | |
1505// | | | |
1506// | | | |
1507// | | SubReq1 | |
1508// | |------------->| |
1509// | | | |
1510// | | | SubReq1 |
1511// | | |------------->|
1512// | | SubReq2 | |
1513// |--------------------------->| |
1514// | | | |
1515// | | | SubReq1 |
1516// | | |------------->|
1517// | | | |
1518// | | | |
1519// | | | SubDelReq |
1520// | | |------------->|
1521// | | | |
1522// | | | SubDelResp |
1523// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001524//
1525//-----------------------------------------------------------------------------
1526func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001527 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001528
1529 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001530 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001531 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001532 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001533
Juha Hyttinen1683f912020-04-17 10:39:57 +03001534 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001535
1536 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001537 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001538 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001539 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001540 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001541 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001542
1543 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001544 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001545
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001546 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1547 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001548
1549 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001550 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001551
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001552 xappConn1.TestMsgChanEmpty(t)
1553 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001554 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001555 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001556}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001557
1558//----------------------------- Policy cases ---------------------------------
1559//-----------------------------------------------------------------------------
1560// TestSubReqPolicyAndSubDelOk
1561//
1562// stub stub
1563// +-------+ +---------+ +---------+
1564// | xapp | | submgr | | e2term |
1565// +-------+ +---------+ +---------+
1566// | | |
1567// | SubReq | |
1568// |------------->| |
1569// | | |
1570// | | SubReq |
1571// | |------------->|
1572// | | |
1573// | | SubResp |
1574// | |<-------------|
1575// | | |
1576// | SubResp | |
1577// |<-------------| |
1578// | | |
1579// | | |
1580// | SubDelReq | |
1581// |------------->| |
1582// | | |
1583// | | SubDelReq |
1584// | |------------->|
1585// | | |
1586// | | SubDelResp |
1587// | |<-------------|
1588// | | |
1589// | SubDelResp | |
1590// |<-------------| |
1591//
1592//-----------------------------------------------------------------------------
1593func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1594 CaseBegin("TestSubReqAndSubDelOk")
1595
1596 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1597 rparams1.Init()
1598 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1599 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1600
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001601 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1602 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001603 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1604 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001605 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001606
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001607 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001608 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001609
1610 //Wait that subs is cleaned
1611 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1612
1613 xappConn1.TestMsgChanEmpty(t)
1614 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001615 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001616 mainCtrl.wait_registry_empty(t, 10)
1617}
1618
1619//-----------------------------------------------------------------------------
1620// TestSubReqPolicyChangeAndSubDelOk
1621//
1622// stub stub
1623// +-------+ +---------+ +---------+
1624// | xapp | | submgr | | e2term |
1625// +-------+ +---------+ +---------+
1626// | | |
1627// | SubReq | |
1628// |------------->| |
1629// | | |
1630// | | SubReq |
1631// | |------------->|
1632// | | |
1633// | | SubResp |
1634// | |<-------------|
1635// | | |
1636// | SubResp | |
1637// |<-------------| |
1638// | | |
1639// | SubReq | |
1640// |------------->| |
1641// | | |
1642// | | SubReq |
1643// | |------------->|
1644// | | |
1645// | | SubResp |
1646// | |<-------------|
1647// | | |
1648// | SubResp | |
1649// |<-------------| |
1650// | | |
1651// | SubDelReq | |
1652// |------------->| |
1653// | | |
1654// | | SubDelReq |
1655// | |------------->|
1656// | | |
1657// | | SubDelResp |
1658// | |<-------------|
1659// | | |
1660// | SubDelResp | |
1661// |<-------------| |
1662//
1663//-----------------------------------------------------------------------------
1664
1665func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1666 CaseBegin("TestSubReqAndSubDelOk")
1667
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001668 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1669 rparams1.Init()
1670 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1671 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001672
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001673 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1674 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001675 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1676
1677 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001678 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001679 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1680 xappConn1.SendSubsReq(t, rparams1, cretrans)
1681
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001682 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1683 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001684 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1685 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001686 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001687
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001688 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001689 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001690
1691 //Wait that subs is cleaned
1692 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1693
1694 xappConn1.TestMsgChanEmpty(t)
1695 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001696 e2termConn1.TestMsgChanEmpty(t)
1697 mainCtrl.wait_registry_empty(t, 10)
1698}
1699
1700//-----------------------------------------------------------------------------
1701// TestSubReqAndSubDelOkTwoE2termParallel
1702//
1703// stub stub stub
1704// +-------+ +---------+ +---------+ +---------+
1705// | xapp | | submgr | | e2term1 | | e2term2 |
1706// +-------+ +---------+ +---------+ +---------+
1707// | | | |
1708// | | | |
1709// | | | |
1710// | SubReq1 | | |
1711// |------------->| | |
1712// | | | |
1713// | | SubReq1 | |
1714// | |------------->| |
1715// | | | |
1716// | SubReq2 | | |
1717// |------------->| | |
1718// | | | |
1719// | | SubReq2 | |
1720// | |---------------------------->|
1721// | | | |
1722// | | SubResp1 | |
1723// | |<-------------| |
1724// | SubResp1 | | |
1725// |<-------------| | |
1726// | | SubResp2 | |
1727// | |<----------------------------|
1728// | SubResp2 | | |
1729// |<-------------| | |
1730// | | | |
1731// | [SUBS 1 DELETE] | |
1732// | | | |
1733// | [SUBS 2 DELETE] | |
1734// | | | |
1735//
1736//-----------------------------------------------------------------------------
1737func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1738 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1739
1740 //Req1
1741 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1742 xappConn1.SendSubsReq(t, nil, cretrans1)
1743 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1744
1745 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1746 xappConn1.SendSubsReq(t, nil, cretrans2)
1747 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1748
1749 //Resp1
1750 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1751 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1752
1753 //Resp2
1754 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1755 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1756
1757 //Del1
1758 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1759 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1760 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1761 xappConn1.RecvSubsDelResp(t, deltrans1)
1762 //Wait that subs is cleaned
1763 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1764
1765 //Del2
1766 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1767 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1768 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1769 xappConn1.RecvSubsDelResp(t, deltrans2)
1770 //Wait that subs is cleaned
1771 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1772
1773 xappConn1.TestMsgChanEmpty(t)
1774 xappConn2.TestMsgChanEmpty(t)
1775 e2termConn1.TestMsgChanEmpty(t)
1776 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001777 mainCtrl.wait_registry_empty(t, 10)
1778}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001779
1780//-----------------------------------------------------------------------------
1781// TestSubReqInsertAndSubDelOk
1782//
1783// stub stub
1784// +-------+ +---------+ +---------+
1785// | xapp | | submgr | | e2term |
1786// +-------+ +---------+ +---------+
1787// | | |
1788// | SubReq | |
1789// |------------->| |
1790// | | |
1791// | | SubReq |
1792// | |------------->|
1793// | | |
1794// | | SubResp |
1795// | |<-------------|
1796// | | |
1797// | SubResp | |
1798// |<-------------| |
1799// | | |
1800// | | |
1801// | SubDelReq | |
1802// |------------->| |
1803// | | |
1804// | | SubDelReq |
1805// | |------------->|
1806// | | |
1807// | | SubDelResp |
1808// | |<-------------|
1809// | | |
1810// | SubDelResp | |
1811// |<-------------| |
1812//
1813//-----------------------------------------------------------------------------
1814func TestSubReqInsertAndSubDelOk(t *testing.T) {
1815 CaseBegin("TestInsertSubReqAndSubDelOk")
1816
1817 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1818 rparams1.Init()
1819 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1820 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1821
1822 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1823 e2termConn1.SendSubsResp(t, crereq, cremsg)
1824 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1825 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1826 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1827
1828 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1829 xappConn1.RecvSubsDelResp(t, deltrans)
1830
1831 //Wait that subs is cleaned
1832 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1833
1834 xappConn1.TestMsgChanEmpty(t)
1835 xappConn2.TestMsgChanEmpty(t)
1836 e2termConn1.TestMsgChanEmpty(t)
1837 mainCtrl.wait_registry_empty(t, 10)
1838}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001839
1840//-----------------------------------------------------------------------------
1841// TestSubReqRetransmissionWithSameSubIdDiffXid
1842//
1843// This case simulates case where xApp restarts and starts sending same
1844// subscription requests which have already subscribed successfully
1845
1846// stub stub
1847// +-------+ +---------+ +---------+
1848// | xapp | | submgr | | e2term |
1849// +-------+ +---------+ +---------+
1850// | | |
1851// | SubReq | |
1852// |------------->| |
1853// | | |
1854// | | SubReq |
1855// | |------------->|
1856// | | |
1857// | | SubResp |
1858// | |<-------------|
1859// | | |
1860// | SubResp | |
1861// |<-------------| |
1862// | | |
1863// | xApp restart | |
1864// | | |
1865// | SubReq | |
1866// | (retrans with same xApp generated subid but diff xid)
1867// |------------->| |
1868// | | |
1869// | SubResp | |
1870// |<-------------| |
1871// | | |
1872// | [SUBS DELETE] |
1873// | | |
1874//
1875//-----------------------------------------------------------------------------
1876func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1877 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1878
1879 //Subs Create
1880 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1881 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1882 e2termConn1.SendSubsResp(t, crereq, cremsg)
1883 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1884
1885 // xApp restart here
1886 // --> artificial delay
1887 <-time.After(1 * time.Second)
1888
1889 //Subs Create
1890 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1891 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1892
1893 //Subs Delete
1894 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1895 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1896 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1897 xappConn1.RecvSubsDelResp(t, deltrans)
1898
1899 //Wait that subs is cleaned
1900 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1901
1902 xappConn1.TestMsgChanEmpty(t)
1903 xappConn2.TestMsgChanEmpty(t)
1904 e2termConn1.TestMsgChanEmpty(t)
1905 mainCtrl.wait_registry_empty(t, 10)
1906}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001907
1908//-----------------------------------------------------------------------------
1909// TestSubReqNokAndSubDelOkWithRestartInMiddle
1910//
1911// stub stub
1912// +-------+ +---------+ +---------+
1913// | xapp | | submgr | | e2term |
1914// +-------+ +---------+ +---------+
1915// | | |
1916// | SubReq | |
1917// |------------->| |
1918// | | |
1919// | | SubReq |
1920// | |------------->|
1921// | | |
1922// | | SubResp |
1923// | <----|
1924// | |
1925// | Submgr restart |
1926// | |
1927// | | |
1928// | | SubDelReq |
1929// | |------------->|
1930// | | |
1931// | | SubDelResp |
1932// | |<-------------|
1933// | | |
1934//
1935//-----------------------------------------------------------------------------
1936
1937func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1938 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1939
1940 // Remove possible existing subscrition
1941 mainCtrl.removeExistingSubscriptions(t)
1942
1943 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1944 xappConn1.SendSubsReq(t, nil, nil)
1945 e2termConn1.RecvSubsReq(t)
1946 mainCtrl.SetResetTestFlag(t, false)
1947
1948 resp, _ := xapp.Subscription.QuerySubscriptions()
1949 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1950 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
1951 e2SubsId := uint32(resp[0].SubscriptionID)
1952 t.Logf("e2SubsId = %v", e2SubsId)
1953
1954 mainCtrl.SimulateRestart(t) // This will trigger sending of SubDelReq
1955
1956 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1957 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1958
1959 // Wait that subs is cleaned
1960 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1961
1962 xappConn1.TestMsgChanEmpty(t)
1963 xappConn2.TestMsgChanEmpty(t)
1964 e2termConn1.TestMsgChanEmpty(t)
1965 mainCtrl.wait_registry_empty(t, 10)
1966}
1967
1968//-----------------------------------------------------------------------------
1969// TestSubReqAndSubDelOkWithRestartInMiddle
1970//
1971// stub stub
1972// +-------+ +---------+ +---------+
1973// | xapp | | submgr | | e2term |
1974// +-------+ +---------+ +---------+
1975// | | |
1976// | SubReq | |
1977// |------------->| |
1978// | | |
1979// | | SubReq |
1980// | |------------->|
1981// | | |
1982// | | SubResp |
1983// | |<-------------|
1984// | | |
1985// | SubResp | |
1986// |<-------------| |
1987// | | |
1988// | |
1989// | Submgr restart |
1990// | |
1991// | SubDelReq | |
1992// |------------->| |
1993// | | |
1994// | | SubDelReq |
1995// | |------------->|
1996// | | |
1997// | | SubDelResp |
1998// | |<-------------|
1999// | | |
2000// | SubDelResp | |
2001// |<-------------| |
2002//
2003//-----------------------------------------------------------------------------
2004
2005func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2006 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2007
2008 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2009 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2010 e2termConn1.SendSubsResp(t, crereq, cremsg)
2011 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2012
2013 // Check subscription
2014 resp, _ := xapp.Subscription.QuerySubscriptions()
2015 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2016 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2017 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
2018
2019 mainCtrl.SimulateRestart(t)
2020
2021 // Check that subscription is restored correctly after restart
2022 resp, _ = xapp.Subscription.QuerySubscriptions()
2023 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2024 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2025 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
2026
2027 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2028 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2029 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2030 xappConn1.RecvSubsDelResp(t, deltrans)
2031
2032 //Wait that subs is cleaned
2033 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2034
2035 xappConn1.TestMsgChanEmpty(t)
2036 xappConn2.TestMsgChanEmpty(t)
2037 e2termConn1.TestMsgChanEmpty(t)
2038 mainCtrl.wait_registry_empty(t, 10)
2039}
2040
2041//-----------------------------------------------------------------------------
2042// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2043//
2044// stub stub
2045// +-------+ +-------+ +---------+ +---------+
2046// | xapp2 | | xapp1 | | submgr | | e2term |
2047// +-------+ +-------+ +---------+ +---------+
2048// | | | |
2049// | | | |
2050// | | | |
2051// | | SubReq1 | |
2052// | |------------->| |
2053// | | | |
2054// | | | SubReq1 |
2055// | | |------------->|
2056// | | | SubResp1 |
2057// | | |<-------------|
2058// | | SubResp1 | |
2059// | |<-------------| |
2060// | | | |
2061// | |
2062// | submgr restart |
2063// | |
2064// | | | |
2065// | | | |
2066// | SubReq2 | |
2067// |--------------------------->| |
2068// | | | |
2069// | SubResp2 | |
2070// |<---------------------------| |
2071// | | | |
2072// | | SubDelReq 1 | |
2073// | |------------->| |
2074// | | | |
2075// | | SubDelResp 1 | |
2076// | |<-------------| |
2077// | | | |
2078// | | | |
2079// | |
2080// | submgr restart |
2081// | |
2082// | | | |
2083// | SubDelReq 2 | |
2084// |--------------------------->| |
2085// | | | |
2086// | | | SubDelReq 2 |
2087// | | |------------->|
2088// | | | |
2089// | | | SubDelReq 2 |
2090// | | |------------->|
2091// | | | |
2092// | SubDelResp 2 | |
2093// |<---------------------------| |
2094//
2095//-----------------------------------------------------------------------------
2096
2097func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2098 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2099
2100 //Req1
2101 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2102 rparams1.Init()
2103 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2104 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2105 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2106 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2107
2108 //Req2
2109 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2110 rparams2.Init()
2111 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2112 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2113
2114 // Check subscription
2115 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2116 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2117 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2118 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
2119
2120 mainCtrl.SimulateRestart(t)
2121
2122 // Check that subscription is restored correctly after restart
2123 resp, _ = xapp.Subscription.QuerySubscriptions()
2124 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2125 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
2126 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
2127
2128 //Del1
2129 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2130 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2131 xappConn1.RecvSubsDelResp(t, deltrans1)
2132 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2133
2134 mainCtrl.SimulateRestart(t)
2135 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2136
2137 //Del2
2138 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2139 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2140
2141 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2142 xappConn2.RecvSubsDelResp(t, deltrans2)
2143
2144 //Wait that subs is cleaned
2145 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2146
2147 xappConn1.TestMsgChanEmpty(t)
2148 xappConn2.TestMsgChanEmpty(t)
2149 e2termConn1.TestMsgChanEmpty(t)
2150 mainCtrl.wait_registry_empty(t, 10)
2151}