blob: bb2dff666658224fd62a8badaeef876b41a71521 [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
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200103 p.Req.RequestId.InstanceId = 0
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200104 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)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +0200119
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200120 p.Req.ActionSetups[0].ActionId = 0
121 p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200122 p.Req.ActionSetups[0].RicActionDefinitionPresent = true
123 p.Req.ActionSetups[0].ActionDefinitionChoice.ActionDefinitionFormat1Present = false
124 p.Req.ActionSetups[0].ActionDefinitionChoice.ActionDefinitionFormat2Present = true
125
126 // 1..15
127 for index2 := 0; index2 < 1; index2++ {
128 ranUEgroupItem := e2ap.RANueGroupItem{}
129 // 1..255
130 for index2 := 0; index2 < 1; index2++ {
131 ranUEGroupDefItem := e2ap.RANueGroupDefItem{}
132 ranUEGroupDefItem.RanParameterID = 22
133 ranUEGroupDefItem.RanParameterTest = e2ap.RANParameterTest_equal
134 ranUEGroupDefItem.RanParameterValue.ValueIntPresent = true
135 ranUEGroupDefItem.RanParameterValue.ValueInt = 100
136 ranUEgroupItem.RanUEgroupDefinition.RanUEGroupDefItems = append(ranUEgroupItem.RanUEgroupDefinition.RanUEGroupDefItems, ranUEGroupDefItem)
137 }
138 // 1..255
139 for index3 := 0; index3 < 1; index3++ {
140 ranParameterItem := e2ap.RANParameterItem{}
141 ranParameterItem.RanParameterID = 33
142 ranParameterItem.RanParameterValue.ValueIntPresent = true
143 ranParameterItem.RanParameterValue.ValueInt = 100
144 ranUEgroupItem.RanPolicy.RanParameterItems = append(ranUEgroupItem.RanPolicy.RanParameterItems, ranParameterItem)
145 }
146 ranUEgroupItem.RanUEgroupID = 2
147 p.Req.ActionSetups[0].ActionDefinitionChoice.ActionDefinitionFormat2.RanUEgroupItems =
148 append(p.Req.ActionSetups[0].ActionDefinitionChoice.ActionDefinitionFormat2.RanUEgroupItems, ranUEgroupItem)
149 }
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200150 p.Req.ActionSetups[0].SubsequentAction.Present = true
151 p.Req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
152 p.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200153}
154
155//-----------------------------------------------------------------------------
156//
157//-----------------------------------------------------------------------------
158
159type E2StubSubsFailParams struct {
160 Req *e2ap.E2APSubscriptionRequest
161 Fail *e2ap.E2APSubscriptionFailure
162}
163
164func (p *E2StubSubsFailParams) Set(req *e2ap.E2APSubscriptionRequest) {
165 p.Req = req
166
167 p.Fail = &e2ap.E2APSubscriptionFailure{}
168 p.Fail.RequestId.Id = p.Req.RequestId.Id
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200169 p.Fail.RequestId.InstanceId = p.Req.RequestId.InstanceId
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200170 p.Fail.FunctionId = p.Req.FunctionId
171 p.Fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.Req.ActionSetups))
172 for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
173 p.Fail.ActionNotAdmittedList.Items[index].ActionId = p.Req.ActionSetups[index].ActionId
174 p.SetCauseVal(index, 5, 1)
175 }
176}
177
178func (p *E2StubSubsFailParams) SetCauseVal(ind int, content uint8, causeval uint8) {
179
180 if ind < 0 {
181 for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
182 p.Fail.ActionNotAdmittedList.Items[index].Cause.Content = content
183 p.Fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval
184 }
185 return
186 }
187 p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
188 p.Fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
189}
190
191//-----------------------------------------------------------------------------
192//
193//-----------------------------------------------------------------------------
194
195func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTrans *RmrTransactionId) *RmrTransactionId {
196
197 trans := oldTrans
198 if oldTrans == nil {
199 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
200 }
201
202 tc.Logger.Info("SendSubsReq %s", trans.String())
203 e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
204
205 //---------------------------------
206 // xapp activity: Send Subs Req
207 //---------------------------------
208 myparams := rparams
209
210 if myparams == nil {
211 myparams = &E2StubSubsReqParams{}
212 myparams.Init()
213 }
214
215 err, packedMsg := e2SubsReq.Pack(myparams.Req)
216 if err != nil {
217 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
218 return nil
219 }
220 tc.Logger.Debug("%s %s", trans.String(), e2SubsReq.String())
221
222 params := xapptweaks.NewParams(nil)
223 params.Mtype = xapp.RIC_SUB_REQ
224 params.SubId = -1
225 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200226 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200227 params.Meid = trans.meid
228 params.Xid = trans.xid
229 params.Mbuf = nil
230
231 tc.Logger.Info("SEND SUB REQ: %s", params.String())
232 snderr := tc.RmrSend(params)
233 if snderr != nil {
234 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
235 return nil
236 }
237 return trans
238}
239
240//-----------------------------------------------------------------------------
241//
242//-----------------------------------------------------------------------------
243func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapptweaks.RMRParams) {
244 tc.Logger.Info("RecvSubsReq")
245 e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
246
247 //---------------------------------
248 // e2term activity: Recv Subs Req
249 //---------------------------------
250 msg := tc.WaitMsg(15)
251 if msg != nil {
252 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
253 tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
254 } else {
255 tc.Logger.Info("Recv Subs Req")
256 packedData := &e2ap.PackedData{}
257 packedData.Buf = msg.Payload
258 unpackerr, req := e2SubsReq.UnPack(packedData)
259 if unpackerr != nil {
260 tc.TestError(t, "RIC_SUB_REQ unpack failed err: %s", unpackerr.Error())
261 }
262 return req, msg
263 }
264 } else {
265 tc.TestError(t, "Not Received msg within %d secs", 15)
266 }
267
268 return nil, nil
269}
270
271//-----------------------------------------------------------------------------
272//
273//-----------------------------------------------------------------------------
274func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapptweaks.RMRParams) {
275 tc.Logger.Info("SendSubsResp")
276 e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
277
278 //---------------------------------
279 // e2term activity: Send Subs Resp
280 //---------------------------------
281 resp := &e2ap.E2APSubscriptionResponse{}
282
283 resp.RequestId.Id = req.RequestId.Id
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200284 resp.RequestId.InstanceId = req.RequestId.InstanceId
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200285 resp.FunctionId = req.FunctionId
286
287 resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
288 for index := int(0); index < len(req.ActionSetups); index++ {
289 resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
290 }
291
292 for index := uint64(0); index < 1; index++ {
293 item := e2ap.ActionNotAdmittedItem{}
294 item.ActionId = index
295 item.Cause.Content = 1
296 item.Cause.CauseVal = 1
297 resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
298 }
299
300 packerr, packedMsg := e2SubsResp.Pack(resp)
301 if packerr != nil {
302 tc.TestError(t, "pack NOK %s", packerr.Error())
303 }
304 tc.Logger.Debug("%s", e2SubsResp.String())
305
306 params := xapptweaks.NewParams(nil)
307 params.Mtype = xapp.RIC_SUB_RESP
308 //params.SubId = msg.SubId
309 params.SubId = -1
310 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200311 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200312 params.Meid = msg.Meid
313 //params.Xid = msg.Xid
314 params.Mbuf = nil
315
316 tc.Logger.Info("SEND SUB RESP: %s", params.String())
317 snderr := tc.RmrSend(params)
318 if snderr != nil {
319 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
320 }
321}
322
323//-----------------------------------------------------------------------------
324//
325//-----------------------------------------------------------------------------
326func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
327 tc.Logger.Info("RecvSubsResp")
328 e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
329 var e2SubsId uint32
330
331 //---------------------------------
332 // xapp activity: Recv Subs Resp
333 //---------------------------------
334 msg := tc.WaitMsg(15)
335 if msg != nil {
336 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
337 tc.TestError(t, "Received RIC_SUB_RESP wrong mtype expected %s got %s, error", "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
338 return 0
339 } else if msg.Xid != trans.xid {
340 tc.TestError(t, "Received RIC_SUB_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
341 return 0
342 } else {
343 packedData := &e2ap.PackedData{}
344 packedData.Buf = msg.Payload
345 if msg.SubId > 0 {
346 e2SubsId = uint32(msg.SubId)
347 } else {
348 e2SubsId = 0
349 }
350 unpackerr, resp := e2SubsResp.UnPack(packedData)
351 if unpackerr != nil {
352 tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
353 }
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200354 tc.Logger.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200355 return e2SubsId
356 }
357 } else {
358 tc.TestError(t, "Not Received msg within %d secs", 15)
359 }
360 return 0
361}
362
363//-----------------------------------------------------------------------------
364//
365//-----------------------------------------------------------------------------
366
367func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapptweaks.RMRParams) {
368 tc.Logger.Info("SendSubsFail")
369 e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
370
371 //---------------------------------
372 // e2term activity: Send Subs Fail
373 //---------------------------------
374 packerr, packedMsg := e2SubsFail.Pack(fparams.Fail)
375 if packerr != nil {
376 tc.TestError(t, "pack NOK %s", packerr.Error())
377 }
378 tc.Logger.Debug("%s", e2SubsFail.String())
379
380 params := xapptweaks.NewParams(nil)
381 params.Mtype = xapp.RIC_SUB_FAILURE
382 params.SubId = msg.SubId
383 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200384 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200385 params.Meid = msg.Meid
386 params.Xid = msg.Xid
387 params.Mbuf = nil
388
389 tc.Logger.Info("SEND SUB FAIL: %s", params.String())
390 snderr := tc.RmrSend(params)
391 if snderr != nil {
392 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
393 }
394}
395
396//-----------------------------------------------------------------------------
397//
398//-----------------------------------------------------------------------------
399func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
400 tc.Logger.Info("RecvSubsFail")
401 e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
402 var e2SubsId uint32
403
404 //-------------------------------
405 // xapp activity: Recv Subs Fail
406 //-------------------------------
407 msg := tc.WaitMsg(15)
408 if msg != nil {
409 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] {
410 tc.TestError(t, "Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype])
411 return 0
412 } else if msg.Xid != trans.xid {
413 tc.TestError(t, "Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", trans.xid, msg.Xid)
414 return 0
415 } else {
416 packedData := &e2ap.PackedData{}
417 packedData.Buf = msg.Payload
418 if msg.SubId > 0 {
419 e2SubsId = uint32(msg.SubId)
420 } else {
421 e2SubsId = 0
422 }
423 unpackerr, resp := e2SubsFail.UnPack(packedData)
424 if unpackerr != nil {
425 tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
426 }
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200427 tc.Logger.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200428 return e2SubsId
429 }
430 } else {
431 tc.TestError(t, "Not Received msg within %d secs", 15)
432 }
433 return 0
434}
435
436//-----------------------------------------------------------------------------
437//
438//-----------------------------------------------------------------------------
439func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2SubsId uint32) *RmrTransactionId {
440
441 trans := oldTrans
442 if oldTrans == nil {
443 trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
444 }
445
446 tc.Logger.Info("SendSubsDelReq %s", trans.String())
447 e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
448 //---------------------------------
449 // xapp activity: Send Subs Del Req
450 //---------------------------------
451 req := &e2ap.E2APSubscriptionDeleteRequest{}
452 req.RequestId.Id = 1
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200453 req.RequestId.InstanceId = e2SubsId
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200454 req.FunctionId = 1
455
456 err, packedMsg := e2SubsDelReq.Pack(req)
457 if err != nil {
458 tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
459 return nil
460 }
461 tc.Logger.Debug("%s %s", trans.String(), e2SubsDelReq.String())
462
463 params := xapptweaks.NewParams(nil)
464 params.Mtype = xapp.RIC_SUB_DEL_REQ
465 params.SubId = int(e2SubsId)
466 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200467 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200468 params.Meid = trans.meid
469 params.Xid = trans.xid
470 params.Mbuf = nil
471
472 tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
473 snderr := tc.RmrSend(params)
474 if snderr != nil {
475 tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
476 return nil
477 }
478 return trans
479}
480
481//-----------------------------------------------------------------------------
482//
483//-----------------------------------------------------------------------------
484func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapptweaks.RMRParams) {
485 tc.Logger.Info("RecvSubsDelReq")
486 e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
487
488 //---------------------------------
489 // e2term activity: Recv Subs Del Req
490 //---------------------------------
491 msg := tc.WaitMsg(15)
492 if msg != nil {
493 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
494 tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
495 } else {
496 tc.Logger.Info("Recv Subs Del Req")
497
498 packedData := &e2ap.PackedData{}
499 packedData.Buf = msg.Payload
500 unpackerr, req := e2SubsDelReq.UnPack(packedData)
501 if unpackerr != nil {
502 tc.TestError(t, "RIC_SUB_DEL_REQ unpack failed err: %s", unpackerr.Error())
503 }
504 return req, msg
505 }
506 } else {
507 tc.TestError(t, "Not Received msg within %d secs", 15)
508 }
509 return nil, nil
510}
511
512//-----------------------------------------------------------------------------
513//
514//-----------------------------------------------------------------------------
515func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
516 tc.Logger.Info("SendSubsDelResp")
517 e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
518
519 //---------------------------------
520 // e2term activity: Send Subs Del Resp
521 //---------------------------------
522 resp := &e2ap.E2APSubscriptionDeleteResponse{}
523 resp.RequestId.Id = req.RequestId.Id
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200524 resp.RequestId.InstanceId = req.RequestId.InstanceId
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200525 resp.FunctionId = req.FunctionId
526
527 packerr, packedMsg := e2SubsDelResp.Pack(resp)
528 if packerr != nil {
529 tc.TestError(t, "pack NOK %s", packerr.Error())
530 }
531 tc.Logger.Debug("%s", e2SubsDelResp.String())
532
533 params := xapptweaks.NewParams(nil)
534 params.Mtype = xapp.RIC_SUB_DEL_RESP
535 params.SubId = msg.SubId
536 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200537 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200538 params.Meid = msg.Meid
539 params.Xid = msg.Xid
540 params.Mbuf = nil
541
542 tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
543 snderr := tc.RmrSend(params)
544 if snderr != nil {
545 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
546 }
547}
548
549//-----------------------------------------------------------------------------
550//
551//-----------------------------------------------------------------------------
552func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
553 tc.Logger.Info("RecvSubsDelResp")
554 e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
555
556 //---------------------------------
557 // xapp activity: Recv Subs Del Resp
558 //---------------------------------
559 msg := tc.WaitMsg(15)
560 if msg != nil {
561 if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
562 tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
563 return
564 } else if trans != nil && msg.Xid != trans.xid {
565 tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
566 return
567 } else {
568 packedData := &e2ap.PackedData{}
569 packedData.Buf = msg.Payload
570 unpackerr, resp := e2SubsDelResp.UnPack(packedData)
571 if unpackerr != nil {
572 tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
573 }
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200574 tc.Logger.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200575 return
576 }
577 } else {
578 tc.TestError(t, "Not Received msg within %d secs", 15)
579 }
580}
581
582//-----------------------------------------------------------------------------
583//
584//-----------------------------------------------------------------------------
585func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
586 tc.Logger.Info("SendSubsDelFail")
587 e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
588
589 //---------------------------------
590 // e2term activity: Send Subs Del Fail
591 //---------------------------------
592 resp := &e2ap.E2APSubscriptionDeleteFailure{}
593 resp.RequestId.Id = req.RequestId.Id
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200594 resp.RequestId.InstanceId = req.RequestId.InstanceId
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200595 resp.FunctionId = req.FunctionId
Anssi Mannilad2ee0c72020-03-02 15:42:37 +0200596 resp.Cause.Content = 4 // CauseMisc
597 resp.Cause.CauseVal = 3 // unspecified
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200598
599 packerr, packedMsg := e2SubsDelFail.Pack(resp)
600 if packerr != nil {
601 tc.TestError(t, "pack NOK %s", packerr.Error())
602 }
603 tc.Logger.Debug("%s", e2SubsDelFail.String())
604
605 params := xapptweaks.NewParams(nil)
606 params.Mtype = xapp.RIC_SUB_DEL_FAILURE
607 params.SubId = msg.SubId
608 params.Payload = packedMsg.Buf
Juha Hyttinen4e69e562020-02-25 12:23:20 +0200609 params.PayloadLen = len(packedMsg.Buf)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200610 params.Meid = msg.Meid
611 params.Xid = msg.Xid
612 params.Mbuf = nil
613
614 tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
615 snderr := tc.RmrSend(params)
616 if snderr != nil {
617 tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
618 }
619}