blob: 2e8bc0e34c2d77d440a9f5f786493d9e30aec91a [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 (
23 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
24 "testing"
25)
26
27//-----------------------------------------------------------------------------
28// TestSubReqAndRouteNok
29//
30// stub stub
31// +-------+ +---------+ +---------+
32// | xapp | | submgr | | rtmgr |
33// +-------+ +---------+ +---------+
34// | | |
35// | SubReq | |
36// |------------->| |
37// | | |
38// | | RouteCreate |
39// | |------------->|
40// | | |
41// | | RouteCreate |
42// | | status:400 |
43// | |<-------------|
44// | | |
45// | [SUBS INT DELETE] |
46// | | |
47//
48//-----------------------------------------------------------------------------
49
50func TestSubReqAndRouteNok(t *testing.T) {
51 xapp.Logger.Info("TestSubReqAndRouteNok")
52
53 waiter := rtmgrHttp.AllocNextEvent(false)
54 newSubsId := mainCtrl.get_subid(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020055 xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020056 waiter.WaitResult(t)
57
58 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020059 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020060
61 xappConn1.TestMsgCnt(t)
62 xappConn2.TestMsgCnt(t)
63 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020064 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020065}
66
67//-----------------------------------------------------------------------------
68// TestSubReqAndSubDelOk
69//
70// stub stub
71// +-------+ +---------+ +---------+
72// | xapp | | submgr | | e2term |
73// +-------+ +---------+ +---------+
74// | | |
75// | SubReq | |
76// |------------->| |
77// | | |
78// | | SubReq |
79// | |------------->|
80// | | |
81// | | SubResp |
82// | |<-------------|
83// | | |
84// | SubResp | |
85// |<-------------| |
86// | | |
87// | | |
88// | SubDelReq | |
89// |------------->| |
90// | | |
91// | | SubDelReq |
92// | |------------->|
93// | | |
94// | | SubDelResp |
95// | |<-------------|
96// | | |
97// | SubDelResp | |
98// |<-------------| |
99//
100//-----------------------------------------------------------------------------
101func TestSubReqAndSubDelOk(t *testing.T) {
102 xapp.Logger.Info("TestSubReqAndSubDelOk")
103
104 waiter := rtmgrHttp.AllocNextEvent(true)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200105 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200106 waiter.WaitResult(t)
107
108 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
109 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
110 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
111 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
112 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
113
114 waiter = rtmgrHttp.AllocNextEvent(true)
115 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
116 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
117 waiter.WaitResult(t)
118
119 //Wait that subs is cleaned
120 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
121
122 xappConn1.TestMsgCnt(t)
123 xappConn2.TestMsgCnt(t)
124 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200125 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200126}
127
128//-----------------------------------------------------------------------------
129// TestSubReqRetransmission
130//
131// stub stub
132// +-------+ +---------+ +---------+
133// | xapp | | submgr | | e2term |
134// +-------+ +---------+ +---------+
135// | | |
136// | SubReq | |
137// |------------->| |
138// | | |
139// | | SubReq |
140// | |------------->|
141// | | |
142// | SubReq | |
143// | (retrans) | |
144// |------------->| |
145// | | |
146// | | SubResp |
147// | |<-------------|
148// | | |
149// | SubResp | |
150// |<-------------| |
151// | | |
152// | [SUBS DELETE] |
153// | | |
154//
155//-----------------------------------------------------------------------------
156func TestSubReqRetransmission(t *testing.T) {
157 xapp.Logger.Info("TestSubReqRetransmission")
158
159 //Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200160 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200161 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
162
163 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200164 xappConn1.handle_xapp_subs_req(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200165 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
166
167 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
168 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
169
170 //Subs Delete
171 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
172 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
173 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
174 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
175
176 //Wait that subs is cleaned
177 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
178
179 xappConn1.TestMsgCnt(t)
180 xappConn2.TestMsgCnt(t)
181 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200182 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200183}
184
185//-----------------------------------------------------------------------------
186// TestSubDelReqRetransmission
187//
188// stub stub
189// +-------+ +---------+ +---------+
190// | xapp | | submgr | | e2term |
191// +-------+ +---------+ +---------+
192// | | |
193// | [SUBS CREATE] |
194// | | |
195// | | |
196// | SubDelReq | |
197// |------------->| |
198// | | |
199// | | SubDelReq |
200// | |------------->|
201// | | |
202// | SubDelReq | |
203// | (same sub) | |
204// | (same xid) | |
205// |------------->| |
206// | | |
207// | | SubDelResp |
208// | |<-------------|
209// | | |
210// | SubDelResp | |
211// |<-------------| |
212//
213//-----------------------------------------------------------------------------
214func TestSubDelReqRetransmission(t *testing.T) {
215 xapp.Logger.Info("TestSubDelReqRetransmission")
216
217 //Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200218 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200219 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
220 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
221 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
222
223 //Subs Delete
224 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
225 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
226
227 seqBef := mainCtrl.get_msgcounter(t)
228 xappConn1.handle_xapp_subs_del_req(t, deltrans, e2SubsId) //Retransmitted SubDelReq
229 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
230
231 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
232 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
233
234 //Wait that subs is cleaned
235 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
236
237 xappConn1.TestMsgCnt(t)
238 xappConn2.TestMsgCnt(t)
239 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200240 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200241}
242
243//-----------------------------------------------------------------------------
244// TestSubDelReqCollision
245//
246// stub stub
247// +-------+ +---------+ +---------+
248// | xapp | | submgr | | e2term |
249// +-------+ +---------+ +---------+
250// | | |
251// | [SUBS CREATE] |
252// | | |
253// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200254// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200255// |------------->| |
256// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200257// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200258// | |------------->|
259// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200260// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200261// | (same sub) | |
262// | (diff xid) | |
263// |------------->| |
264// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200265// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200266// | |<-------------|
267// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200268// | SubDelResp 1 | |
269// |<-------------| |
270// | | |
271// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200272// |<-------------| |
273//
274//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200275
Juha Hyttinenfa015662020-01-24 10:05:18 +0200276func TestSubDelReqCollision(t *testing.T) {
277 xapp.Logger.Info("TestSubDelReqCollision")
278
279 //Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200280 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200281 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
282 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
283 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
284
285 //Subs Delete
Juha Hyttinen3944a222020-01-24 11:51:46 +0200286 xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
287 delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200288
Juha Hyttinen3944a222020-01-24 11:51:46 +0200289 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200290 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200291 deltranscol2 := xappConn1.newXappTransaction(nil, "RAN_NAME_1")
292 xappConn1.handle_xapp_subs_del_req(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200293 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
294
Juha Hyttinen3944a222020-01-24 11:51:46 +0200295 // Del resp for first and second
296 e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
297
298 // don't care in which order responses are received
299 xappConn1.handle_xapp_subs_del_resp(t, nil)
300 xappConn1.handle_xapp_subs_del_resp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200301
302 //Wait that subs is cleaned
303 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
304
305 xappConn1.TestMsgCnt(t)
306 xappConn2.TestMsgCnt(t)
307 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200308 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200309}
310
311//-----------------------------------------------------------------------------
312// TestSubReqAndSubDelOkTwoParallel
313//
314// stub stub
315// +-------+ +---------+ +---------+
316// | xapp | | submgr | | e2term |
317// +-------+ +---------+ +---------+
318// | | |
319// | | |
320// | | |
321// | SubReq1 | |
322// |------------->| |
323// | | |
324// | | SubReq1 |
325// | |------------->|
326// | | |
327// | SubReq2 | |
328// |------------->| |
329// | | |
330// | | SubReq2 |
331// | |------------->|
332// | | |
333// | | SubResp1 |
334// | |<-------------|
335// | | SubResp2 |
336// | |<-------------|
337// | | |
338// | SubResp1 | |
339// |<-------------| |
340// | SubResp2 | |
341// |<-------------| |
342// | | |
343// | [SUBS 1 DELETE] |
344// | | |
345// | [SUBS 2 DELETE] |
346// | | |
347//
348//-----------------------------------------------------------------------------
349func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
350 xapp.Logger.Info("TestSubReqAndSubDelOkTwoParallel")
351
352 //Req1
Juha Hyttinen3944a222020-01-24 11:51:46 +0200353 rparams1 := &test_subs_req_params{}
354 rparams1.Init()
355 rparams1.req.EventTriggerDefinition.ProcedureCode = 5
356 cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200357 crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
358
359 //Req2
Juha Hyttinen3944a222020-01-24 11:51:46 +0200360 rparams2 := &test_subs_req_params{}
361 rparams2.Init()
362 rparams2.req.EventTriggerDefinition.ProcedureCode = 28
363 cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200364 crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
365
366 //Resp1
367 e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
368 e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
369
370 //Resp2
371 e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
372 e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
373
374 //Del1
375 deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
376 delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
377 e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
378 xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
379 //Wait that subs is cleaned
380 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
381
382 //Del2
383 deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
384 delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
385 e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
386 xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
387 //Wait that subs is cleaned
388 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
389
390 xappConn1.TestMsgCnt(t)
391 xappConn2.TestMsgCnt(t)
392 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200393 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200394}
395
396//-----------------------------------------------------------------------------
397// TestSameSubsDiffRan
398// Same subscription to different RANs
399//
400// stub stub
401// +-------+ +---------+ +---------+
402// | xapp | | submgr | | e2term |
403// +-------+ +---------+ +---------+
404// | | |
405// | | |
406// | | |
407// | SubReq(r1) | |
408// |------------->| |
409// | | |
410// | | SubReq(r1) |
411// | |------------->|
412// | | |
413// | | SubResp(r1) |
414// | |<-------------|
415// | | |
416// | SubResp(r1) | |
417// |<-------------| |
418// | | |
419// | SubReq(r2) | |
420// |------------->| |
421// | | |
422// | | SubReq(r2) |
423// | |------------->|
424// | | |
425// | | SubResp(r2) |
426// | |<-------------|
427// | | |
428// | SubResp(r2) | |
429// |<-------------| |
430// | | |
431// | [SUBS r1 DELETE] |
432// | | |
433// | [SUBS r2 DELETE] |
434// | | |
435//
436//-----------------------------------------------------------------------------
437func TestSameSubsDiffRan(t *testing.T) {
438 xapp.Logger.Info("TestSameSubsDiffRan")
439
440 //Req1
441 cretrans1 := xappConn1.newXappTransaction(nil, "RAN_NAME_1")
Juha Hyttinen3944a222020-01-24 11:51:46 +0200442 xappConn1.handle_xapp_subs_req(t, nil, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200443 crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
444 e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
445 e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
446
447 //Req2
448 cretrans2 := xappConn1.newXappTransaction(nil, "RAN_NAME_2")
Juha Hyttinen3944a222020-01-24 11:51:46 +0200449 xappConn1.handle_xapp_subs_req(t, nil, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200450 crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
451 e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
452 e2SubsId2 := xappConn1.handle_xapp_subs_resp(t, cretrans2)
453
454 //Del1
455 deltrans1 := xappConn1.newXappTransaction(nil, "RAN_NAME_1")
456 xappConn1.handle_xapp_subs_del_req(t, deltrans1, e2SubsId1)
457 delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
458 e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
459 xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
460 //Wait that subs is cleaned
461 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
462
463 //Del2
464 deltrans2 := xappConn1.newXappTransaction(nil, "RAN_NAME_2")
465 xappConn1.handle_xapp_subs_del_req(t, deltrans2, e2SubsId2)
466 delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
467 e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
468 xappConn1.handle_xapp_subs_del_resp(t, deltrans2)
469 //Wait that subs is cleaned
470 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
471
472 xappConn1.TestMsgCnt(t)
473 xappConn2.TestMsgCnt(t)
474 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200475 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200476}
477
478//-----------------------------------------------------------------------------
479// TestSubReqRetryInSubmgr
480//
481// stub stub
482// +-------+ +---------+ +---------+
483// | xapp | | submgr | | e2term |
484// +-------+ +---------+ +---------+
485// | | |
486// | SubReq | |
487// |------------->| |
488// | | |
489// | | SubReq |
490// | |------------->|
491// | | |
492// | | |
493// | | SubReq |
494// | |------------->|
495// | | |
496// | | SubResp |
497// | |<-------------|
498// | | |
499// | SubResp | |
500// |<-------------| |
501// | | |
502// | [SUBS DELETE] |
503// | | |
504//
505//-----------------------------------------------------------------------------
506
507func TestSubReqRetryInSubmgr(t *testing.T) {
508
509 xapp.Logger.Info("TestSubReqRetryInSubmgr start")
510
511 // Xapp: Send SubsReq
Juha Hyttinen3944a222020-01-24 11:51:46 +0200512 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200513
514 // E2t: Receive 1st SubsReq
515 e2termConn.handle_e2term_subs_req(t)
516
517 // E2t: Receive 2nd SubsReq and send SubsResp
518 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
519 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
520
521 // Xapp: Receive SubsResp
522 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
523
524 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
525 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
526 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
527 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
528
529 // Wait that subs is cleaned
530 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
531
532 xappConn1.TestMsgCnt(t)
533 xappConn2.TestMsgCnt(t)
534 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200535 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200536}
537
538//-----------------------------------------------------------------------------
539// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
540//
541// stub stub
542// +-------+ +---------+ +---------+
543// | xapp | | submgr | | e2term |
544// +-------+ +---------+ +---------+
545// | | |
546// | SubReq | |
547// |------------->| |
548// | | |
549// | | SubReq |
550// | |------------->|
551// | | |
552// | | |
553// | | SubReq |
554// | |------------->|
555// | | |
556// | | SubDelReq |
557// | |------------->|
558// | | |
559// | | |
560// | | SubDelReq |
561// | |------------->|
562// | | |
563// | | |
564// | | SubDelResp |
565// | |<-------------|
566// | | |
567//
568//-----------------------------------------------------------------------------
569
570func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
571
572 xapp.Logger.Info("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
573
574 // Xapp: Send SubsReq
Juha Hyttinen3944a222020-01-24 11:51:46 +0200575 xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576
577 // E2t: Receive 1st SubsReq
578 e2termConn.handle_e2term_subs_req(t)
579
580 // E2t: Receive 2nd SubsReq
581 e2termConn.handle_e2term_subs_req(t)
582
583 // E2t: Send receive SubsDelReq and send SubsResp
584 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
585 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
586
587 // Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200588 mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200589
590 xappConn1.TestMsgCnt(t)
591 xappConn2.TestMsgCnt(t)
592 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200593 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200594}
595
596//-----------------------------------------------------------------------------
597// TestSubReqTwoRetriesNoRespAtAllInSubmgr
598//
599// stub stub
600// +-------+ +---------+ +---------+
601// | xapp | | submgr | | e2term |
602// +-------+ +---------+ +---------+
603// | | |
604// | SubReq | |
605// |------------->| |
606// | | |
607// | | SubReq |
608// | |------------->|
609// | | |
610// | | |
611// | | SubReq |
612// | |------------->|
613// | | |
614// | | SubDelReq |
615// | |------------->|
616// | | |
617// | | |
618// | | SubDelReq |
619// | |------------->|
620// | | |
621// | | |
622//
623//-----------------------------------------------------------------------------
624
625func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
626
627 xapp.Logger.Info("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
628
629 // Xapp: Send SubsReq
Juha Hyttinen3944a222020-01-24 11:51:46 +0200630 xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200631
632 // E2t: Receive 1st SubsReq
633 e2termConn.handle_e2term_subs_req(t)
634
635 // E2t: Receive 2nd SubsReq
636 e2termConn.handle_e2term_subs_req(t)
637
638 // E2t: Receive 1st SubsDelReq
639 e2termConn.handle_e2term_subs_del_req(t)
640
641 // E2t: Receive 2nd SubsDelReq
642 delreq, _ := e2termConn.handle_e2term_subs_del_req(t)
643
644 // Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200645 mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200646
647 xappConn1.TestMsgCnt(t)
648 xappConn2.TestMsgCnt(t)
649 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200650 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200651}
652
653//-----------------------------------------------------------------------------
654// TestSubReqSubFailRespInSubmgr
655//
656// stub stub
657// +-------+ +---------+ +---------+
658// | xapp | | submgr | | e2term |
659// +-------+ +---------+ +---------+
660// | | |
661// | SubReq | |
662// |------------->| |
663// | | |
664// | | SubReq |
665// | |------------->|
666// | | |
667// | | SubFail |
668// | |<-------------|
669// | | |
670// | SubFail | |
671// |<-------------| |
672// | | |
673//
674//-----------------------------------------------------------------------------
675
676func TestSubReqSubFailRespInSubmgr(t *testing.T) {
677
678 xapp.Logger.Info("TestSubReqSubFailRespInSubmgr start")
679
680 // Xapp: Send SubsReq
Juha Hyttinen3944a222020-01-24 11:51:46 +0200681 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200682
683 // E2t: Receive SubsReq and send SubsFail
684 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
685 fparams := &test_subs_fail_params{}
686 fparams.Set(crereq)
687 e2termConn.handle_e2term_subs_fail(t, fparams, cremsg)
688
689 // Xapp: Receive SubsFail
690 e2SubsId := xappConn1.handle_xapp_subs_fail(t, cretrans)
691
692 // Wait that subs is cleaned
693 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
694
695 xappConn1.TestMsgCnt(t)
696 xappConn2.TestMsgCnt(t)
697 e2termConn.TestMsgCnt(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// TestSubDelReqRetryInSubmgr
703//
704// stub stub
705// +-------+ +---------+ +---------+
706// | xapp | | submgr | | e2term |
707// +-------+ +---------+ +---------+
708// | | |
709// | [SUBS CREATE] |
710// | | |
711// | | |
712// | SubDelReq | |
713// |------------->| |
714// | | |
715// | | SubDelReq |
716// | |------------->|
717// | | |
718// | | SubDelReq |
719// | |------------->|
720// | | |
721// | | SubDelResp |
722// | |<-------------|
723// | | |
724// | SubDelResp | |
725// |<-------------| |
726//
727//-----------------------------------------------------------------------------
728
729func TestSubDelReqRetryInSubmgr(t *testing.T) {
730
731 xapp.Logger.Info("TestSubDelReqRetryInSubmgr start")
732
733 // Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200734 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200735 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
736 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
737 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
738
739 // Subs Delete
740 // Xapp: Send SubsDelReq
741 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
742
743 // E2t: Receive 1st SubsDelReq
744 e2termConn.handle_e2term_subs_del_req(t)
745
746 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
747 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
748 e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
749
750 // Xapp: Receive SubsDelResp
751 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
752
753 // Wait that subs is cleaned
754 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
755
756 xappConn1.TestMsgCnt(t)
757 xappConn2.TestMsgCnt(t)
758 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200759 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200760}
761
762//-----------------------------------------------------------------------------
763// TestSubDelReqTwoRetriesNoRespInSubmgr
764//
765// stub stub
766// +-------+ +---------+ +---------+
767// | xapp | | submgr | | e2term |
768// +-------+ +---------+ +---------+
769// | | |
770// | [SUBS CREATE] |
771// | | |
772// | | |
773// | SubDelReq | |
774// |------------->| |
775// | | |
776// | | SubDelReq |
777// | |------------->|
778// | | |
779// | | SubDelReq |
780// | |------------->|
781// | | |
782// | | |
783// | SubDelResp | |
784// |<-------------| |
785//
786//-----------------------------------------------------------------------------
787
788func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
789
790 xapp.Logger.Info("TestSubDelReTwoRetriesNoRespInSubmgr start")
791
792 // Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200793 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200794 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
795 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
796 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
797
798 // Subs Delete
799 // Xapp: Send SubsDelReq
800 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
801
802 // E2t: Receive 1st SubsDelReq
803 e2termConn.handle_e2term_subs_del_req(t)
804
805 // E2t: Receive 2nd SubsDelReq
806 e2termConn.handle_e2term_subs_del_req(t)
807
808 // Xapp: Receive SubsDelResp
809 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
810
811 // Wait that subs is cleaned
812 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
813
814 xappConn1.TestMsgCnt(t)
815 xappConn2.TestMsgCnt(t)
816 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200817 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200818}
819
820//-----------------------------------------------------------------------------
821// TestSubDelReqSubDelFailRespInSubmgr
822//
823// stub stub
824// +-------+ +---------+ +---------+
825// | xapp | | submgr | | e2term |
826// +-------+ +---------+ +---------+
827// | | |
828// | [SUBS CREATE] |
829// | | |
830// | | |
831// | SubDelReq | |
832// |------------->| |
833// | | |
834// | | SubDelReq |
835// | |------------->|
836// | | |
837// | | SubDelFail |
838// | |<-------------|
839// | | |
840// | SubDelResp | |
841// |<-------------| |
842// | | |
843//
844//-----------------------------------------------------------------------------
845
846func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
847
848 xapp.Logger.Info("TestSubReqSubDelFailRespInSubmgr start")
849
850 // Subs Create
Juha Hyttinen3944a222020-01-24 11:51:46 +0200851 cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200852 crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
853 e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
854 e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
855
856 // Xapp: Send SubsDelReq
857 deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
858
859 // E2t: Send receive SubsDelReq and send SubsDelFail
860 delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
861 e2termConn.handle_e2term_subs_del_fail(t, delreq, delmsg)
862
863 // Xapp: Receive SubsDelResp
864 xappConn1.handle_xapp_subs_del_resp(t, deltrans)
865
866 // Wait that subs is cleaned
867 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
868
869 xappConn1.TestMsgCnt(t)
870 xappConn2.TestMsgCnt(t)
871 e2termConn.TestMsgCnt(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200872 mainCtrl.wait_registry_empty(t, 10)
873}
874
875//-----------------------------------------------------------------------------
876// TestSubReqAndSubDelOkSameAction
877//
878// stub stub
879// +-------+ +---------+ +---------+
880// | xapp | | submgr | | e2term |
881// +-------+ +---------+ +---------+
882// | | |
883// | | |
884// | | |
885// | SubReq1 | |
886// |------------->| |
887// | | |
888// | | SubReq1 |
889// | |------------->|
890// | | SubResp1 |
891// | |<-------------|
892// | SubResp1 | |
893// |<-------------| |
894// | | |
895// | SubReq2 | |
896// |------------->| |
897// | | |
898// | SubResp2 | |
899// |<-------------| |
900// | | |
901// | SubDelReq 1 | |
902// |------------->| |
903// | | |
904// | SubDelResp 1 | |
905// |<-------------| |
906// | | |
907// | SubDelReq 2 | |
908// |------------->| |
909// | | |
910// | | SubDelReq 2 |
911// | |------------->|
912// | | |
913// | | SubDelReq 2 |
914// | |------------->|
915// | | |
916// | SubDelResp 2 | |
917// |<-------------| |
918//
919//-----------------------------------------------------------------------------
920func TestSubReqAndSubDelOkSameAction(t *testing.T) {
921 xapp.Logger.Info("TestSubReqAndSubDelOkSameAction")
922
923 //Req1
924 rparams1 := &test_subs_req_params{}
925 rparams1.Init()
926 cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
927 crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
928 e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
929 e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
930
931 //Req2
932 rparams2 := &test_subs_req_params{}
933 rparams2.Init()
934 cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
935 //crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
936 //e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
937 e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
938
939 //Del1
940 deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
941 //e2termConn.handle_e2term_subs_del_req(t)
942 //e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
943 xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
944 //Wait that subs is cleaned
945 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
946
947 //Del2
948 deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
949 delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
950 e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
951 xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
952 //Wait that subs is cleaned
953 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
954
955 xappConn1.TestMsgCnt(t)
956 xappConn2.TestMsgCnt(t)
957 e2termConn.TestMsgCnt(t)
958 mainCtrl.wait_registry_empty(t, 10)
959}
960
961//-----------------------------------------------------------------------------
962// TestSubReqAndSubDelOkSameActionParallel
963//
964// stub stub
965// +-------+ +---------+ +---------+
966// | xapp | | submgr | | e2term |
967// +-------+ +---------+ +---------+
968// | | |
969// | | |
970// | | |
971// | SubReq1 | |
972// |------------->| |
973// | | |
974// | | SubReq1 |
975// | |------------->|
976// | SubReq2 | |
977// |------------->| |
978// | | SubResp1 |
979// | |<-------------|
980// | SubResp1 | |
981// |<-------------| |
982// | | |
983// | SubResp2 | |
984// |<-------------| |
985// | | |
986// | SubDelReq 1 | |
987// |------------->| |
988// | | |
989// | SubDelResp 1 | |
990// |<-------------| |
991// | | |
992// | SubDelReq 2 | |
993// |------------->| |
994// | | |
995// | | SubDelReq 2 |
996// | |------------->|
997// | | |
998// | | SubDelReq 2 |
999// | |------------->|
1000// | | |
1001// | SubDelResp 2 | |
1002// |<-------------| |
1003//
1004//-----------------------------------------------------------------------------
1005func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
1006 xapp.Logger.Info("TestSubReqAndSubDelOkSameActionParallel")
1007
1008 //Req1
1009 rparams1 := &test_subs_req_params{}
1010 rparams1.Init()
1011 cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
1012 crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
1013
1014 //Req2
1015 rparams2 := &test_subs_req_params{}
1016 rparams2.Init()
1017 cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
1018
1019 //Resp1
1020 e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
1021 e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
1022
1023 //Resp2
1024 e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
1025
1026 //Del1
1027 deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
1028 xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
1029
1030 //Del2
1031 deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
1032 delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
1033 e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
1034 xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
1035
1036 //Wait that subs is cleaned
1037 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1038
1039 xappConn1.TestMsgCnt(t)
1040 xappConn2.TestMsgCnt(t)
1041 e2termConn.TestMsgCnt(t)
1042 mainCtrl.wait_registry_empty(t, 10)
1043}
1044
1045//-----------------------------------------------------------------------------
1046// TestSubReqAndSubDelNokSameActionParallel
1047//
1048// stub stub
1049// +-------+ +---------+ +---------+
1050// | xapp | | submgr | | e2term |
1051// +-------+ +---------+ +---------+
1052// | | |
1053// | | |
1054// | | |
1055// | SubReq1 | |
1056// |------------->| |
1057// | | |
1058// | | SubReq1 |
1059// | |------------->|
1060// | SubReq2 | |
1061// |------------->| |
1062// | | SubFail1 |
1063// | |<-------------|
1064// | SubFail1 | |
1065// |<-------------| |
1066// | | |
1067// | SubFail2 | |
1068// |<-------------| |
1069//
1070//-----------------------------------------------------------------------------
1071func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
1072 xapp.Logger.Info("TestSubReqAndSubDelNokSameActionParallel")
1073
1074 //Req1
1075 rparams1 := &test_subs_req_params{}
1076 rparams1.Init()
1077 cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
1078 crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
1079
1080 //Req2
1081 rparams2 := &test_subs_req_params{}
1082 rparams2.Init()
1083 seqBef2 := mainCtrl.get_msgcounter(t)
1084 cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
1085 mainCtrl.wait_msgcounter_change(t, seqBef2, 10)
1086
1087 //E2T Fail
1088 fparams := &test_subs_fail_params{}
1089 fparams.Set(crereq1)
1090 e2termConn.handle_e2term_subs_fail(t, fparams, cremsg1)
1091
1092 //Fail1
1093 e2SubsId1 := xappConn1.handle_xapp_subs_fail(t, cretrans1)
1094 //Fail2
1095 xappConn2.handle_xapp_subs_fail(t, cretrans2)
1096
1097 //Wait that subs is cleaned
1098 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1099
1100 xappConn1.TestMsgCnt(t)
1101 xappConn2.TestMsgCnt(t)
1102 e2termConn.TestMsgCnt(t)
1103 mainCtrl.wait_registry_empty(t, 10)
1104}
1105
1106//-----------------------------------------------------------------------------
1107// TestSubReqAndSubDelNoAnswerSameActionParallel
1108//
1109// stub stub
1110// +-------+ +---------+ +---------+
1111// | xapp | | submgr | | e2term |
1112// +-------+ +---------+ +---------+
1113// | | |
1114// | | |
1115// | | |
1116// | SubReq1 | |
1117// |------------->| |
1118// | | |
1119// | | SubReq1 |
1120// | |------------->|
1121// | SubReq2 | |
1122// |------------->| |
1123// | | |
1124// | | SubReq1 |
1125// | |------------->|
1126// | | |
1127// | | |
1128// | | SubDelReq |
1129// | |------------->|
1130// | | |
1131// | | SubDelResp |
1132// | |<-------------|
1133//
1134//-----------------------------------------------------------------------------
1135func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
1136 xapp.Logger.Info("TestSubReqAndSubDelNoAnswerSameActionParallel")
1137
1138 //Req1
1139 rparams1 := &test_subs_req_params{}
1140 rparams1.Init()
1141 xappConn1.handle_xapp_subs_req(t, rparams1, nil)
1142
1143 e2termConn.handle_e2term_subs_req(t)
1144
1145 //Req2
1146 rparams2 := &test_subs_req_params{}
1147 rparams2.Init()
1148 seqBef2 := mainCtrl.get_msgcounter(t)
1149 xappConn2.handle_xapp_subs_req(t, rparams2, nil)
1150 mainCtrl.wait_msgcounter_change(t, seqBef2, 10)
1151
1152 //Req1 (retransmitted)
1153 e2termConn.handle_e2term_subs_req(t)
1154
1155 delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
1156 e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
1157
1158 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +02001159 mainCtrl.wait_subs_clean(t, delreq1.RequestId.Seq, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001160
1161 xappConn1.TestMsgCnt(t)
1162 xappConn2.TestMsgCnt(t)
1163 e2termConn.TestMsgCnt(t)
1164 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001165}