2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
23 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestWithData(t *testing.T, areqenc *e2ap.E2APSubscriptionRequest) {
33 e2SubsReq := testCtxt.packerif.NewPackerSubscriptionRequest()
35 testCtxt.testPrint("########## ##########")
36 testCtxt.testPrint("init")
37 testCtxt.testPrint("pack")
38 err, packedMsg := e2SubsReq.Pack(areqenc)
40 testCtxt.testError(t, "Pack failed: %s", err.Error())
43 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
44 testCtxt.testPrint("unpack")
45 err, areqdec := e2SubsReq.UnPack(packedMsg)
47 testCtxt.testError(t, "UnPack failed: %s", err.Error())
50 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
51 testCtxt.testValueEquality(t, "msg", areqenc, areqdec)
52 testCtxt.testValueEquality(t, "EventTriggerDefinition", &areqenc.EventTriggerDefinition, &areqdec.EventTriggerDefinition)
55 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequest(t *testing.T) {
57 areqenc := e2ap.E2APSubscriptionRequest{}
58 areqenc.RequestId.Id = 1
59 areqenc.RequestId.Seq = 22
60 areqenc.FunctionId = 33
61 //Bits 20, 28(works), 18, 21 (asn1 problems)
62 areqenc.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
63 areqenc.EventTriggerDefinition.ProcedureCode = 35
64 areqenc.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
65 for index := 0; index < 16; index++ {
66 item := e2ap.ActionToBeSetupItem{}
67 item.ActionId = uint64(index)
68 item.ActionType = e2ap.E2AP_ActionTypeInsert
69 // NOT SUPPORTED CURRENTLY
70 //item.ActionDefinition.Present = true
71 //item.ActionDefinition.StyleId = 255
72 //item.ActionDefinition.ParamId = 222
73 item.SubsequentAction.Present = true
74 item.SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
75 item.SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW100ms
76 areqenc.ActionSetups = append(areqenc.ActionSetups, item)
79 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
80 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
81 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
82 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
83 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 202251
84 testCtxt.SetDesc("SubsReq-28bit")
85 testCtxt.E2ApTestMsgSubscriptionRequestWithData(t, &areqenc)
87 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
88 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
89 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
90 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDShortMacroits18
91 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
92 //testCtxt.SetDesc("SubsReq-18bit")
93 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
95 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
96 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
97 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
98 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDMacroPBits20
99 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
100 //testCtxt.SetDesc("SubsReq-20bit")
101 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
103 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
104 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
105 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
106 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDlongMacroBits21
107 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
108 //testCtxt.SetDesc("SubsReq-21bit")
109 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
113 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponse(t *testing.T) {
115 testCtxt.SetDesc("SubsResp")
117 e2SubsResp := testCtxt.packerif.NewPackerSubscriptionResponse()
119 testCtxt.testPrint("########## ##########")
120 testCtxt.testPrint("init")
122 arespenc := e2ap.E2APSubscriptionResponse{}
123 arespenc.RequestId.Id = 1
124 arespenc.RequestId.Seq = 22
125 arespenc.FunctionId = 33
126 for index := uint64(0); index < 16; index++ {
127 item := e2ap.ActionAdmittedItem{}
128 item.ActionId = index
129 arespenc.ActionAdmittedList.Items = append(arespenc.ActionAdmittedList.Items, item)
131 for index := uint64(0); index < 16; index++ {
132 item := e2ap.ActionNotAdmittedItem{}
133 item.ActionId = index
134 item.Cause.Content = 1
136 arespenc.ActionNotAdmittedList.Items = append(arespenc.ActionNotAdmittedList.Items, item)
139 testCtxt.testPrint("pack")
140 err, packedMsg := e2SubsResp.Pack(&arespenc)
142 testCtxt.testError(t, "Pack failed: %s", err.Error())
145 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
146 testCtxt.testPrint("unpack")
147 err, arespdec := e2SubsResp.UnPack(packedMsg)
149 testCtxt.testError(t, "UnPack failed: %s", err.Error())
152 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
153 testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
156 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailure(t *testing.T) {
158 testCtxt.SetDesc("SubsFail")
160 e2SubsFail := testCtxt.packerif.NewPackerSubscriptionFailure()
162 testCtxt.testPrint("########## ##########")
163 testCtxt.testPrint("init")
165 afailenc := e2ap.E2APSubscriptionFailure{}
166 afailenc.RequestId.Id = 1
167 afailenc.RequestId.Seq = 22
168 afailenc.FunctionId = 33
169 for index := uint64(0); index < 16; index++ {
170 item := e2ap.ActionNotAdmittedItem{}
171 item.ActionId = index
172 item.Cause.Content = 1
174 afailenc.ActionNotAdmittedList.Items = append(afailenc.ActionNotAdmittedList.Items, item)
176 // NOT SUPPORTED CURRENTLY
177 afailenc.CriticalityDiagnostics.Present = false
178 // afailenc.CriticalityDiagnostics.ProcCodePresent = true
179 // afailenc.CriticalityDiagnostics.ProcCode = 1
180 // afailenc.CriticalityDiagnostics.TrigMsgPresent = true
181 // afailenc.CriticalityDiagnostics.TrigMsg = 2
182 // afailenc.CriticalityDiagnostics.ProcCritPresent = true
183 // afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
184 // for index := uint32(0); index < 256; index++ {
185 // ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
186 // ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
187 // ieitem.IeID = index
188 // ieitem.TypeOfError = 1
189 // afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
192 testCtxt.testPrint("pack")
193 err, packedMsg := e2SubsFail.Pack(&afailenc)
195 testCtxt.testError(t, "Pack failed: %s", err.Error())
198 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
199 testCtxt.testPrint("unpack")
200 err, afaildec := e2SubsFail.UnPack(packedMsg)
202 testCtxt.testError(t, "UnPack failed: %s", err.Error())
205 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
206 testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
209 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
211 testfunc := func(buffer string) {
212 packedData := testCtxt.toPackedData(t, buffer)
213 if packedData == nil {
216 e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
217 err, _ := e2SubResp.UnPack(packedData)
219 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
222 testCtxt.testPrint("OK [%s]", buffer)
225 testCtxt.SetDesc("SubReqBuffer")
226 testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
229 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
231 testfunc := func(buffer string) {
232 packedData := testCtxt.toPackedData(t, buffer)
233 if packedData == nil {
236 e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
237 err, _ := e2SubResp.UnPack(packedData)
239 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
242 testCtxt.testPrint("OK [%s]", buffer)
245 testCtxt.SetDesc("SubRespBuffer")
246 testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
247 testfunc("20c9401d000003ea7e0005004eec0004ea6300020001ea6c000700ea6d40020000")
251 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
253 testfunc := func(buffer string) {
254 packedData := testCtxt.toPackedData(t, buffer)
255 if packedData == nil {
258 e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
259 err, _ := e2SubResp.UnPack(packedData)
261 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
264 testCtxt.testPrint("OK [%s]", buffer)
267 testCtxt.SetDesc("SubFailBuffer")
268 testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")