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