98c98f42bc7a117acc7bbf192529c932451720a6
[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         if tc.subscriptionId == "SUBSCRIPTIONID NOT SET" {
668                 tc.Info("REST notification received for %v while no SubscriptionID was not set for E2EventInstanceID=%v, XappEventInstanceID=%v (%v)",
669                         *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
670                 tc.CallBackNotification <- *resp.SubscriptionInstances[0].E2EventInstanceID
671         } else if tc.subscriptionId == *resp.SubscriptionID {
672                 tc.Info("REST notification received SubscriptionID=%s, E2EventInstanceID=%v, RequestorID=%v (%v)",
673                         *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
674                 tc.CallBackNotification <- *resp.SubscriptionInstances[0].E2EventInstanceID
675         } else {
676                 tc.Info("MISMATCHING REST notification received SubscriptionID=%s<>%s, E2EventInstanceID=%v, XappEventInstanceID=%v (%v)",
677                         tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
678         }
679 }
680
681 //-----------------------------------------------------------------------------
682 //
683 //-----------------------------------------------------------------------------
684
685 func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) {
686         tc.expectNotification(t, restSubsId, "")
687 }
688
689 func (tc *E2Stub) ExpectRESTNotificationOk(t *testing.T, restSubsId string) {
690         tc.expectNotification(t, restSubsId, "allOk")
691 }
692
693 func (tc *E2Stub) ExpectRESTNotificationNok(t *testing.T, restSubsId string, expectError string) {
694         tc.expectNotification(t, restSubsId, expectError)
695 }
696
697 func (tc *E2Stub) expectNotification(t *testing.T, restSubsId string, expectError string) {
698
699         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)
700         tc.restSubsIdList = []string{restSubsId}
701         xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
702         if tc.requestCount == 0 {
703                 tc.TestError(t, "### NO REST notifications SET received for endpoint=%s, request zount ZERO! (%v)", tc.clientEndpoint, tc)
704         }
705         go func() {
706                 select {
707                 case e2Ids := <-tc.CallBackListedNotifications:
708                         if tc.requestCount == 0 {
709                                 tc.TestError(t, "### REST notification count unexpectedly ZERO for %s (%v)", restSubsId, tc)
710                         } else if e2Ids.RestSubsId != restSubsId {
711                                 tc.TestError(t, "### Unexpected REST notifications received |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc)
712                         } else if e2Ids.ErrorCause == "" && expectError == "allFail" {
713                                 tc.TestError(t, "### Unexpected ok cause received from REST notifications |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc)
714                         } else if e2Ids.ErrorCause != "" && expectError == "allOk" {
715                                 tc.TestError(t, "### Unexpected error cause (%s) received from REST notifications |%s:%s| (%v)", e2Ids.ErrorCause, e2Ids.RestSubsId, restSubsId, tc)
716                         } else {
717                                 tc.requestCount--
718                                 if tc.requestCount == 0 {
719                                         tc.Info("### All expected REST notifications received for %s (%v)", e2Ids.RestSubsId, tc)
720                                 } else {
721                                         tc.Info("### Expected REST notifications received for %s, (%v)", e2Ids.RestSubsId, tc)
722                                 }
723                                 if e2Ids.ErrorCause != "" && expectError == "allFail" {
724                                         tc.Info("### REST Notification: %s, ErrorCause: %v", e2Ids.RestSubsId, e2Ids.ErrorCause)
725                                 }
726                                 tc.Info("### REST Notification received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
727                                 tc.ListedRESTNotifications <- e2Ids
728                         }
729                 case <-time.After(15 * time.Second):
730                         err := fmt.Errorf("### Timeout 15s expired while expecting REST notification for subsId: %v", restSubsId)
731                         tc.TestError(t, "%s", err.Error())
732                 }
733         }()
734 }
735
736 func (tc *E2Stub) WaitRESTNotification(t *testing.T, restSubsId string) uint32 {
737         select {
738         case e2SubsId := <-tc.ListedRESTNotifications:
739                 if e2SubsId.RestSubsId == restSubsId {
740                         tc.Info("### Expected REST notifications received %s, e2SubsId %v for endpoint=%s, (%v)", e2SubsId.RestSubsId, e2SubsId.E2SubsId, tc.clientEndpoint, tc)
741                         return e2SubsId.E2SubsId
742                 } else {
743                         tc.TestError(t, "### Unexpected REST notifications received %s, expected %s for endpoint=%s, (%v)", e2SubsId.RestSubsId, restSubsId, tc.clientEndpoint, tc)
744                         return 0
745                 }
746         case <-time.After(15 * time.Second):
747                 err := fmt.Errorf("### Timeout 15s expired while waiting REST notification for subsId: %v", restSubsId)
748                 tc.TestError(t, "%s", err.Error())
749                 panic("WaitRESTNotification - timeout error")
750         }
751         return 0
752 }
753
754 func (tc *E2Stub) WaitRESTNotificationForAnySubscriptionId(t *testing.T) {
755         go func() {
756                 tc.Info("### REST notifications received for endpoint=%s, (%v)", tc.clientEndpoint, tc)
757                 select {
758                 case e2SubsId := <-tc.CallBackNotification:
759                         tc.Info("### REST notifications received e2SubsId %v for endpoint=%s, (%v)", e2SubsId, tc.clientEndpoint, tc)
760                         tc.RESTNotification <- (uint32)(e2SubsId)
761                 case <-time.After(15 * time.Second):
762                         err := fmt.Errorf("### Timeout 15s expired while waiting REST notification")
763                         tc.TestError(t, "%s", err.Error())
764                         tc.RESTNotification <- 0
765                 }
766         }()
767 }
768
769 func (tc *E2Stub) ListedRestNotifHandler(resp *clientmodel.SubscriptionResponse) {
770
771         if len(tc.restSubsIdList) == 0 {
772                 tc.Error("Unexpected listed REST notifications received for endpoint=%s, expected restSubsId list size was ZERO!", tc.clientEndpoint)
773         } else {
774                 for i, subsId := range tc.restSubsIdList {
775                         if *resp.SubscriptionID == subsId {
776                                 //tc.Info("Listed REST notifications received SubscriptionID=%s, InstanceID=%v, XappEventInstanceID=%v",
777                                 //      *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID)
778
779                                 tc.restSubsIdList = append(tc.restSubsIdList[:i], tc.restSubsIdList[i+1:]...)
780                                 //tc.Info("Removed %s from Listed REST notifications, %v entries left", *resp.SubscriptionID, len(tc.restSubsIdList))
781
782                                 if resp.SubscriptionInstances[0].ErrorCause != nil {
783                                         tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), *resp.SubscriptionInstances[0].ErrorCause}
784                                 } else {
785                                         tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), ""}
786                                 }
787
788                                 if len(tc.restSubsIdList) == 0 {
789                                         //tc.Info("All listed REST notifications received for endpoint=%s", tc.clientEndpoint)
790                                 }
791
792                                 return
793                         }
794                 }
795                 tc.Error("UNKONWN REST notification received SubscriptionID=%s<>%s, InstanceID=%v, XappEventInstanceID=%v (%v)",
796                         tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc)
797         }
798 }
799
800 //-----------------------------------------------------------------------------
801 //
802 //-----------------------------------------------------------------------------
803 func (tc *E2Stub) WaitListedRestNotifications(t *testing.T, restSubsIds []string) {
804         tc.Info("Started to wait REST notifications %v on port %v f(RMR port %v)", restSubsIds, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort)
805
806         tc.restSubsIdList = restSubsIds
807         xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
808
809         for i := 0; i < len(restSubsIds); i++ {
810                 go func() {
811                         select {
812                         case e2Ids := <-tc.CallBackListedNotifications:
813                                 tc.Info("Listed Notification waiter received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
814                                 tc.ListedRESTNotifications <- e2Ids
815                         case <-time.After(15 * time.Second):
816                                 err := fmt.Errorf("Timeout 15s expired while waiting Listed REST notification")
817                                 tc.TestError(t, "%s", err.Error())
818                                 tc.RESTNotification <- 0
819                         }
820                 }()
821         }
822 }
823
824 //-----------------------------------------------------------------------------
825 //
826 //-----------------------------------------------------------------------------
827 func (tc *E2Stub) SendRESTSubsReq(t *testing.T, params *RESTSubsReqParams) string { // This need to be edited according to new specification
828         tc.Info("======== Posting REST Report subscriptions to Submgr ======")
829
830         if params == nil {
831                 tc.Info("SendRESTReportSubsReq: params == nil")
832                 return ""
833         }
834
835         tc.subscriptionId = "SUBSCIPTIONID NOT SET"
836
837         resp, err := xapp.Subscription.Subscribe(&params.SubsReqParams)
838         if err != nil {
839                 // Swagger generated code makes checks for the values that are inserted the subscription function
840                 // If error cause is unknown and POST is not done, the problem is in the inserted values
841                 tc.Error("======== REST report subscriptions failed %s ========", err.Error())
842                 return ""
843         }
844         tc.subscriptionId = *resp.SubscriptionID
845         tc.Info("======== REST report subscriptions posted successfully. SubscriptionID = %s, RequestCount = %v ========", *resp.SubscriptionID, tc.requestCount)
846         return *resp.SubscriptionID
847 }
848
849 //-----------------------------------------------------------------------------
850 //
851 //-----------------------------------------------------------------------------
852 func (tc *E2Stub) GetRESTSubsReqReportParams(subReqCount int) *RESTSubsReqParams {
853
854         reportParams := RESTSubsReqParams{}
855         reportParams.GetRESTSubsReqReportParams(subReqCount, &tc.clientEndpoint, &tc.meid)
856         tc.requestCount = subReqCount
857         return &reportParams
858 }
859
860 //-----------------------------------------------------------------------------
861 //
862 //-----------------------------------------------------------------------------
863 type RESTSubsReqParams struct {
864         SubsReqParams clientmodel.SubscriptionParams
865 }
866
867 func (p *RESTSubsReqParams) GetRESTSubsReqReportParams(subReqCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
868
869         // E2SM-gNB-X2
870         p.SubsReqParams.ClientEndpoint = clientEndpoint
871         p.SubsReqParams.Meid = meid
872         var rANFunctionID int64 = 33
873         p.SubsReqParams.RANFunctionID = &rANFunctionID
874
875         //      reqId := int64(1)
876         //seqId := int64(1)
877         actionId := int64(1)
878         actionType := "report"
879         subsequestActioType := "continue"
880         timeToWait := "w10ms"
881
882         for requestCount := 0; requestCount < subReqCount; requestCount++ {
883                 reqId := int64(requestCount) + 1
884                 subscriptionDetail := &clientmodel.SubscriptionDetail{
885                         XappEventInstanceID: &reqId,
886                         EventTriggers: clientmodel.EventTriggerDefinition{
887                                 int64(1234 + requestCount),
888                         },
889                         ActionToBeSetupList: clientmodel.ActionsToBeSetup{
890                                 &clientmodel.ActionToBeSetup{
891                                         ActionID:   &actionId,
892                                         ActionType: &actionType,
893                                         ActionDefinition: clientmodel.ActionDefinition{
894                                                 int64(5678 + requestCount),
895                                         },
896                                         SubsequentAction: &clientmodel.SubsequentAction{
897                                                 SubsequentActionType: &subsequestActioType,
898                                                 TimeToWait:           &timeToWait,
899                                         },
900                                 },
901                         },
902                 }
903                 p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
904         }
905
906 }
907
908 func (p *RESTSubsReqParams) SetMeid(MEID string) {
909         p.SubsReqParams.Meid = &MEID
910 }
911
912 func (p *RESTSubsReqParams) SetEndpoint(HTTP_port int64, RMR_port int64, host string) {
913         var endpoint clientmodel.SubscriptionParamsClientEndpoint
914         endpoint.HTTPPort = &HTTP_port
915         endpoint.RMRPort = &RMR_port
916         endpoint.Host = host
917         p.SubsReqParams.ClientEndpoint = &endpoint
918 }
919
920 func (p *RESTSubsReqParams) SetEndpointHost(host string) {
921
922         if p.SubsReqParams.ClientEndpoint.Host != "" {
923                 if p.SubsReqParams.ClientEndpoint.Host != host {
924                         // Renaming toto, print something tc.Info("Posting REST subscription request to Submgr")
925                         err := fmt.Errorf("hostname change attempt: %s -> %s", p.SubsReqParams.ClientEndpoint.Host, host)
926                         panic(err)
927                 }
928         }
929         p.SubsReqParams.ClientEndpoint.Host = host
930 }
931
932 func (p *RESTSubsReqParams) SetHTTPEndpoint(HTTP_port int64, host string) {
933
934         p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
935
936         p.SetEndpointHost(host)
937
938         if p.SubsReqParams.ClientEndpoint.RMRPort == nil {
939                 var RMR_port int64
940                 p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
941         }
942 }
943
944 func (p *RESTSubsReqParams) SetSubActionTypes(actionType string) {
945
946         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
947                 for _, action := range subDetail.ActionToBeSetupList {
948                         if action != nil {
949                                 action.ActionType = &actionType
950                         }
951                 }
952         }
953 }
954
955 func (p *RESTSubsReqParams) SetSubActionIDs(actionId int64) {
956
957         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
958                 for _, action := range subDetail.ActionToBeSetupList {
959                         if action != nil {
960                                 action.ActionID = &actionId
961                         }
962                 }
963         }
964 }
965
966 func (p *RESTSubsReqParams) SetSubActionDefinition(actionDefinition []int64) {
967
968         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
969                 for _, action := range subDetail.ActionToBeSetupList {
970                         if action != nil {
971                                 action.ActionDefinition = actionDefinition
972                         }
973                 }
974         }
975 }
976
977 func (p *RESTSubsReqParams) SetSubEventTriggerDefinition(eventTriggerDefinition []int64) {
978
979         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
980                 if subDetail != nil {
981                         subDetail.EventTriggers = eventTriggerDefinition
982                 }
983         }
984 }
985
986 func (p *RESTSubsReqParams) AppendActionToActionToBeSetupList(actionId int64, actionType string, actionDefinition []int64, subsequentActionType string, timeToWait string) {
987
988         actionToBeSetup := &clientmodel.ActionToBeSetup{
989                 ActionID:         &actionId,
990                 ActionType:       &actionType,
991                 ActionDefinition: clientmodel.ActionDefinition(actionDefinition),
992                 SubsequentAction: &clientmodel.SubsequentAction{
993                         SubsequentActionType: &subsequentActionType,
994                         TimeToWait:           &timeToWait,
995                 },
996         }
997
998         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
999                 if subDetail != nil {
1000                         subDetail.ActionToBeSetupList = append(subDetail.ActionToBeSetupList, actionToBeSetup)
1001                 }
1002         }
1003 }
1004
1005 func (p *RESTSubsReqParams) SetRMREndpoint(RMR_port int64, host string) {
1006
1007         p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
1008
1009         p.SetEndpointHost(host)
1010
1011         if p.SubsReqParams.ClientEndpoint.HTTPPort == nil {
1012                 var HTTP_port int64
1013                 p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
1014         }
1015 }
1016
1017 func (p *RESTSubsReqParams) SetTimeToWait(timeToWait string) {
1018
1019         for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
1020                 for _, action := range subDetail.ActionToBeSetupList {
1021                         if action != nil && action.SubsequentAction != nil {
1022                                 action.SubsequentAction.TimeToWait = &timeToWait
1023                         }
1024                 }
1025         }
1026 }
1027
1028 func (p *RESTSubsReqParams) SetSubscriptionID(SubscriptionID *string) {
1029
1030         if *SubscriptionID == "" {
1031                 return
1032         }
1033         p.SubsReqParams.SubscriptionID = *SubscriptionID
1034 }
1035
1036 //-----------------------------------------------------------------------------
1037 //
1038 //-----------------------------------------------------------------------------
1039 func (tc *E2Stub) SendRESTSubsDelReq(t *testing.T, subscriptionID *string) {
1040
1041         if *subscriptionID == "" {
1042                 tc.Error("REST error in deleting subscriptions. Empty SubscriptionID = %s", *subscriptionID)
1043         }
1044         tc.Info("REST deleting E2 subscriptions. SubscriptionID = %s", *subscriptionID)
1045
1046         err := xapp.Subscription.Unsubscribe(*subscriptionID)
1047         if err != nil {
1048                 tc.Error("REST Delete subscription failed %s", err.Error())
1049         }
1050         tc.Info("REST delete subscription pushed to submgr successfully. SubscriptionID = %s", *subscriptionID)
1051 }
1052
1053 //-----------------------------------------------------------------------------
1054 //
1055 //-----------------------------------------------------------------------------
1056 func (tc *E2Stub) GetRESTSubsReqPolicyParams(subReqCount int) *RESTSubsReqParams {
1057
1058         policyParams := RESTSubsReqParams{}
1059         policyParams.GetRESTSubsReqPolicyParams(subReqCount, &tc.clientEndpoint, &tc.meid)
1060         tc.requestCount = subReqCount
1061         return &policyParams
1062 }
1063
1064 //-----------------------------------------------------------------------------
1065 //
1066 //-----------------------------------------------------------------------------
1067 func (p *RESTSubsReqParams) GetRESTSubsReqPolicyParams(subReqCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
1068
1069         p.SubsReqParams.ClientEndpoint = clientEndpoint
1070         p.SubsReqParams.Meid = meid
1071         var rANFunctionID int64 = 33
1072         p.SubsReqParams.RANFunctionID = &rANFunctionID
1073
1074         //      reqId := int64(1)
1075         //seqId := int64(1)
1076         actionId := int64(1)
1077         actionType := "policy"
1078         subsequestActioType := "continue"
1079         timeToWait := "w10ms"
1080
1081         for requestCount := 0; requestCount < subReqCount; requestCount++ {
1082                 reqId := int64(requestCount) + 1
1083                 subscriptionDetail := &clientmodel.SubscriptionDetail{
1084                         XappEventInstanceID: &reqId,
1085                         EventTriggers: clientmodel.EventTriggerDefinition{
1086                                 int64(1234 + requestCount),
1087                         },
1088                         ActionToBeSetupList: clientmodel.ActionsToBeSetup{
1089                                 &clientmodel.ActionToBeSetup{
1090                                         ActionID:   &actionId,
1091                                         ActionType: &actionType,
1092                                         ActionDefinition: clientmodel.ActionDefinition{
1093                                                 int64(5678 + requestCount),
1094                                         },
1095                                         SubsequentAction: &clientmodel.SubsequentAction{
1096                                                 SubsequentActionType: &subsequestActioType,
1097                                                 TimeToWait:           &timeToWait,
1098                                         },
1099                                 },
1100                         },
1101                 }
1102                 p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
1103         }
1104
1105 }