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.StringPut("310150")
81 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
82 areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 202251
83 testCtxt.SetDesc("SubsReq-28bit")
84 testCtxt.E2ApTestMsgSubscriptionRequestWithData(t, &areqenc)
86 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
87 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
88 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDShortMacroits18
89 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
90 //testCtxt.SetDesc("SubsReq-18bit")
91 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
93 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
94 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
95 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDMacroPBits20
96 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
97 //testCtxt.SetDesc("SubsReq-20bit")
98 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
100 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
101 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
102 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDlongMacroBits21
103 //areqenc.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 55
104 //testCtxt.SetDesc("SubsReq-21bit")
105 //testCtxt.E2ApTestMsgSubscriptionRequestWithData(t,&areqenc)
109 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponse(t *testing.T) {
111 testCtxt.SetDesc("SubsResp")
113 e2SubsResp := testCtxt.packerif.NewPackerSubscriptionResponse()
115 testCtxt.testPrint("########## ##########")
116 testCtxt.testPrint("init")
118 arespenc := e2ap.E2APSubscriptionResponse{}
119 arespenc.RequestId.Id = 1
120 arespenc.RequestId.Seq = 22
121 arespenc.FunctionId = 33
122 for index := uint64(0); index < 16; index++ {
123 item := e2ap.ActionAdmittedItem{}
124 item.ActionId = index
125 arespenc.ActionAdmittedList.Items = append(arespenc.ActionAdmittedList.Items, item)
127 for index := uint64(0); index < 16; index++ {
128 item := e2ap.ActionNotAdmittedItem{}
129 item.ActionId = index
130 item.Cause.Content = 1
131 item.Cause.CauseVal = 1
132 arespenc.ActionNotAdmittedList.Items = append(arespenc.ActionNotAdmittedList.Items, item)
135 testCtxt.testPrint("pack")
136 err, packedMsg := e2SubsResp.Pack(&arespenc)
138 testCtxt.testError(t, "Pack failed: %s", err.Error())
141 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
142 testCtxt.testPrint("unpack")
143 err, arespdec := e2SubsResp.UnPack(packedMsg)
145 testCtxt.testError(t, "UnPack failed: %s", err.Error())
148 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
149 testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
152 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailure(t *testing.T) {
154 testCtxt.SetDesc("SubsFail")
156 e2SubsFail := testCtxt.packerif.NewPackerSubscriptionFailure()
158 testCtxt.testPrint("########## ##########")
159 testCtxt.testPrint("init")
161 afailenc := e2ap.E2APSubscriptionFailure{}
162 afailenc.RequestId.Id = 1
163 afailenc.RequestId.Seq = 22
164 afailenc.FunctionId = 33
165 for index := uint64(0); index < 16; index++ {
166 item := e2ap.ActionNotAdmittedItem{}
167 item.ActionId = index
168 item.Cause.Content = 1
169 item.Cause.CauseVal = 1
170 afailenc.ActionNotAdmittedList.Items = append(afailenc.ActionNotAdmittedList.Items, item)
172 // NOT SUPPORTED CURRENTLY
173 afailenc.CriticalityDiagnostics.Present = false
174 // afailenc.CriticalityDiagnostics.ProcCodePresent = true
175 // afailenc.CriticalityDiagnostics.ProcCode = 1
176 // afailenc.CriticalityDiagnostics.TrigMsgPresent = true
177 // afailenc.CriticalityDiagnostics.TrigMsg = 2
178 // afailenc.CriticalityDiagnostics.ProcCritPresent = true
179 // afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
180 // for index := uint32(0); index < 256; index++ {
181 // ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
182 // ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
183 // ieitem.IeID = index
184 // ieitem.TypeOfError = 1
185 // afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
188 testCtxt.testPrint("pack")
189 err, packedMsg := e2SubsFail.Pack(&afailenc)
191 testCtxt.testError(t, "Pack failed: %s", err.Error())
194 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
195 testCtxt.testPrint("unpack")
196 err, afaildec := e2SubsFail.UnPack(packedMsg)
198 testCtxt.testError(t, "UnPack failed: %s", err.Error())
201 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
202 testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
205 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
207 testfunc := func(buffer string) {
208 packedData := testCtxt.toPackedData(t, buffer)
209 if packedData == nil {
212 e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
213 err, _ := e2SubResp.UnPack(packedData)
215 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
218 testCtxt.testPrint("OK [%s]", buffer)
221 testCtxt.SetDesc("SubReqBuffer")
222 testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
225 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
227 testfunc := func(buffer string) {
228 packedData := testCtxt.toPackedData(t, buffer)
229 if packedData == nil {
232 e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
233 err, _ := e2SubResp.UnPack(packedData)
235 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
238 testCtxt.testPrint("OK [%s]", buffer)
241 testCtxt.SetDesc("SubRespBuffer")
242 testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
243 testfunc("20c9401d000003ea7e0005004eec0004ea6300020001ea6c000700ea6d40020000")
247 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
249 testfunc := func(buffer string) {
250 packedData := testCtxt.toPackedData(t, buffer)
251 if packedData == nil {
254 e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
255 err, _ := e2SubResp.UnPack(packedData)
257 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
260 testCtxt.testPrint("OK [%s]", buffer)
263 testCtxt.SetDesc("SubFailBuffer")
264 testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")