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