blob: a5dfa54ba4c30b190bb3417379a237db0a3dfd96 [file] [log] [blame]
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001/*
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
20package teststube2ap
21
22import (
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//-----------------------------------------------------------------------------
35var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
36
37//-----------------------------------------------------------------------------
38//
39//-----------------------------------------------------------------------------
40type RmrTransactionId struct {
41 xid string
42 meid *xapp.RMRMeid
43}
44
45func (trans *RmrTransactionId) String() string {
46 return "trans(" + trans.xid + "/" + trans.meid.RanName + ")"
47}
48
49type E2Stub struct {
50 teststub.RmrStubControl
51 xid_seq uint64
52}
53
54//-----------------------------------------------------------------------------
55//
56//-----------------------------------------------------------------------------
57func 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//-----------------------------------------------------------------------------
68func 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//-----------------------------------------------------------------------------
79func (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//-----------------------------------------------------------------------------
95type E2StubSubsReqParams struct {
96 Req *e2ap.E2APSubscriptionRequest
97}
98
99func (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
Juha Hyttinen14f82732020-02-27 13:49:06 +0200107 p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
108 p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200109 p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 123
110 p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
111
112 // gnb -> enb outgoing
113 // enb -> gnb incoming
114 // X2 36423-f40.doc
115 p.Req.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
116 p.Req.EventTriggerDefinition.ProcedureCode = 5 //28 35
117 p.Req.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
118
119 p.Req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +0200120
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200121 p.Req.ActionSetups[0].ActionId = 0
122 p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
Anssi Mannila9bcb0a42020-02-11 11:30:44 +0200123 p.Req.ActionSetups[0].ActionDefinition.Present = false // Not supported
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200124 //p.Req.ActionSetups[index].ActionDefinition.StyleId = 255
125 //p.Req.ActionSetups[index].ActionDefinition.ParamId = 222
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
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200129}
130
131//-----------------------------------------------------------------------------
132//
133//-----------------------------------------------------------------------------
134
135type E2StubSubsFailParams struct {
136 Req *e2ap.E2APSubscriptionRequest
137 Fail *e2ap.E2APSubscriptionFailure
138}
139
140func (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.Seq = p.Req.RequestId.Seq
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
154func (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.CauseVal = causeval
160 }
161 return
162 }
163 p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
164 p.Fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
165}
166
167//-----------------------------------------------------------------------------
168//
169//-----------------------------------------------------------------------------
170
171func (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.Logger.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.Logger.Debug("%s %s", trans.String(), e2SubsReq.String())
197
198 params := xapptweaks.NewParams(nil)
199 params.Mtype = xapp.RIC_SUB_REQ
200 params.SubId = -1
201 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200202 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200203 params.Meid = trans.meid
204 params.Xid = trans.xid
205 params.Mbuf = nil
206
207 tc.Logger.Info("SEND SUB REQ: %s", params.String())
208 snderr := tc.RmrSend(params)
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//-----------------------------------------------------------------------------
219func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapptweaks.RMRParams) {
220 tc.Logger.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.Logger.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//-----------------------------------------------------------------------------
250func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapptweaks.RMRParams) {
251 tc.Logger.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.Seq = req.RequestId.Seq
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.CauseVal = 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.Logger.Debug("%s", e2SubsResp.String())
281
282 params := xapptweaks.NewParams(nil)
283 params.Mtype = xapp.RIC_SUB_RESP
284 //params.SubId = msg.SubId
285 params.SubId = -1
286 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200287 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200288 params.Meid = msg.Meid
289 //params.Xid = msg.Xid
290 params.Mbuf = nil
291
292 tc.Logger.Info("SEND SUB RESP: %s", params.String())
293 snderr := tc.RmrSend(params)
294 if snderr != nil {
295 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
296 }
297}
298
299//-----------------------------------------------------------------------------
300//
301//-----------------------------------------------------------------------------
302func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
303 tc.Logger.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.Logger.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
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
343func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapptweaks.RMRParams) {
344 tc.Logger.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.Logger.Debug("%s", e2SubsFail.String())
355
356 params := xapptweaks.NewParams(nil)
357 params.Mtype = xapp.RIC_SUB_FAILURE
358 params.SubId = msg.SubId
359 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200360 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200361 params.Meid = msg.Meid
362 params.Xid = msg.Xid
363 params.Mbuf = nil
364
365 tc.Logger.Info("SEND SUB FAIL: %s", params.String())
366 snderr := tc.RmrSend(params)
367 if snderr != nil {
368 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
369 }
370}
371
372//-----------------------------------------------------------------------------
373//
374//-----------------------------------------------------------------------------
375func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
376 tc.Logger.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.Logger.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
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//-----------------------------------------------------------------------------
415func (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.Logger.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.Seq = 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.Logger.Debug("%s %s", trans.String(), e2SubsDelReq.String())
438
439 params := xapptweaks.NewParams(nil)
440 params.Mtype = xapp.RIC_SUB_DEL_REQ
441 params.SubId = int(e2SubsId)
442 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200443 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200444 params.Meid = trans.meid
445 params.Xid = trans.xid
446 params.Mbuf = nil
447
448 tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
449 snderr := tc.RmrSend(params)
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//-----------------------------------------------------------------------------
460func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapptweaks.RMRParams) {
461 tc.Logger.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.Logger.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//-----------------------------------------------------------------------------
491func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
492 tc.Logger.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.Seq = req.RequestId.Seq
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.Logger.Debug("%s", e2SubsDelResp.String())
508
509 params := xapptweaks.NewParams(nil)
510 params.Mtype = xapp.RIC_SUB_DEL_RESP
511 params.SubId = msg.SubId
512 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200513 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200514 params.Meid = msg.Meid
515 params.Xid = msg.Xid
516 params.Mbuf = nil
517
518 tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
519 snderr := tc.RmrSend(params)
520 if snderr != nil {
521 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
522 }
523}
524
525//-----------------------------------------------------------------------------
526//
527//-----------------------------------------------------------------------------
528func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
529 tc.Logger.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.Logger.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
551 return
552 }
553 } else {
554 tc.TestError(t, "Not Received msg within %d secs", 15)
555 }
556}
557
558//-----------------------------------------------------------------------------
559//
560//-----------------------------------------------------------------------------
561func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
562 tc.Logger.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.Seq = req.RequestId.Seq
571 resp.FunctionId = req.FunctionId
572 resp.Cause.Content = 3 // CauseMisc
573 resp.Cause.CauseVal = 4 // unspecified
574
575 packerr, packedMsg := e2SubsDelFail.Pack(resp)
576 if packerr != nil {
577 tc.TestError(t, "pack NOK %s", packerr.Error())
578 }
579 tc.Logger.Debug("%s", e2SubsDelFail.String())
580
581 params := xapptweaks.NewParams(nil)
582 params.Mtype = xapp.RIC_SUB_DEL_FAILURE
583 params.SubId = msg.SubId
584 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200585 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200586 params.Meid = msg.Meid
587 params.Xid = msg.Xid
588 params.Mbuf = nil
589
590 tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
591 snderr := tc.RmrSend(params)
592 if snderr != nil {
593 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
594 }
595}