RICPLT-2965 Unittest to support multiple xappconns
[ric-plt/submgr.git] / pkg / control / messaging_test.go
1 /*
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
20 package control
21
22 import (
23         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
24         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
25         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
26         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
27         "testing"
28         "time"
29 )
30
31 //-----------------------------------------------------------------------------
32 //
33 //-----------------------------------------------------------------------------
34
35 var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
36
37 //-----------------------------------------------------------------------------
38 //
39 //-----------------------------------------------------------------------------
40 type xappTransaction struct {
41         xappConn *testingXappControl
42         xid      string
43 }
44
45 func newXappTransaction(xappConn *testingXappControl) {
46         trans := &xappTransaction{}
47         trans.xappConn = xappConn
48         trans.xid = xappConn.newXid()
49 }
50
51 //-----------------------------------------------------------------------------
52 //
53 //-----------------------------------------------------------------------------
54 func (xappConn *testingXappControl) handle_xapp_subs_req(t *testing.T, updseq bool) {
55         xapp.Logger.Info("handle_xapp_subs_req")
56         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
57
58         //---------------------------------
59         // xapp activity: Send Subs Req
60         //---------------------------------
61         xapp.Logger.Info("(%s) Send Subs Req", xappConn.desc)
62
63         req := &e2ap.E2APSubscriptionRequest{}
64
65         req.RequestId.Id = 1
66         req.RequestId.Seq = 0
67         req.FunctionId = 1
68
69         req.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
70         req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
71         req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 123
72         req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
73
74         // gnb -> enb outgoing
75         // enb -> gnb incoming
76         // X2 36423-f40.doc
77         req.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
78         req.EventTriggerDefinition.ProcedureCode = 5 //28 35
79         req.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
80
81         req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
82         req.ActionSetups[0].ActionId = 0
83         req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
84         req.ActionSetups[0].ActionDefinition.Present = false
85         //req.ActionSetups[index].ActionDefinition.StyleId = 255
86         //req.ActionSetups[index].ActionDefinition.ParamId = 222
87         req.ActionSetups[0].SubsequentAction.Present = true
88         req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
89         req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
90
91         e2SubsReq.Set(req)
92         xapp.Logger.Debug("%s", e2SubsReq.String())
93         err, packedMsg := e2SubsReq.Pack(nil)
94         if err != nil {
95                 testError(t, "(%s) pack NOK %s", xappConn.desc, err.Error())
96         }
97
98         params := &xapp.RMRParams{}
99         params.Mtype = xapp.RIC_SUB_REQ
100         params.SubId = -1
101         params.Payload = packedMsg.Buf
102         params.Meid = xappConn.meid
103         if updseq {
104                 xappConn.newXid()
105         }
106         params.Xid = xappConn.xid
107         params.Mbuf = nil
108
109         snderr := xappConn.RmrSend(params)
110         if snderr != nil {
111                 testError(t, "(%s) RMR SEND FAILED: %s", xappConn.desc, snderr.Error())
112         }
113 }
114
115 //-----------------------------------------------------------------------------
116 //
117 //-----------------------------------------------------------------------------
118 func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T) int {
119         xapp.Logger.Info("handle_xapp_subs_resp")
120         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
121         var e2SubsId int
122
123         //---------------------------------
124         // xapp activity: Recv Subs Resp
125         //---------------------------------
126         select {
127         case msg := <-xappConn.rmrConChan:
128                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
129                         testError(t, "(%s) Received wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
130                         return -1
131                 } else {
132                         packedData := &packer.PackedData{}
133                         packedData.Buf = msg.Payload
134                         e2SubsId = msg.SubId
135                         unpackerr := e2SubsResp.UnPack(packedData)
136
137                         if unpackerr != nil {
138                                 testError(t, "(%s) RIC_SUB_RESP unpack failed err: %s", xappConn.desc, unpackerr.Error())
139                         }
140                         geterr, resp := e2SubsResp.Get()
141                         if geterr != nil {
142                                 testError(t, "(%s) RIC_SUB_RESP get failed err: %s", xappConn.desc, geterr.Error())
143                         }
144
145                         xapp.Logger.Info("(%s) Recv Subs Resp rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.desc, msg.Xid, msg.SubId, resp.RequestId.Seq)
146                         return e2SubsId
147                 }
148         case <-time.After(15 * time.Second):
149                 testError(t, "(%s) Not Received RIC_SUB_RESP within 15 secs", xappConn.desc)
150                 return -1
151         }
152         return -1
153 }
154
155 //-----------------------------------------------------------------------------
156 //
157 //-----------------------------------------------------------------------------
158 func (xappConn *testingXappControl) handle_xapp_subs_del_req(t *testing.T, updseq bool, e2SubsId int) {
159         xapp.Logger.Info("handle_xapp_subs_del_req")
160         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
161
162         //---------------------------------
163         // xapp activity: Send Subs Del Req
164         //---------------------------------
165         xapp.Logger.Info("(%s) Send Subs Del Req", xappConn.desc)
166
167         req := &e2ap.E2APSubscriptionDeleteRequest{}
168         req.RequestId.Id = 1
169         req.RequestId.Seq = uint32(e2SubsId)
170         req.FunctionId = 1
171
172         e2SubsDelReq.Set(req)
173         xapp.Logger.Debug("%s", e2SubsDelReq.String())
174         err, packedMsg := e2SubsDelReq.Pack(nil)
175         if err != nil {
176                 testError(t, "(%s) pack NOK %s", xappConn.desc, err.Error())
177         }
178
179         params := &xapp.RMRParams{}
180         params.Mtype = xapp.RIC_SUB_DEL_REQ
181         params.SubId = e2SubsId
182         params.Payload = packedMsg.Buf
183         params.Meid = xappConn.meid
184         if updseq {
185                 xappConn.newXid()
186         }
187         params.Xid = xappConn.xid
188         params.Mbuf = nil
189
190         snderr := xappConn.RmrSend(params)
191         if snderr != nil {
192                 testError(t, "(%s) RMR SEND FAILED: %s", xappConn.desc, snderr.Error())
193         }
194 }
195
196 //-----------------------------------------------------------------------------
197 //
198 //-----------------------------------------------------------------------------
199 func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T) {
200         xapp.Logger.Info("handle_xapp_subs_del_resp")
201         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
202
203         //---------------------------------
204         // xapp activity: Recv Subs Del Resp
205         //---------------------------------
206         select {
207         case msg := <-xappConn.rmrConChan:
208                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
209                         testError(t, "(%s) Received wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
210                         return
211                 } else {
212                         packedData := &packer.PackedData{}
213                         packedData.Buf = msg.Payload
214                         unpackerr := e2SubsDelResp.UnPack(packedData)
215                         if unpackerr != nil {
216                                 testError(t, "(%s) RIC_SUB_DEL_RESP unpack failed err: %s", xappConn.desc, unpackerr.Error())
217                         }
218                         geterr, resp := e2SubsDelResp.Get()
219                         if geterr != nil {
220                                 testError(t, "(%s) RIC_SUB_DEL_RESP get failed err: %s", xappConn.desc, geterr.Error())
221                         }
222                         xapp.Logger.Info("(%s) Recv Subs Del Resp rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.desc, msg.Xid, msg.SubId, resp.RequestId.Seq)
223                         return
224                 }
225         case <-time.After(15 * time.Second):
226                 testError(t, "(%s) Not Received RIC_SUB_DEL_RESP within 15 secs", xappConn.desc)
227         }
228 }
229
230 //-----------------------------------------------------------------------------
231 //
232 //-----------------------------------------------------------------------------
233 func (e2termConn *testingE2termControl) handle_e2term_subs_req(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) {
234         xapp.Logger.Info("handle_e2term_subs_req")
235         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
236
237         //---------------------------------
238         // e2term activity: Recv Subs Req
239         //---------------------------------
240         select {
241         case msg := <-e2termConn.rmrConChan:
242                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
243                         testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.desc, "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
244                 } else {
245                         xapp.Logger.Info("(%s) Recv Subs Req", e2termConn.desc)
246                         packedData := &packer.PackedData{}
247                         packedData.Buf = msg.Payload
248                         unpackerr := e2SubsReq.UnPack(packedData)
249                         if unpackerr != nil {
250                                 testError(t, "(%s) RIC_SUB_REQ unpack failed err: %s", e2termConn.desc, unpackerr.Error())
251                         }
252                         geterr, req := e2SubsReq.Get()
253                         if geterr != nil {
254                                 testError(t, "(%s) RIC_SUB_REQ get failed err: %s", e2termConn.desc, geterr.Error())
255                         }
256                         return req, msg
257                 }
258         case <-time.After(15 * time.Second):
259                 testError(t, "(%s) Not Received RIC_SUB_REQ within 15 secs", e2termConn.desc)
260         }
261         return nil, nil
262 }
263
264 func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
265         xapp.Logger.Info("handle_e2term_subs_resp")
266         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
267
268         //---------------------------------
269         // e2term activity: Send Subs Resp
270         //---------------------------------
271         xapp.Logger.Info("(%s) Send Subs Resp", e2termConn.desc)
272
273         resp := &e2ap.E2APSubscriptionResponse{}
274
275         resp.RequestId.Id = req.RequestId.Id
276         resp.RequestId.Seq = req.RequestId.Seq
277         resp.FunctionId = req.FunctionId
278
279         resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
280         for index := int(0); index < len(req.ActionSetups); index++ {
281                 resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
282         }
283
284         for index := uint64(0); index < 1; index++ {
285                 item := e2ap.ActionNotAdmittedItem{}
286                 item.ActionId = index
287                 item.Cause.Content = 1
288                 item.Cause.CauseVal = 1
289                 resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
290         }
291
292         e2SubsResp.Set(resp)
293         xapp.Logger.Debug("%s", e2SubsResp.String())
294         packerr, packedMsg := e2SubsResp.Pack(nil)
295         if packerr != nil {
296                 testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error())
297         }
298
299         params := &xapp.RMRParams{}
300         params.Mtype = xapp.RIC_SUB_RESP
301         params.SubId = msg.SubId
302         params.Payload = packedMsg.Buf
303         params.Meid = msg.Meid
304         params.Xid = msg.Xid
305         params.Mbuf = nil
306
307         snderr := e2termConn.RmrSend(params)
308         if snderr != nil {
309                 testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.desc, snderr.Error())
310         }
311 }
312
313 //-----------------------------------------------------------------------------
314 //
315 //-----------------------------------------------------------------------------
316 func (e2termConn *testingE2termControl) handle_e2term_subs_del_req(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) {
317         xapp.Logger.Info("handle_e2term_subs_del_req")
318         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
319
320         //---------------------------------
321         // e2term activity: Recv Subs Del Req
322         //---------------------------------
323         select {
324         case msg := <-e2termConn.rmrConChan:
325                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
326                         testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.desc, "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
327                 } else {
328                         xapp.Logger.Info("(%s) Recv Subs Del Req", e2termConn.desc)
329
330                         packedData := &packer.PackedData{}
331                         packedData.Buf = msg.Payload
332                         unpackerr := e2SubsDelReq.UnPack(packedData)
333                         if unpackerr != nil {
334                                 testError(t, "(%s) RIC_SUB_DEL_REQ unpack failed err: %s", e2termConn.desc, unpackerr.Error())
335                         }
336                         geterr, req := e2SubsDelReq.Get()
337                         if geterr != nil {
338                                 testError(t, "(%s) RIC_SUB_DEL_REQ get failed err: %s", e2termConn.desc, geterr.Error())
339                         }
340                         return req, msg
341                 }
342         case <-time.After(15 * time.Second):
343                 testError(t, "(%s) Not Received RIC_SUB_DEL_REQ within 15 secs", e2termConn.desc)
344         }
345         return nil, nil
346 }
347
348 func handle_e2term_recv_empty() bool {
349         if len(e2termConn.rmrConChan) > 0 {
350                 return false
351         }
352         return true
353 }
354
355 func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
356         xapp.Logger.Info("handle_e2term_subs_del_resp")
357         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
358
359         //---------------------------------
360         // e2term activity: Send Subs Del Resp
361         //---------------------------------
362         xapp.Logger.Info("(%s) Send Subs Del Resp", e2termConn.desc)
363
364         resp := &e2ap.E2APSubscriptionDeleteResponse{}
365         resp.RequestId.Id = req.RequestId.Id
366         resp.RequestId.Seq = req.RequestId.Seq
367         resp.FunctionId = req.FunctionId
368
369         e2SubsDelResp.Set(resp)
370         xapp.Logger.Debug("%s", e2SubsDelResp.String())
371         packerr, packedMsg := e2SubsDelResp.Pack(nil)
372         if packerr != nil {
373                 testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error())
374         }
375
376         params := &xapp.RMRParams{}
377         params.Mtype = xapp.RIC_SUB_DEL_RESP
378         params.SubId = msg.SubId
379         params.Payload = packedMsg.Buf
380         params.Meid = msg.Meid
381         params.Xid = msg.Xid
382         params.Mbuf = nil
383
384         snderr := e2termConn.RmrSend(params)
385         if snderr != nil {
386                 testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.desc, snderr.Error())
387         }
388
389 }
390
391 //-----------------------------------------------------------------------------
392 //
393 //-----------------------------------------------------------------------------
394 func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs int) bool {
395         i := 1
396         for ; i <= secs*2; i++ {
397                 if mc.c.registry.IsValidSequenceNumber(uint16(e2SubsId)) == false {
398                         return true
399                 }
400                 time.Sleep(500 * time.Millisecond)
401         }
402         testError(t, "(general) no clean within %d secs", secs)
403         return false
404 }
405
406 //-----------------------------------------------------------------------------
407 // TestSubReqAndSubDelOk
408 //
409 //   stub                          stub
410 // +-------+     +---------+    +---------+
411 // | xapp  |     | submgr  |    | e2term  |
412 // +-------+     +---------+    +---------+
413 //     |              |              |
414 //     | SubReq       |              |
415 //     |------------->|              |
416 //     |              |              |
417 //     |              | SubReq       |
418 //     |              |------------->|
419 //     |              |              |
420 //     |              |      SubResp |
421 //     |              |<-------------|
422 //     |              |              |
423 //     |      SubResp |              |
424 //     |<-------------|              |
425 //     |              |              |
426 //     |              |              |
427 //     | SubDelReq    |              |
428 //     |------------->|              |
429 //     |              |              |
430 //     |              | SubDelReq    |
431 //     |              |------------->|
432 //     |              |              |
433 //     |              |   SubDelResp |
434 //     |              |<-------------|
435 //     |              |              |
436 //     |   SubDelResp |              |
437 //     |<-------------|              |
438 //
439 //-----------------------------------------------------------------------------
440 func TestSubReqAndSubDelOk(t *testing.T) {
441         xapp.Logger.Info("TestSubReqAndSubDelOk")
442
443         xappConn1.handle_xapp_subs_req(t, true)
444         crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
445         e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
446         e2SubsId := xappConn1.handle_xapp_subs_resp(t)
447
448         xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId)
449         delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
450         e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
451         xappConn1.handle_xapp_subs_del_resp(t)
452
453         //Wait that subs is cleaned
454         mainCtrl.wait_subs_clean(t, e2SubsId, 10)
455 }
456
457 //-----------------------------------------------------------------------------
458 // TestSubReqRetransmission
459 //
460 //   stub                          stub
461 // +-------+     +---------+    +---------+
462 // | xapp  |     | submgr  |    | e2term  |
463 // +-------+     +---------+    +---------+
464 //     |              |              |
465 //     |  SubReq      |              |
466 //     |------------->|              |
467 //     |              |              |
468 //     |              | SubReq       |
469 //     |              |------------->|
470 //     |              |              |
471 //     |  SubReq      |              |
472 //     | (retrans)    |              |
473 //     |------------->|              |
474 //     |              |              |
475 //     |              |      SubResp |
476 //     |              |<-------------|
477 //     |              |              |
478 //     |      SubResp |              |
479 //     |<-------------|              |
480 //     |              |              |
481 //     |         [SUBS DELETE]       |
482 //     |              |              |
483 //
484 //-----------------------------------------------------------------------------
485 func TestSubReqRetransmission(t *testing.T) {
486         xapp.Logger.Info("TestSubReqRetransmission")
487
488         //Subs Create
489         xappConn1.handle_xapp_subs_req(t, true)
490         crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
491         xappConn1.handle_xapp_subs_req(t, false)
492
493         e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
494
495         e2SubsId := xappConn1.handle_xapp_subs_resp(t)
496
497         //Subs Delete
498         xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId)
499         delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
500         e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
501         xappConn1.handle_xapp_subs_del_resp(t)
502
503         //Wait that subs is cleaned
504         mainCtrl.wait_subs_clean(t, e2SubsId, 10)
505 }
506
507 //-----------------------------------------------------------------------------
508 // TestSubDelReqRetransmission
509 //
510 //   stub                          stub
511 // +-------+     +---------+    +---------+
512 // | xapp  |     | submgr  |    | e2term  |
513 // +-------+     +---------+    +---------+
514 //     |              |              |
515 //     |         [SUBS CREATE]       |
516 //     |              |              |
517 //     |              |              |
518 //     | SubDelReq    |              |
519 //     |------------->|              |
520 //     |              |              |
521 //     |              | SubDelReq    |
522 //     |              |------------->|
523 //     |              |              |
524 //     | SubDelReq    |              |
525 //     |------------->|              |
526 //     |              |              |
527 //     |              |   SubDelResp |
528 //     |              |<-------------|
529 //     |              |              |
530 //     |   SubDelResp |              |
531 //     |<-------------|              |
532 //
533 //-----------------------------------------------------------------------------
534 func TestSubDelReqRetransmission(t *testing.T) {
535         xapp.Logger.Info("TestSubDelReqRetransmission")
536
537         //Subs Create
538         xappConn1.handle_xapp_subs_req(t, true)
539         crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
540         e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
541         e2SubsId := xappConn1.handle_xapp_subs_resp(t)
542
543         //Subs Delete
544         xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId)
545         delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
546
547         <-time.After(2 * time.Second)
548         xappConn1.handle_xapp_subs_del_req(t, false, e2SubsId)
549
550         e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
551         xappConn1.handle_xapp_subs_del_resp(t)
552
553         //Wait that subs is cleaned
554         mainCtrl.wait_subs_clean(t, e2SubsId, 10)
555 }
556
557 //-----------------------------------------------------------------------------
558 // TestSubReqAndSubDelOkTwoParallel
559 //
560 //   stub                          stub
561 // +-------+     +---------+    +---------+
562 // | xapp  |     | submgr  |    | e2term  |
563 // +-------+     +---------+    +---------+
564 //     |              |              |
565 //     |              |              |
566 //     |              |              |
567 //     | SubReq1      |              |
568 //     |------------->|              |
569 //     |              |              |
570 //     |              | SubReq1      |
571 //     |              |------------->|
572 //     |              |              |
573 //     | SubReq2      |              |
574 //     |------------->|              |
575 //     |              |              |
576 //     |              | SubReq2      |
577 //     |              |------------->|
578 //     |              |              |
579 //     |              |    SubResp1  |
580 //     |              |<-------------|
581 //     |              |    SubResp2  |
582 //     |              |<-------------|
583 //     |              |              |
584 //     |    SubResp1  |              |
585 //     |<-------------|              |
586 //     |    SubResp2  |              |
587 //     |<-------------|              |
588 //     |              |              |
589 //     |        [SUBS 1 DELETE]      |
590 //     |              |              |
591 //     |        [SUBS 2 DELETE]      |
592 //     |              |              |
593 //
594 //-----------------------------------------------------------------------------
595 func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
596         xapp.Logger.Info("TestSubReqAndSubDelOkTwoParallel")
597
598         //Req1
599         xappConn1.handle_xapp_subs_req(t, true)
600         crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
601
602         //Req2
603         xappConn2.handle_xapp_subs_req(t, true)
604         crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
605
606         //Resp1
607         e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
608         e2SubsId1 := xappConn1.handle_xapp_subs_resp(t)
609
610         //Resp2
611         e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
612         e2SubsId2 := xappConn2.handle_xapp_subs_resp(t)
613
614         //Del1
615         xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId1)
616         delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
617         e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
618         xappConn1.handle_xapp_subs_del_resp(t)
619         //Wait that subs is cleaned
620         mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
621
622         //Del2
623         xappConn2.handle_xapp_subs_del_req(t, true, e2SubsId2)
624         delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
625         e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
626         xappConn2.handle_xapp_subs_del_resp(t)
627         //Wait that subs is cleaned
628         mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
629 }