d830aa7f15530946f9ab7aeceaf98374f2098961
[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         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
24         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
25         "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
26         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
27         "strconv"
28         "testing"
29 )
30
31 //-----------------------------------------------------------------------------
32 //
33 //-----------------------------------------------------------------------------
34 var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
35
36 //-----------------------------------------------------------------------------
37 //
38 //-----------------------------------------------------------------------------
39 type RmrTransactionId struct {
40         xid  string
41         meid *xapp.RMRMeid
42 }
43
44 func (trans *RmrTransactionId) String() string {
45         meidstr := "N/A"
46         if trans.meid != nil {
47                 meidstr = trans.meid.String()
48         }
49         return "trans(" + trans.xid + "/" + meidstr + ")"
50 }
51
52 type E2Stub struct {
53         teststub.RmrStubControl
54         xid_seq uint64
55 }
56
57 //-----------------------------------------------------------------------------
58 //
59 //-----------------------------------------------------------------------------
60 func CreateNewE2Stub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
61         tc := &E2Stub{}
62         tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
63         tc.xid_seq = 1
64         tc.SetCheckXid(true)
65         return tc
66 }
67
68 //-----------------------------------------------------------------------------
69 //
70 //-----------------------------------------------------------------------------
71 func CreateNewE2termStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
72         tc := &E2Stub{}
73         tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
74         tc.xid_seq = 1
75         tc.SetCheckXid(false)
76         return tc
77 }
78
79 //-----------------------------------------------------------------------------
80 //
81 //-----------------------------------------------------------------------------
82 func (tc *E2Stub) NewRmrTransactionId(xid string, ranname string) *RmrTransactionId {
83         trans := &RmrTransactionId{}
84         if len(xid) == 0 {
85                 trans.xid = tc.GetDesc() + "_XID_" + strconv.FormatUint(uint64(tc.xid_seq), 10)
86                 tc.xid_seq++
87         } else {
88                 trans.xid = xid
89         }
90         trans.meid = &xapp.RMRMeid{RanName: ranname}
91         tc.Info("New test %s", trans.String())
92         return trans
93 }
94
95 //-----------------------------------------------------------------------------
96 //
97 //-----------------------------------------------------------------------------
98 type E2StubSubsReqParams struct {
99         Req *e2ap.E2APSubscriptionRequest
100 }
101
102 func (p *E2StubSubsReqParams) Init() {
103         p.Req = &e2ap.E2APSubscriptionRequest{}
104
105         p.Req.RequestId.Id = 1
106         p.Req.RequestId.InstanceId = 0
107         p.Req.FunctionId = 1
108
109         // gnb -> enb outgoing
110         // enb -> gnb incoming
111         // X2 36423-f40.doc
112         p.Req.EventTriggerDefinition.Data.Length = 1
113         p.Req.EventTriggerDefinition.Data.Data = make([]uint8, p.Req.EventTriggerDefinition.Data.Length)
114         p.Req.EventTriggerDefinition.Data.Data[0] = 1
115
116         p.Req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
117
118         p.Req.ActionSetups[0].ActionId = 0
119         p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
120         p.Req.ActionSetups[0].RicActionDefinitionPresent = true
121
122         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length = 1
123         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data = make([]uint8, p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length)
124         p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data[0] = 1
125
126         p.Req.ActionSetups[0].SubsequentAction.Present = true
127         p.Req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
128         p.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
129 }
130
131 //-----------------------------------------------------------------------------
132 //
133 //-----------------------------------------------------------------------------
134
135 type E2StubSubsFailParams struct {
136         Req  *e2ap.E2APSubscriptionRequest
137         Fail *e2ap.E2APSubscriptionFailure
138 }
139
140 func (p *E2StubSubsFailParams) Set(req *e2ap.E2APSubscriptionRequest) {
141         p.Req = req
142
143         p.Fail = &e2ap.E2APSubscriptionFailure{}
144         p.Fail.RequestId.Id = p.Req.RequestId.Id
145         p.Fail.RequestId.InstanceId = p.Req.RequestId.InstanceId
146         p.Fail.FunctionId = p.Req.FunctionId
147         p.Fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.Req.ActionSetups))
148         for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
149                 p.Fail.ActionNotAdmittedList.Items[index].ActionId = p.Req.ActionSetups[index].ActionId
150                 p.SetCauseVal(index, 5, 1)
151         }
152 }
153
154 func (p *E2StubSubsFailParams) SetCauseVal(ind int, content uint8, causeval uint8) {
155
156         if ind < 0 {
157                 for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
158                         p.Fail.ActionNotAdmittedList.Items[index].Cause.Content = content
159                         p.Fail.ActionNotAdmittedList.Items[index].Cause.Value = causeval
160                 }
161                 return
162         }
163         p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
164         p.Fail.ActionNotAdmittedList.Items[ind].Cause.Value = causeval
165 }
166
167 //-----------------------------------------------------------------------------
168 //
169 //-----------------------------------------------------------------------------
170
171 func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTrans *RmrTransactionId) *RmrTransactionId {
172
173         trans := oldTrans
174         if oldTrans == nil {
175                 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
176         }
177
178         tc.Info("SendSubsReq %s", trans.String())
179         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
180
181         //---------------------------------
182         // xapp activity: Send Subs Req
183         //---------------------------------
184         myparams := rparams
185
186         if myparams == nil {
187                 myparams = &E2StubSubsReqParams{}
188                 myparams.Init()
189         }
190
191         err, packedMsg := e2SubsReq.Pack(myparams.Req)
192         if err != nil {
193                 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
194                 return nil
195         }
196         tc.Debug("%s %s", trans.String(), e2SubsReq.String())
197
198         params := &xapp.RMRParams{}
199         params.Mtype = xapp.RIC_SUB_REQ
200         params.SubId = -1
201         params.Payload = packedMsg.Buf
202         params.PayloadLen = len(packedMsg.Buf)
203         params.Meid = trans.meid
204         params.Xid = trans.xid
205         params.Mbuf = nil
206
207         tc.Info("SEND SUB REQ: %s", params.String())
208         snderr := tc.SendWithRetry(params, false, 5)
209         if snderr != nil {
210                 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
211                 return nil
212         }
213         return trans
214 }
215
216 //-----------------------------------------------------------------------------
217 //
218 //-----------------------------------------------------------------------------
219 func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) {
220         tc.Info("RecvSubsReq")
221         e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
222
223         //---------------------------------
224         // e2term activity: Recv Subs Req
225         //---------------------------------
226         msg := tc.WaitMsg(15)
227         if msg != nil {
228                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
229                         tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
230                 } else {
231                         tc.Info("Recv Subs Req")
232                         packedData := &e2ap.PackedData{}
233                         packedData.Buf = msg.Payload
234                         unpackerr, req := e2SubsReq.UnPack(packedData)
235                         if unpackerr != nil {
236                                 tc.TestError(t, "RIC_SUB_REQ unpack failed err: %s", unpackerr.Error())
237                         }
238                         return req, msg
239                 }
240         } else {
241                 tc.TestError(t, "Not Received msg within %d secs", 15)
242         }
243
244         return nil, nil
245 }
246
247 //-----------------------------------------------------------------------------
248 //
249 //-----------------------------------------------------------------------------
250 func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
251         tc.Info("SendSubsResp")
252         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
253
254         //---------------------------------
255         // e2term activity: Send Subs Resp
256         //---------------------------------
257         resp := &e2ap.E2APSubscriptionResponse{}
258
259         resp.RequestId.Id = req.RequestId.Id
260         resp.RequestId.InstanceId = req.RequestId.InstanceId
261         resp.FunctionId = req.FunctionId
262
263         resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
264         for index := int(0); index < len(req.ActionSetups); index++ {
265                 resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
266         }
267
268         for index := uint64(0); index < 1; index++ {
269                 item := e2ap.ActionNotAdmittedItem{}
270                 item.ActionId = index
271                 item.Cause.Content = 1
272                 item.Cause.Value = 1
273                 resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
274         }
275
276         packerr, packedMsg := e2SubsResp.Pack(resp)
277         if packerr != nil {
278                 tc.TestError(t, "pack NOK %s", packerr.Error())
279         }
280         tc.Debug("%s", e2SubsResp.String())
281
282         params := &xapp.RMRParams{}
283         params.Mtype = xapp.RIC_SUB_RESP
284         //params.SubId = msg.SubId
285         params.SubId = -1
286         params.Payload = packedMsg.Buf
287         params.PayloadLen = len(packedMsg.Buf)
288         params.Meid = msg.Meid
289         //params.Xid = msg.Xid
290         params.Mbuf = nil
291
292         tc.Info("SEND SUB RESP: %s", params.String())
293         snderr := tc.SendWithRetry(params, false, 5)
294         if snderr != nil {
295                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
296         }
297 }
298
299 //-----------------------------------------------------------------------------
300 //
301 //-----------------------------------------------------------------------------
302 func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
303         tc.Info("RecvSubsResp")
304         e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
305         var e2SubsId uint32
306
307         //---------------------------------
308         // xapp activity: Recv Subs Resp
309         //---------------------------------
310         msg := tc.WaitMsg(15)
311         if msg != nil {
312                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
313                         tc.TestError(t, "Received RIC_SUB_RESP wrong mtype expected %s got %s, error", "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
314                         return 0
315                 } else if msg.Xid != trans.xid {
316                         tc.TestError(t, "Received RIC_SUB_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
317                         return 0
318                 } else {
319                         packedData := &e2ap.PackedData{}
320                         packedData.Buf = msg.Payload
321                         if msg.SubId > 0 {
322                                 e2SubsId = uint32(msg.SubId)
323                         } else {
324                                 e2SubsId = 0
325                         }
326                         unpackerr, resp := e2SubsResp.UnPack(packedData)
327                         if unpackerr != nil {
328                                 tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
329                         }
330                         tc.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
331                         return e2SubsId
332                 }
333         } else {
334                 tc.TestError(t, "Not Received msg within %d secs", 15)
335         }
336         return 0
337 }
338
339 //-----------------------------------------------------------------------------
340 //
341 //-----------------------------------------------------------------------------
342
343 func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapp.RMRParams) {
344         tc.Info("SendSubsFail")
345         e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
346
347         //---------------------------------
348         // e2term activity: Send Subs Fail
349         //---------------------------------
350         packerr, packedMsg := e2SubsFail.Pack(fparams.Fail)
351         if packerr != nil {
352                 tc.TestError(t, "pack NOK %s", packerr.Error())
353         }
354         tc.Debug("%s", e2SubsFail.String())
355
356         params := &xapp.RMRParams{}
357         params.Mtype = xapp.RIC_SUB_FAILURE
358         params.SubId = msg.SubId
359         params.Payload = packedMsg.Buf
360         params.PayloadLen = len(packedMsg.Buf)
361         params.Meid = msg.Meid
362         params.Xid = msg.Xid
363         params.Mbuf = nil
364
365         tc.Info("SEND SUB FAIL: %s", params.String())
366         snderr := tc.SendWithRetry(params, false, 5)
367         if snderr != nil {
368                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
369         }
370 }
371
372 //-----------------------------------------------------------------------------
373 //
374 //-----------------------------------------------------------------------------
375 func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
376         tc.Info("RecvSubsFail")
377         e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
378         var e2SubsId uint32
379
380         //-------------------------------
381         // xapp activity: Recv Subs Fail
382         //-------------------------------
383         msg := tc.WaitMsg(15)
384         if msg != nil {
385                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] {
386                         tc.TestError(t, "Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype])
387                         return 0
388                 } else if msg.Xid != trans.xid {
389                         tc.TestError(t, "Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", trans.xid, msg.Xid)
390                         return 0
391                 } else {
392                         packedData := &e2ap.PackedData{}
393                         packedData.Buf = msg.Payload
394                         if msg.SubId > 0 {
395                                 e2SubsId = uint32(msg.SubId)
396                         } else {
397                                 e2SubsId = 0
398                         }
399                         unpackerr, resp := e2SubsFail.UnPack(packedData)
400                         if unpackerr != nil {
401                                 tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
402                         }
403                         tc.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
404                         return e2SubsId
405                 }
406         } else {
407                 tc.TestError(t, "Not Received msg within %d secs", 15)
408         }
409         return 0
410 }
411
412 //-----------------------------------------------------------------------------
413 //
414 //-----------------------------------------------------------------------------
415 func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2SubsId uint32) *RmrTransactionId {
416
417         trans := oldTrans
418         if oldTrans == nil {
419                 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
420         }
421
422         tc.Info("SendSubsDelReq %s", trans.String())
423         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
424         //---------------------------------
425         // xapp activity: Send Subs Del Req
426         //---------------------------------
427         req := &e2ap.E2APSubscriptionDeleteRequest{}
428         req.RequestId.Id = 1
429         req.RequestId.InstanceId = e2SubsId
430         req.FunctionId = 1
431
432         err, packedMsg := e2SubsDelReq.Pack(req)
433         if err != nil {
434                 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
435                 return nil
436         }
437         tc.Debug("%s %s", trans.String(), e2SubsDelReq.String())
438
439         params := &xapp.RMRParams{}
440         params.Mtype = xapp.RIC_SUB_DEL_REQ
441         params.SubId = int(e2SubsId)
442         params.Payload = packedMsg.Buf
443         params.PayloadLen = len(packedMsg.Buf)
444         params.Meid = trans.meid
445         params.Xid = trans.xid
446         params.Mbuf = nil
447
448         tc.Info("SEND SUB DEL REQ: %s", params.String())
449         snderr := tc.SendWithRetry(params, false, 5)
450         if snderr != nil {
451                 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
452                 return nil
453         }
454         return trans
455 }
456
457 //-----------------------------------------------------------------------------
458 //
459 //-----------------------------------------------------------------------------
460 func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) {
461         tc.Info("RecvSubsDelReq")
462         e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
463
464         //---------------------------------
465         // e2term activity: Recv Subs Del Req
466         //---------------------------------
467         msg := tc.WaitMsg(15)
468         if msg != nil {
469                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
470                         tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
471                 } else {
472                         tc.Info("Recv Subs Del Req")
473
474                         packedData := &e2ap.PackedData{}
475                         packedData.Buf = msg.Payload
476                         unpackerr, req := e2SubsDelReq.UnPack(packedData)
477                         if unpackerr != nil {
478                                 tc.TestError(t, "RIC_SUB_DEL_REQ unpack failed err: %s", unpackerr.Error())
479                         }
480                         return req, msg
481                 }
482         } else {
483                 tc.TestError(t, "Not Received msg within %d secs", 15)
484         }
485         return nil, nil
486 }
487
488 //-----------------------------------------------------------------------------
489 //
490 //-----------------------------------------------------------------------------
491 func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
492         tc.Info("SendSubsDelResp")
493         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
494
495         //---------------------------------
496         // e2term activity: Send Subs Del Resp
497         //---------------------------------
498         resp := &e2ap.E2APSubscriptionDeleteResponse{}
499         resp.RequestId.Id = req.RequestId.Id
500         resp.RequestId.InstanceId = req.RequestId.InstanceId
501         resp.FunctionId = req.FunctionId
502
503         packerr, packedMsg := e2SubsDelResp.Pack(resp)
504         if packerr != nil {
505                 tc.TestError(t, "pack NOK %s", packerr.Error())
506         }
507         tc.Debug("%s", e2SubsDelResp.String())
508
509         params := &xapp.RMRParams{}
510         params.Mtype = xapp.RIC_SUB_DEL_RESP
511         params.SubId = msg.SubId
512         params.Payload = packedMsg.Buf
513         params.PayloadLen = len(packedMsg.Buf)
514         params.Meid = msg.Meid
515         params.Xid = msg.Xid
516         params.Mbuf = nil
517
518         tc.Info("SEND SUB DEL RESP: %s", params.String())
519         snderr := tc.SendWithRetry(params, false, 5)
520         if snderr != nil {
521                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
522         }
523 }
524
525 //-----------------------------------------------------------------------------
526 //
527 //-----------------------------------------------------------------------------
528 func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
529         tc.Info("RecvSubsDelResp")
530         e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
531
532         //---------------------------------
533         // xapp activity: Recv Subs Del Resp
534         //---------------------------------
535         msg := tc.WaitMsg(15)
536         if msg != nil {
537                 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
538                         tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
539                         return
540                 } else if trans != nil && msg.Xid != trans.xid {
541                         tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
542                         return
543                 } else {
544                         packedData := &e2ap.PackedData{}
545                         packedData.Buf = msg.Payload
546                         unpackerr, resp := e2SubsDelResp.UnPack(packedData)
547                         if unpackerr != nil {
548                                 tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
549                         }
550                         tc.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
551                         return
552                 }
553         } else {
554                 tc.TestError(t, "Not Received msg within %d secs", 15)
555         }
556 }
557
558 //-----------------------------------------------------------------------------
559 //
560 //-----------------------------------------------------------------------------
561 func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
562         tc.Info("SendSubsDelFail")
563         e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
564
565         //---------------------------------
566         // e2term activity: Send Subs Del Fail
567         //---------------------------------
568         resp := &e2ap.E2APSubscriptionDeleteFailure{}
569         resp.RequestId.Id = req.RequestId.Id
570         resp.RequestId.InstanceId = req.RequestId.InstanceId
571         resp.FunctionId = req.FunctionId
572         resp.Cause.Content = 4 // CauseMisc
573         resp.Cause.Value = 3   // unspecified
574
575         packerr, packedMsg := e2SubsDelFail.Pack(resp)
576         if packerr != nil {
577                 tc.TestError(t, "pack NOK %s", packerr.Error())
578         }
579         tc.Debug("%s", e2SubsDelFail.String())
580
581         params := &xapp.RMRParams{}
582         params.Mtype = xapp.RIC_SUB_DEL_FAILURE
583         params.SubId = msg.SubId
584         params.Payload = packedMsg.Buf
585         params.PayloadLen = len(packedMsg.Buf)
586         params.Meid = msg.Meid
587         params.Xid = msg.Xid
588         params.Mbuf = nil
589
590         tc.Info("SEND SUB DEL FAIL: %s", params.String())
591         snderr := tc.SendWithRetry(params, false, 5)
592         if snderr != nil {
593                 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
594         }
595 }