Added duplicate detection changes
[ric-plt/submgr.git] / pkg / teststube2ap / stubE2.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 teststube2ap
21
22 import (
23         "fmt"
24         "strconv"
25         "testing"
26         "time"
27
28         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
29         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
30         "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
31         clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
32         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 )
34
35 //-----------------------------------------------------------------------------
36 //
37 //-----------------------------------------------------------------------------
38 var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
39
40 //-----------------------------------------------------------------------------
41 //
42 //-----------------------------------------------------------------------------
43 type RmrTransactionId struct {
44         xid  string
45         meid *xapp.RMRMeid
46 }
47
48 type E2RestIds struct {
49         RestSubsId string
50         E2SubsId   uint32
51         ErrorCause string
52 }
53
54 func (trans *RmrTransactionId) String() string {
55         meidstr := "N/A"
56         if trans.meid != nil {
57                 meidstr = trans.meid.String()
58         }
59         return "trans(" + trans.xid + "/" + meidstr + ")"
60 }
61
62 type E2Stub struct {
63         teststub.RmrStubControl
64         xid_seq                     uint64
65         subscriptionId              string
66         requestCount                int
67         CallBackNotification        chan int64
68         RESTNotification            chan uint32
69         CallBackListedNotifications chan E2RestIds
70         ListedRESTNotifications     chan E2RestIds
71         clientEndpoint              clientmodel.SubscriptionParamsClientEndpoint
72         meid                        string
73         restSubsIdList              []string
74 }
75
76 //-----------------------------------------------------------------------------
77 //
78 //-----------------------------------------------------------------------------
79 func CreateNewE2Stub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int, ranName string, host string, RMRPort int64, HTTPPort int64) *E2Stub {
80         tc := &E2Stub{}
81         tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
82         tc.xid_seq = 1
83         tc.SetCheckXid(true)
84         tc.CallBackNotification = make(chan int64)
85         tc.RESTNotification = make(chan uint32)
86         tc.CallBackListedNotifications = make(chan E2RestIds)
87         tc.ListedRESTNotifications = make(chan E2RestIds, 2)
88         var endPoint clientmodel.SubscriptionParamsClientEndpoint
89         endPoint.Host = host
90         endPoint.HTTPPort = &HTTPPort
91         endPoint.RMRPort = &RMRPort
92         tc.clientEndpoint = endPoint
93         tc.meid = ranName
94         return tc
95 }
96
97 //-----------------------------------------------------------------------------
98 //
99 //-----------------------------------------------------------------------------
100 func CreateNewE2termStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
101         tc := &E2Stub{}
102         tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
103         tc.xid_seq = 1
104         tc.SetCheckXid(false)
105         return tc
106 }
107
108 //-----------------------------------------------------------------------------
109 //
110 //-----------------------------------------------------------------------------
111 func (tc *E2Stub) NewRmrTransactionId(xid string, ranname string) *RmrTransactionId {
112         trans := &RmrTransactionId{}
113         if len(xid) == 0 {
114                 trans.xid = tc.GetDesc() + "_XID_" + strconv.FormatUint(uint64(tc.xid_seq), 10)
115                 tc.xid_seq++
116         } else {
117                 trans.xid = xid
118         }
119         trans.meid = &xapp.RMRMeid{RanName: ranname}
120         tc.Info("New test %s", trans.String())
121         return trans
122 }
123
124 //-----------------------------------------------------------------------------
125 //
126 //-----------------------------------------------------------------------------
127 type E2StubSubsReqParams struct {
128         Req *e2ap.E2APSubscriptionRequest
129 }
130
131 func (p *E2StubSubsReqParams) Init() {
132         p.Req = &e2ap.E2APSubscriptionRequest{}
133
134         p.Req.RequestId.Id = 1
135         p.Req.RequestId.InstanceId = 0
136         p.Req.FunctionId = 1
137
138         // gnb -> enb outgoing
139         // enb -> gnb incoming
140         // X2 36423-f40.doc
141         p.Req.EventTriggerDefinition.Data.Length = 1
142         p.Req.EventTriggerDefinition.Data.Data = make([]uint8, p.Req.EventTriggerDefinition.Data.Length)
143         p.Req.EventTriggerDefinition.Data.Data[0] = 1
144
145         p.Req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
146
147         p.Req.ActionSetups[0].ActionId = 0
148         p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
149         p.Req.ActionSetups[0].RicActionDefinitionPresent = true
150
151         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length = 1
152         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data = make([]uint8, p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length)
153         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data[0] = 1
154
155         p.Req.ActionSetups[0].SubsequentAction.Present = true
156         p.Req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
157         p.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
158 }
159
160 //-----------------------------------------------------------------------------
161 //
162 //-----------------------------------------------------------------------------
163
164 type E2StubSubsFailParams struct {
165         Req  *e2ap.E2APSubscriptionRequest
166         Fail *e2ap.E2APSubscriptionFailure
167 }
168
169 func (p *E2StubSubsFailParams) Set(req *e2ap.E2APSubscriptionRequest) {
170         p.Req = req
171
172         p.Fail = &e2ap.E2APSubscriptionFailure{}
173         p.Fail.RequestId.Id = p.Req.RequestId.Id
174         p.Fail.RequestId.InstanceId = p.Req.RequestId.InstanceId
175         p.Fail.FunctionId = p.Req.FunctionId
176         p.Fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.Req.ActionSetups))
177         for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
178                 p.Fail.ActionNotAdmittedList.Items[index].ActionId = p.Req.ActionSetups[index].ActionId
179                 p.SetCauseVal(index, 5, 1)
180         }
181 }
182
183 func (p *E2StubSubsFailParams) SetCauseVal(ind int, content uint8, causeval uint8) {
184
185         if ind < 0 {
186                 for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
187                         p.Fail.ActionNotAdmittedList.Items[index].Cause.Content = content
188                         p.Fail.ActionNotAdmittedList.Items[index].Cause.Value = causeval
189                 }
190                 return
191         }
192         p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
193         p.Fail.ActionNotAdmittedList.Items[ind].Cause.Value = causeval
194 }
195
196 //-----------------------------------------------------------------------------
197 //
198 //-----------------------------------------------------------------------------
199
200 func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTrans *RmrTransactionId) *RmrTransactionId {
201
202         trans := oldTrans
203         if oldTrans == nil {
204                 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
205         }
206
207         tc.Info("SendSubsReq %s", trans.String())
208         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
209
210         //---------------------------------
211         // xapp activity: Send Subs Req
212         //---------------------------------
213         myparams := rparams
214
215         if myparams == nil {
216                 myparams = &E2StubSubsReqParams{}
217                 myparams.Init()
218         }
219
220         err, packedMsg := e2SubsReq.Pack(myparams.Req)
221         if err != nil {
222                 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
223                 return nil
224         }
225         tc.Debug("%s %s", trans.String(), e2SubsReq.String())
226
227         params := &xapp.RMRParams{}
228         params.Mtype = xapp.RIC_SUB_REQ
229         params.SubId = -1
230         params.Payload = packedMsg.Buf
231         params.PayloadLen = len(packedMsg.Buf)
232         params.Meid = trans.meid
233         params.Xid = trans.xid
234         params.Mbuf = nil
235
236         tc.Info("SEND SUB REQ: %s", params.String())
237         snderr := tc.SendWithRetry(params, false, 5)
238         if snderr != nil {
239                 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
240                 return nil
241         }
242         return trans
243 }
244
245 //-----------------------------------------------------------------------------
246 //
247 //-----------------------------------------------------------------------------
248 func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) {
249         tc.Info("RecvSubsReq")
250         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
251
252         //---------------------------------
253         // e2term activity: Recv Subs Req
254         //---------------------------------
255         msg := tc.WaitMsg(15)
256         if msg != nil {
257                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
258                         tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
259                 } else {
260                         tc.Info("Recv Subs Req")
261                         packedData := &e2ap.PackedData{}
262                         packedData.Buf = msg.Payload
263                         unpackerr, req := e2SubsReq.UnPack(packedData)
264                         if unpackerr != nil {
265                                 tc.TestError(t, "RIC_SUB_REQ unpack failed err: %s", unpackerr.Error())
266                         }
267                         return req, msg
268                 }
269         } else {
270                 tc.TestError(t, "Not Received msg within %d secs", 15)
271         }
272
273         return nil, nil
274 }
275
276 //-----------------------------------------------------------------------------
277 //
278 //-----------------------------------------------------------------------------
279 func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
280         tc.Info("SendSubsResp")
281         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
282
283         //---------------------------------
284         // e2term activity: Send Subs Resp
285         //---------------------------------
286         resp := &e2ap.E2APSubscriptionResponse{}
287
288         resp.RequestId.Id = req.RequestId.Id
289         resp.RequestId.InstanceId = req.RequestId.InstanceId
290         resp.FunctionId = req.FunctionId
291
292         resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
293         for index := int(0); index < len(req.ActionSetups); index++ {
294                 resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
295         }
296
297         for index := uint64(0); index < 1; index++ {
298                 item := e2ap.ActionNotAdmittedItem{}
299                 item.ActionId = index
300                 item.Cause.Content = 1
301                 item.Cause.Value = 1
302                 resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
303         }
304
305         packerr, packedMsg := e2SubsResp.Pack(resp)
306         if packerr != nil {
307                 tc.TestError(t, "pack NOK %s", packerr.Error())
308         }
309         tc.Debug("%s", e2SubsResp.String())
310
311         params := &xapp.RMRParams{}
312         params.Mtype = xapp.RIC_SUB_RESP
313         //params.SubId = msg.SubId
314         params.SubId = -1
315         params.Payload = packedMsg.Buf
316         params.PayloadLen = len(packedMsg.Buf)
317         params.Meid = msg.Meid
318         //params.Xid = msg.Xid
319         params.Mbuf = nil
320
321         tc.Info("SEND SUB RESP: %s", params.String())
322         snderr := tc.SendWithRetry(params, false, 5)
323         if snderr != nil {
324                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
325         }
326 }
327
328 //-----------------------------------------------------------------------------
329 //
330 //-----------------------------------------------------------------------------
331 func (tc *E2Stub) SendInvalidE2Asn1Resp(t *testing.T, msg *xapp.RMRParams, msgType int) {
332
333         params := &xapp.RMRParams{}
334         params.Mtype = msgType
335         params.SubId = -1
336         params.Payload = []byte{1, 2, 3, 4, 5}
337         params.PayloadLen = 5
338         params.Meid = msg.Meid
339         params.Xid = ""
340         params.Mbuf = nil
341
342         if params.Mtype == xapp.RIC_SUB_RESP {
343                 tc.Info("SEND INVALID ASN.1 SUB RESP")
344
345         } else if params.Mtype == xapp.RIC_SUB_FAILURE {
346                 tc.Info("SEND INVALID ASN.1 SUB FAILURE")
347
348         } else if params.Mtype == xapp.RIC_SUB_DEL_RESP {
349                 tc.Info("SEND INVALID ASN.1 SUB DEL RESP")
350
351         } else if params.Mtype == xapp.RIC_SUB_DEL_FAILURE {
352                 tc.Info("SEND INVALID ASN.1 SUB DEL FAILURE")
353         }
354         snderr := tc.SendWithRetry(params, false, 5)
355         if snderr != nil {
356                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
357         }
358 }
359
360 //-----------------------------------------------------------------------------
361 //
362 //-----------------------------------------------------------------------------
363 func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
364         tc.Info("RecvSubsResp")
365         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
366         var e2SubsId uint32
367
368         //---------------------------------
369         // xapp activity: Recv Subs Resp
370         //---------------------------------
371         msg := tc.WaitMsg(15)
372         if msg != nil {
373                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
374                         tc.TestError(t, "Received RIC_SUB_RESP wrong mtype expected %s got %s, error", "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
375                         return 0
376                 } else if msg.Xid != trans.xid {
377                         tc.TestError(t, "Received RIC_SUB_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
378                         return 0
379                 } else {
380                         packedData := &e2ap.PackedData{}
381                         packedData.Buf = msg.Payload
382                         if msg.SubId > 0 {
383                                 e2SubsId = uint32(msg.SubId)
384                         } else {
385                                 e2SubsId = 0
386                         }
387                         unpackerr, resp := e2SubsResp.UnPack(packedData)
388                         if unpackerr != nil {
389                                 tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
390                         }
391                         tc.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
392                         return e2SubsId
393                 }
394         } else {
395                 tc.TestError(t, "Not Received msg within %d secs", 15)
396         }
397         return 0
398 }
399
400 //-----------------------------------------------------------------------------
401 //
402 //-----------------------------------------------------------------------------
403
404 func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapp.RMRParams) {
405         tc.Info("SendSubsFail")
406         e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
407
408         //---------------------------------
409         // e2term activity: Send Subs Fail
410         //---------------------------------
411         packerr, packedMsg := e2SubsFail.Pack(fparams.Fail)
412         if packerr != nil {
413                 tc.TestError(t, "pack NOK %s", packerr.Error())
414         }
415         tc.Debug("%s", e2SubsFail.String())
416
417         params := &xapp.RMRParams{}
418         params.Mtype = xapp.RIC_SUB_FAILURE
419         params.SubId = msg.SubId
420         params.Payload = packedMsg.Buf
421         params.PayloadLen = len(packedMsg.Buf)
422         params.Meid = msg.Meid
423         params.Xid = msg.Xid
424         params.Mbuf = nil
425
426         tc.Info("SEND SUB FAIL: %s", params.String())
427         snderr := tc.SendWithRetry(params, false, 5)
428         if snderr != nil {
429                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
430         }
431 }
432
433 //-----------------------------------------------------------------------------
434 //
435 //-----------------------------------------------------------------------------
436 func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
437         tc.Info("RecvSubsFail")
438         e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
439         var e2SubsId uint32
440
441         //-------------------------------
442         // xapp activity: Recv Subs Fail
443         //-------------------------------
444         msg := tc.WaitMsg(15)
445         if msg != nil {
446                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] {
447                         tc.TestError(t, "Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype])
448                         return 0
449                 } else if msg.Xid != trans.xid {
450                         tc.TestError(t, "Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", trans.xid, msg.Xid)
451                         return 0
452                 } else {
453                         packedData := &e2ap.PackedData{}
454                         packedData.Buf = msg.Payload
455                         if msg.SubId > 0 {
456                                 e2SubsId = uint32(msg.SubId)
457                         } else {
458                                 e2SubsId = 0
459                         }
460                         unpackerr, resp := e2SubsFail.UnPack(packedData)
461                         if unpackerr != nil {
462                                 tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
463                         }
464                         tc.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
465                         return e2SubsId
466                 }
467         } else {
468                 tc.TestError(t, "Not Received msg within %d secs", 15)
469         }
470         return 0
471 }
472
473 //-----------------------------------------------------------------------------
474 //
475 //-----------------------------------------------------------------------------
476 func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2SubsId uint32) *RmrTransactionId {
477
478         trans := oldTrans
479         if oldTrans == nil {
480                 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
481         }
482
483         tc.Info("SendSubsDelReq %s", trans.String())
484         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
485         //---------------------------------
486         // xapp activity: Send Subs Del Req
487         //---------------------------------
488         req := &e2ap.E2APSubscriptionDeleteRequest{}
489         req.RequestId.Id = 1
490         req.RequestId.InstanceId = e2SubsId
491         req.FunctionId = 1
492
493         err, packedMsg := e2SubsDelReq.Pack(req)
494         if err != nil {
495                 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
496                 return nil
497         }
498         tc.Debug("%s %s", trans.String(), e2SubsDelReq.String())
499
500         params := &xapp.RMRParams{}
501         params.Mtype = xapp.RIC_SUB_DEL_REQ
502         params.SubId = int(e2SubsId)
503         params.Payload = packedMsg.Buf
504         params.PayloadLen = len(packedMsg.Buf)
505         params.Meid = trans.meid
506         params.Xid = trans.xid
507         params.Mbuf = nil
508
509         tc.Info("SEND SUB DEL REQ: %s", params.String())
510         snderr := tc.SendWithRetry(params, false, 5)
511         if snderr != nil {
512                 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
513                 return nil
514         }
515         return trans
516 }
517
518 //-----------------------------------------------------------------------------
519 //
520 //-----------------------------------------------------------------------------
521 func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) {
522         tc.Info("RecvSubsDelReq")
523         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
524
525         //---------------------------------
526         // e2term activity: Recv Subs Del Req
527         //---------------------------------
528         msg := tc.WaitMsg(15)
529         if msg != nil {
530                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
531                         tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
532                 } else {
533                         tc.Info("Recv Subs Del Req")
534
535                         packedData := &e2ap.PackedData{}
536                         packedData.Buf = msg.Payload
537                         unpackerr, req := e2SubsDelReq.UnPack(packedData)
538                         if unpackerr != nil {
539                                 tc.TestError(t, "RIC_SUB_DEL_REQ unpack failed err: %s", unpackerr.Error())
540                         }
541                         return req, msg
542                 }
543         } else {
544                 tc.TestError(t, "Not Received msg within %d secs", 15)
545         }
546         return nil, nil
547 }
548
549 //-----------------------------------------------------------------------------
550 //
551 //-----------------------------------------------------------------------------
552 func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
553         tc.Info("SendSubsDelResp")
554         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
555
556         //---------------------------------
557         // e2term activity: Send Subs Del Resp
558         //---------------------------------
559         resp := &e2ap.E2APSubscriptionDeleteResponse{}
560         resp.RequestId.Id = req.RequestId.Id
561         resp.RequestId.InstanceId = req.RequestId.InstanceId
562         resp.FunctionId = req.FunctionId
563
564         packerr, packedMsg := e2SubsDelResp.Pack(resp)
565         if packerr != nil {
566                 tc.TestError(t, "pack NOK %s", packerr.Error())
567         }
568         tc.Debug("%s", e2SubsDelResp.String())
569
570         params := &xapp.RMRParams{}
571         params.Mtype = xapp.RIC_SUB_DEL_RESP
572         params.SubId = msg.SubId
573         params.Payload = packedMsg.Buf
574         params.PayloadLen = len(packedMsg.Buf)
575         params.Meid = msg.Meid
576         params.Xid = msg.Xid
577         params.Mbuf = nil
578
579         tc.Info("SEND SUB DEL RESP: %s", params.String())
580         snderr := tc.SendWithRetry(params, false, 5)
581         if snderr != nil {
582                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
583         }
584 }
585
586 //-----------------------------------------------------------------------------
587 //
588 //-----------------------------------------------------------------------------
589 func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
590         tc.Info("RecvSubsDelResp")
591         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
592
593         //---------------------------------
594         // xapp activity: Recv Subs Del Resp
595         //---------------------------------
596         msg := tc.WaitMsg(15)
597         if msg != nil {
598                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
599                         tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
600                         return
601                 } else if trans != nil && msg.Xid != trans.xid {
602                         tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
603                         return
604                 } else {
605                         packedData := &e2ap.PackedData{}
606                         packedData.Buf = msg.Payload
607                         unpackerr, resp := e2SubsDelResp.UnPack(packedData)
608                         if unpackerr != nil {
609                                 tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
610                         }
611                         tc.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
612                         return
613                 }
614         } else {
615                 tc.TestError(t, "Not Received msg within %d secs", 15)
616         }
617 }
618
619 //-----------------------------------------------------------------------------
620 //
621 //-----------------------------------------------------------------------------
622 func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
623         tc.Info("SendSubsDelFail")
624         e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
625
626         //---------------------------------
627         // e2term activity: Send Subs Del Fail
628         //---------------------------------
629         resp := &e2ap.E2APSubscriptionDeleteFailure{}
630         resp.RequestId.Id = req.RequestId.Id
631         resp.RequestId.InstanceId = req.RequestId.InstanceId
632         resp.FunctionId = req.FunctionId
633         resp.Cause.Content = 5 // CauseMisc
634         resp.Cause.Value = 3   // unspecified
635
636         packerr, packedMsg := e2SubsDelFail.Pack(resp)
637         if packerr != nil {
638                 tc.TestError(t, "pack NOK %s", packerr.Error())
639         }
640         tc.Debug("%s", e2SubsDelFail.String())
641
642         params := &xapp.RMRParams{}
643         params.Mtype = xapp.RIC_SUB_DEL_FAILURE
644         params.SubId = msg.SubId
645         params.Payload = packedMsg.Buf
646         params.PayloadLen = len(packedMsg.Buf)
647         params.Meid = msg.Meid
648         params.Xid = msg.Xid
649         params.Mbuf = nil
650
651         tc.Info("SEND SUB DEL FAIL: %s", params.String())
652         snderr := tc.SendWithRetry(params, false, 5)
653         if snderr != nil {
654                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
655         }
656 }
657
658 // REST code below all
659
660 /*****************************************************************************/
661 // REST interface specific functions are below
662
663 //-----------------------------------------------------------------------------
664 // Callback handler for subscription response notifications
665 //-----------------------------------------------------------------------------
666 func (tc *E2Stub) SubscriptionRespHandler(resp *clientmodel.SubscriptionResponse) {
667
668         if tc.subscriptionId == "SUBSCRIPTIONID NOT SET" {
669                 tc.Info("REST notification received for %v while no SubscriptionID was not set for E2EventInstanceID=%v, XappEventInstanceID=%v (%v)",
670                         *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
671                 tc.CallBackNotification <- *resp.SubscriptionInstances[0].E2EventInstanceID
672         } else if tc.subscriptionId == *resp.SubscriptionID {
673                 tc.Info("REST notification received SubscriptionID=%s, E2EventInstanceID=%v, RequestorID=%v (%v)",
674                         *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
675                 tc.CallBackNotification <- *resp.SubscriptionInstances[0].E2EventInstanceID
676         } else {
677                 tc.Info("MISMATCHING REST notification received SubscriptionID=%s<>%s, E2EventInstanceID=%v, XappEventInstanceID=%v (%v)",
678                         tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
679         }
680 }
681
682 //-----------------------------------------------------------------------------
683 //
684 //-----------------------------------------------------------------------------
685
686 func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) {
687         tc.expectNotification(t, restSubsId, "")
688 }
689
690 func (tc *E2Stub) ExpectRESTNotificationOk(t *testing.T, restSubsId string) {
691         tc.expectNotification(t, restSubsId, "allOk")
692 }
693
694 func (tc *E2Stub) ExpectRESTNotificationNok(t *testing.T, restSubsId string, expectError string) {
695         tc.expectNotification(t, restSubsId, expectError)
696 }
697
698 func (tc *E2Stub) expectNotification(t *testing.T, restSubsId string, expectError string) {
699
700         tc.Info("### Started to wait REST notification for %v on port %v f(RMR port %v), %v responses expected", restSubsId, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort, tc.requestCount)
701         tc.restSubsIdList = []string{restSubsId}
702         xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
703         if tc.requestCount == 0 {
704                 tc.TestError(t, "### NO REST notifications SET received for endpoint=%s, request zount ZERO! (%v)", tc.clientEndpoint, tc)
705         }
706         go func() {
707                 select {
708                 case e2Ids := <-tc.CallBackListedNotifications:
709                         if tc.requestCount == 0 {
710                                 tc.TestError(t, "### REST notification count unexpectedly ZERO for %s (%v)", restSubsId, tc)
711                         } else if e2Ids.RestSubsId != restSubsId {
712                                 tc.TestError(t, "### Unexpected REST notifications received |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc)
713                         } else if e2Ids.ErrorCause == "" && expectError == "allFail" {
714                                 tc.TestError(t, "### Unexpected ok cause received from REST notifications |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc)
715                         } else if e2Ids.ErrorCause != "" && expectError == "allOk" {
716                                 tc.TestError(t, "### Unexpected error cause (%s) received from REST notifications |%s:%s| (%v)", e2Ids.ErrorCause, e2Ids.RestSubsId, restSubsId, tc)
717                         } else {
718                                 tc.requestCount--
719                                 if tc.requestCount == 0 {
720                                         tc.Info("### All expected REST notifications received for %s (%v)", e2Ids.RestSubsId, tc)
721                                 } else {
722                                         tc.Info("### Expected REST notifications received for %s, (%v)", e2Ids.RestSubsId, tc)
723                                 }
724                                 if e2Ids.ErrorCause != "" && expectError == "allFail" {
725                                         tc.Info("### REST Notification: %s, ErrorCause: %v", e2Ids.RestSubsId, e2Ids.ErrorCause)
726                                 }
727                                 tc.Info("### REST Notification received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
728                                 tc.ListedRESTNotifications <- e2Ids
729                         }
730                 case <-time.After(15 * time.Second):
731                         err := fmt.Errorf("### Timeout 15s expired while expecting REST notification for subsId: %v", restSubsId)
732                         tc.TestError(t, "%s", err.Error())
733                 }
734         }()
735 }
736
737 func (tc *E2Stub) WaitRESTNotification(t *testing.T, restSubsId string) uint32 {
738         select {
739         case e2SubsId := <-tc.ListedRESTNotifications:
740                 if e2SubsId.RestSubsId == restSubsId {
741                         tc.Info("### Expected REST notifications received %s, e2SubsId %v for endpoint=%s, (%v)", e2SubsId.RestSubsId, e2SubsId.E2SubsId, tc.clientEndpoint, tc)
742                         return e2SubsId.E2SubsId
743                 } else {
744                         tc.TestError(t, "### Unexpected REST notifications received %s, expected %s for endpoint=%s, (%v)", e2SubsId.RestSubsId, restSubsId, tc.clientEndpoint, tc)
745                         return 0
746                 }
747         case <-time.After(15 * time.Second):
748                 err := fmt.Errorf("### Timeout 15s expired while waiting REST notification for subsId: %v", restSubsId)
749                 tc.TestError(t, "%s", err.Error())
750                 panic("WaitRESTNotification - timeout error")
751         }
752         return 0
753 }
754
755 func (tc *E2Stub) WaitRESTNotificationForAnySubscriptionId(t *testing.T) {
756         go func() {
757                 tc.Info("### REST notifications received for endpoint=%s, (%v)", tc.clientEndpoint, tc)
758                 select {
759                 case e2SubsId := <-tc.CallBackNotification:
760                         tc.Info("### REST notifications received e2SubsId %v for endpoint=%s, (%v)", e2SubsId, tc.clientEndpoint, tc)
761                         tc.RESTNotification <- (uint32)(e2SubsId)
762                 case <-time.After(15 * time.Second):
763                         err := fmt.Errorf("### Timeout 15s expired while waiting REST notification")
764                         tc.TestError(t, "%s", err.Error())
765                         tc.RESTNotification <- 0
766                 }
767         }()
768 }
769
770 func (tc *E2Stub) ListedRestNotifHandler(resp *clientmodel.SubscriptionResponse) {
771
772         if len(tc.restSubsIdList) == 0 {
773                 tc.Error("Unexpected listed REST notifications received for endpoint=%s, expected restSubsId list size was ZERO!", tc.clientEndpoint)
774         } else {
775                 for i, subsId := range tc.restSubsIdList {
776                         if *resp.SubscriptionID == subsId {
777                                 //tc.Info("Listed REST notifications received SubscriptionID=%s, InstanceID=%v, XappEventInstanceID=%v",
778                                 //      *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID)
779
780                                 tc.restSubsIdList = append(tc.restSubsIdList[:i], tc.restSubsIdList[i+1:]...)
781                                 //tc.Info("Removed %s from Listed REST notifications, %v entries left", *resp.SubscriptionID, len(tc.restSubsIdList))
782
783                                 if resp.SubscriptionInstances[0].ErrorCause != nil {
784                                         tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), *resp.SubscriptionInstances[0].ErrorCause}
785                                 } else {
786                                         tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), ""}
787                                 }
788
789                                 if len(tc.restSubsIdList) == 0 {
790                                         //tc.Info("All listed REST notifications received for endpoint=%s", tc.clientEndpoint)
791                                 }
792
793                                 return
794                         }
795                 }
796                 tc.Error("UNKONWN REST notification received SubscriptionID=%s<>%s, InstanceID=%v, XappEventInstanceID=%v (%v)",
797                         tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
798         }
799 }
800
801 //-----------------------------------------------------------------------------
802 //
803 //-----------------------------------------------------------------------------
804 func (tc *E2Stub) WaitListedRestNotifications(t *testing.T, restSubsIds []string) {
805         tc.Info("Started to wait REST notifications %v on port %v f(RMR port %v)", restSubsIds, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort)
806
807         tc.restSubsIdList = restSubsIds
808         xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
809
810         for i := 0; i < len(restSubsIds); i++ {
811                 go func() {
812                         select {
813                         case e2Ids := <-tc.CallBackListedNotifications:
814                                 tc.Info("Listed Notification waiter received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
815                                 tc.ListedRESTNotifications <- e2Ids
816                         case <-time.After(15 * time.Second):
817                                 err := fmt.Errorf("Timeout 15s expired while waiting Listed REST notification")
818                                 tc.TestError(t, "%s", err.Error())
819                                 tc.RESTNotification <- 0
820                         }
821                 }()
822         }
823 }
824
825 //-----------------------------------------------------------------------------
826 //
827 //-----------------------------------------------------------------------------
828 func (tc *E2Stub) SendRESTSubsReq(t *testing.T, params *RESTSubsReqParams) string { // This need to be edited according to new specification
829         tc.Info("======== Posting REST Report subscriptions to Submgr ======")
830
831         if params == nil {
832                 tc.Info("SendRESTReportSubsReq: params == nil")
833                 return ""
834         }
835
836         tc.subscriptionId = "SUBSCRIPTIONID NOT SET"
837
838         resp, err := xapp.Subscription.Subscribe(&params.SubsReqParams)
839         if err != nil {
840                 // Swagger generated code makes checks for the values that are inserted the subscription function
841                 // If error cause is unknown and POST is not done, the problem is in the inserted values
842                 tc.Error("======== REST report subscriptions failed %s ========", err.Error())
843                 return ""
844         }
845         tc.subscriptionId = *resp.SubscriptionID
846         tc.Info("======== REST report subscriptions posted successfully. SubscriptionID = %s, RequestCount = %v ========", *resp.SubscriptionID, tc.requestCount)
847         return *resp.SubscriptionID
848 }
849
850 //-----------------------------------------------------------------------------
851 //
852 //-----------------------------------------------------------------------------
853 func (tc *E2Stub) GetRESTSubsReqReportParams(subReqCount int) *RESTSubsReqParams {
854
855         reportParams := RESTSubsReqParams{}
856         reportParams.GetRESTSubsReqReportParams(subReqCount, &tc.clientEndpoint, &tc.meid)
857         tc.requestCount = subReqCount
858         return &reportParams
859 }
860
861 //-----------------------------------------------------------------------------
862 //
863 //-----------------------------------------------------------------------------
864 type RESTSubsReqParams struct {
865         SubsReqParams clientmodel.SubscriptionParams
866 }
867
868 func (p *RESTSubsReqParams) GetRESTSubsReqReportParams(subReqCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
869
870         // E2SM-gNB-X2
871         p.SubsReqParams.ClientEndpoint = clientEndpoint
872         p.SubsReqParams.Meid = meid
873         var rANFunctionID int64 = 33
874         p.SubsReqParams.RANFunctionID = &rANFunctionID
875
876         //      reqId := int64(1)
877         //seqId := int64(1)
878         actionId := int64(1)
879         actionType := "report"
880         subsequestActioType := "continue"
881         timeToWait := "w10ms"
882
883         for requestCount := 0; requestCount < subReqCount; requestCount++ {
884                 reqId := int64(requestCount) + 1
885                 subscriptionDetail := &clientmodel.SubscriptionDetail{
886                         XappEventInstanceID: &reqId,
887                         EventTriggers: clientmodel.EventTriggerDefinition{
888                                 int64(1234 + requestCount),
889                         },
890                         ActionToBeSetupList: clientmodel.ActionsToBeSetup{
891                                 &clientmodel.ActionToBeSetup{
892                                         ActionID:   &actionId,
893                                         ActionType: &actionType,
894                                         ActionDefinition: clientmodel.ActionDefinition{
895                                                 int64(5678 + requestCount),
896                                         },
897                                         SubsequentAction: &clientmodel.SubsequentAction{
898                                                 SubsequentActionType: &subsequestActioType,
899                                                 TimeToWait:           &timeToWait,
900                                         },
901                                 },
902                         },
903                 }
904                 p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
905         }
906
907 }
908
909 func (p *RESTSubsReqParams) SetMeid(MEID string) {
910         p.SubsReqParams.Meid = &MEID
911 }
912
913 func (p *RESTSubsReqParams) SetEndpoint(HTTP_port int64, RMR_port int64, host string) {
914         var endpoint clientmodel.SubscriptionParamsClientEndpoint
915         endpoint.HTTPPort = &HTTP_port
916         endpoint.RMRPort = &RMR_port
917         endpoint.Host = host
918         p.SubsReqParams.ClientEndpoint = &endpoint
919 }
920
921 func (p *RESTSubsReqParams) SetEndpointHost(host string) {
922
923         if p.SubsReqParams.ClientEndpoint.Host != "" {
924                 if p.SubsReqParams.ClientEndpoint.Host != host {
925                         // Renaming toto, print something tc.Info("Posting REST subscription request to Submgr")
926                         err := fmt.Errorf("hostname change attempt: %s -> %s", p.SubsReqParams.ClientEndpoint.Host, host)
927                         panic(err)
928                 }
929         }
930         p.SubsReqParams.ClientEndpoint.Host = host
931 }
932
933 func (p *RESTSubsReqParams) SetHTTPEndpoint(HTTP_port int64, host string) {
934
935         p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
936
937         p.SetEndpointHost(host)
938
939         if p.SubsReqParams.ClientEndpoint.RMRPort == nil {
940                 var RMR_port int64
941                 p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
942         }
943 }
944
945 func (p *RESTSubsReqParams) SetSubActionTypes(actionType string) {
946
947         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
948                 for _, action := range subDetail.ActionToBeSetupList {
949                         if action != nil {
950                                 action.ActionType = &actionType
951                         }
952                 }
953         }
954 }
955
956 func (p *RESTSubsReqParams) SetSubActionIDs(actionId int64) {
957
958         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
959                 for _, action := range subDetail.ActionToBeSetupList {
960                         if action != nil {
961                                 action.ActionID = &actionId
962                         }
963                 }
964         }
965 }
966
967 func (p *RESTSubsReqParams) SetSubActionDefinition(actionDefinition []int64) {
968
969         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
970                 for _, action := range subDetail.ActionToBeSetupList {
971                         if action != nil {
972                                 action.ActionDefinition = actionDefinition
973                         }
974                 }
975         }
976 }
977
978 func (p *RESTSubsReqParams) SetSubEventTriggerDefinition(eventTriggerDefinition []int64) {
979
980         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
981                 if subDetail != nil {
982                         subDetail.EventTriggers = eventTriggerDefinition
983                 }
984         }
985 }
986
987 func (p *RESTSubsReqParams) AppendActionToActionToBeSetupList(actionId int64, actionType string, actionDefinition []int64, subsequentActionType string, timeToWait string) {
988
989         actionToBeSetup := &clientmodel.ActionToBeSetup{
990                 ActionID:         &actionId,
991                 ActionType:       &actionType,
992                 ActionDefinition: clientmodel.ActionDefinition(actionDefinition),
993                 SubsequentAction: &clientmodel.SubsequentAction{
994                         SubsequentActionType: &subsequentActionType,
995                         TimeToWait:           &timeToWait,
996                 },
997         }
998
999         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
1000                 if subDetail != nil {
1001                         subDetail.ActionToBeSetupList = append(subDetail.ActionToBeSetupList, actionToBeSetup)
1002                 }
1003         }
1004 }
1005
1006 func (p *RESTSubsReqParams) SetRMREndpoint(RMR_port int64, host string) {
1007
1008         p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
1009
1010         p.SetEndpointHost(host)
1011
1012         if p.SubsReqParams.ClientEndpoint.HTTPPort == nil {
1013                 var HTTP_port int64
1014                 p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
1015         }
1016 }
1017
1018 func (p *RESTSubsReqParams) SetTimeToWait(timeToWait string) {
1019
1020         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
1021                 for _, action := range subDetail.ActionToBeSetupList {
1022                         if action != nil && action.SubsequentAction != nil {
1023                                 action.SubsequentAction.TimeToWait = &timeToWait
1024                         }
1025                 }
1026         }
1027 }
1028
1029 func (p *RESTSubsReqParams) SetSubscriptionID(SubscriptionID *string) {
1030
1031         if *SubscriptionID == "" {
1032                 return
1033         }
1034         p.SubsReqParams.SubscriptionID = *SubscriptionID
1035 }
1036
1037 //-----------------------------------------------------------------------------
1038 //
1039 //-----------------------------------------------------------------------------
1040 func (tc *E2Stub) SendRESTSubsDelReq(t *testing.T, subscriptionID *string) {
1041
1042         if *subscriptionID == "" {
1043                 tc.Error("REST error in deleting subscriptions. Empty SubscriptionID = %s", *subscriptionID)
1044         }
1045         tc.Info("REST deleting E2 subscriptions. SubscriptionID = %s", *subscriptionID)
1046
1047         err := xapp.Subscription.Unsubscribe(*subscriptionID)
1048         if err != nil {
1049                 tc.Error("REST Delete subscription failed %s", err.Error())
1050         }
1051         tc.Info("REST delete subscription pushed to submgr successfully. SubscriptionID = %s", *subscriptionID)
1052 }
1053
1054 //-----------------------------------------------------------------------------
1055 //
1056 //-----------------------------------------------------------------------------
1057 func (tc *E2Stub) GetRESTSubsReqPolicyParams(subReqCount int) *RESTSubsReqParams {
1058
1059         policyParams := RESTSubsReqParams{}
1060         policyParams.GetRESTSubsReqPolicyParams(subReqCount, &tc.clientEndpoint, &tc.meid)
1061         tc.requestCount = subReqCount
1062         return &policyParams
1063 }
1064
1065 //-----------------------------------------------------------------------------
1066 //
1067 //-----------------------------------------------------------------------------
1068 func (p *RESTSubsReqParams) GetRESTSubsReqPolicyParams(subReqCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
1069
1070         p.SubsReqParams.ClientEndpoint = clientEndpoint
1071         p.SubsReqParams.Meid = meid
1072         var rANFunctionID int64 = 33
1073         p.SubsReqParams.RANFunctionID = &rANFunctionID
1074
1075         //      reqId := int64(1)
1076         //seqId := int64(1)
1077         actionId := int64(1)
1078         actionType := "policy"
1079         subsequestActioType := "continue"
1080         timeToWait := "w10ms"
1081
1082         for requestCount := 0; requestCount < subReqCount; requestCount++ {
1083                 reqId := int64(requestCount) + 1
1084                 subscriptionDetail := &clientmodel.SubscriptionDetail{
1085                         XappEventInstanceID: &reqId,
1086                         EventTriggers: clientmodel.EventTriggerDefinition{
1087                                 int64(1234 + requestCount),
1088                         },
1089                         ActionToBeSetupList: clientmodel.ActionsToBeSetup{
1090                                 &clientmodel.ActionToBeSetup{
1091                                         ActionID:   &actionId,
1092                                         ActionType: &actionType,
1093                                         ActionDefinition: clientmodel.ActionDefinition{
1094                                                 int64(5678 + requestCount),
1095                                         },
1096                                         SubsequentAction: &clientmodel.SubsequentAction{
1097                                                 SubsequentActionType: &subsequestActioType,
1098                                                 TimeToWait:           &timeToWait,
1099                                         },
1100                                 },
1101                         },
1102                 }
1103                 p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
1104         }
1105
1106 }