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 ==================================================================================
25 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
32 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestWithData(t *testing.T, areqenc *e2ap.E2APSubscriptionRequest) {
34 e2SubsReq := testCtxt.packerif.NewPackerSubscriptionRequest()
36 testCtxt.testPrint("########## ##########")
37 testCtxt.testPrint("init")
38 testCtxt.testPrint("pack")
40 err, packedMsg := e2SubsReq.Pack(areqenc)
42 testCtxt.testError(t, "Pack failed: %s", err.Error())
45 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
46 testCtxt.testPrint("unpack")
48 err, areqdec := e2SubsReq.UnPack(packedMsg)
50 testCtxt.testError(t, "UnPack failed: %s", err.Error())
53 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
55 testCtxt.testValueEquality(t, "msg", areqenc, areqdec)
56 testCtxt.testValueEquality(t, "EventTriggerDefinition", &areqenc.EventTriggerDefinition, &areqdec.EventTriggerDefinition)
58 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequest(t *testing.T, msgContent *SubscriptionTestMsgContent) {
60 areqenc := e2ap.E2APSubscriptionRequest{}
61 areqenc.RequestId.Id = 1
62 areqenc.RequestId.InstanceId = 22
63 areqenc.FunctionId = 33
65 if msgContent.NBX2EventTriggerDefinitionPresent {
66 areqenc.EventTriggerDefinition.Data.Length = 1
67 areqenc.EventTriggerDefinition.Data.Data = make([]uint8, areqenc.EventTriggerDefinition.Data.Length)
68 areqenc.EventTriggerDefinition.Data.Data[0] = 1
69 } else if msgContent.NBNRTEventTriggerDefinitionPresent {
70 areqenc.EventTriggerDefinition.Data.Length = 1
71 areqenc.EventTriggerDefinition.Data.Data = make([]uint8, areqenc.EventTriggerDefinition.Data.Length)
72 areqenc.EventTriggerDefinition.Data.Data[0] = 100
75 for index := 0; index < 1; /*16*/ index++ {
76 item := e2ap.ActionToBeSetupItem{}
77 item.ActionId = uint64(index)
78 item.ActionType = e2ap.E2AP_ActionTypeInsert
80 item.RicActionDefinitionPresent = true
82 if item.RicActionDefinitionPresent {
83 if msgContent.ActionDefinitionX2Format1Present {
84 item.ActionDefinitionChoice.Data.Length = 1
85 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
86 item.ActionDefinitionChoice.Data.Data[0] = 1
87 } else if msgContent.ActionDefinitionX2Format2Present {
88 item.ActionDefinitionChoice.Data.Length = 1
89 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
90 item.ActionDefinitionChoice.Data.Data[0] = 2
91 } else if msgContent.ActionDefinitionNRTFormat1Present {
92 item.ActionDefinitionChoice.Data.Length = 1
93 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
94 item.ActionDefinitionChoice.Data.Data[0] = 3
97 item.SubsequentAction.Present = true
98 item.SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
99 item.SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW100ms
100 areqenc.ActionSetups = append(areqenc.ActionSetups, item)
102 testCtxt.E2ApTestMsgSubscriptionRequestWithData(t, &areqenc)
105 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponse(t *testing.T) {
107 testCtxt.SetDesc("SubsResp")
109 e2SubsResp := testCtxt.packerif.NewPackerSubscriptionResponse()
111 testCtxt.testPrint("########## ##########")
112 testCtxt.testPrint("init")
114 arespenc := e2ap.E2APSubscriptionResponse{}
115 arespenc.RequestId.Id = 1
116 arespenc.RequestId.InstanceId = 22
117 arespenc.FunctionId = 33
118 for index := uint64(0); index < 16; index++ {
119 item := e2ap.ActionAdmittedItem{}
120 item.ActionId = index
121 arespenc.ActionAdmittedList.Items = append(arespenc.ActionAdmittedList.Items, item)
123 for index := uint64(0); index < 16; index++ {
124 item := e2ap.ActionNotAdmittedItem{}
125 item.ActionId = index
126 item.Cause.Content = 1
128 arespenc.ActionNotAdmittedList.Items = append(arespenc.ActionNotAdmittedList.Items, item)
131 testCtxt.testPrint("pack")
132 err, packedMsg := e2SubsResp.Pack(&arespenc)
134 testCtxt.testError(t, "Pack failed: %s", err.Error())
137 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
138 testCtxt.testPrint("unpack")
139 err, arespdec := e2SubsResp.UnPack(packedMsg)
141 testCtxt.testError(t, "UnPack failed: %s", err.Error())
144 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
145 testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
148 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailure(t *testing.T) {
150 testCtxt.SetDesc("SubsFail")
152 e2SubsFail := testCtxt.packerif.NewPackerSubscriptionFailure()
154 testCtxt.testPrint("########## ##########")
155 testCtxt.testPrint("init")
157 afailenc := e2ap.E2APSubscriptionFailure{}
158 afailenc.RequestId.Id = 1
159 afailenc.RequestId.InstanceId = 22
160 afailenc.Cause.Content = e2ap.E2AP_CauseContent_RICrequest
161 afailenc.Cause.Value = e2ap.E2AP_CauseValue_RICrequest_control_message_invalid
163 // NOT SUPPORTED CURRENTLY
164 afailenc.CriticalityDiagnostics.Present = false
165 // afailenc.CriticalityDiagnostics.ProcCodePresent = true
166 // afailenc.CriticalityDiagnostics.ProcCode = 1
167 // afailenc.CriticalityDiagnostics.TrigMsgPresent = true
168 // afailenc.CriticalityDiagnostics.TrigMsg = 2
169 // afailenc.CriticalityDiagnostics.ProcCritPresent = true
170 // afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
171 // for index := uint32(0); index < 256; index++ {
172 // ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
173 // ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
174 // ieitem.IeID = index
175 // ieitem.TypeOfError = 1
176 // afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
179 testCtxt.testPrint("pack")
180 err, packedMsg := e2SubsFail.Pack(&afailenc)
182 testCtxt.testError(t, "Pack failed: %s", err.Error())
185 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
186 testCtxt.testPrint("unpack")
187 err, afaildec := e2SubsFail.UnPack(packedMsg)
189 testCtxt.testError(t, "UnPack failed: %s", err.Error())
192 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
193 testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
196 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
198 testfunc := func(buffer string) {
199 packedData := testCtxt.toPackedData(t, buffer)
200 if packedData == nil {
203 e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
204 err, _ := e2SubResp.UnPack(packedData)
206 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
209 testCtxt.testPrint("OK [%s]", buffer)
212 testCtxt.SetDesc("SubReqBuffer")
213 testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
216 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
218 testfunc := func(buffer string) {
219 packedData := testCtxt.toPackedData(t, buffer)
220 if packedData == nil {
223 e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
224 err, _ := e2SubResp.UnPack(packedData)
226 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
229 testCtxt.testPrint("OK [%s]", buffer)
232 testCtxt.SetDesc("SubRespBuffer")
233 testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
234 testfunc("20c9401d000003ea7e0005004eec0004ea6300020001ea6c000700ea6d40020000")
238 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
240 testfunc := func(buffer string) {
241 packedData := testCtxt.toPackedData(t, buffer)
242 if packedData == nil {
245 e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
246 err, _ := e2SubResp.UnPack(packedData)
248 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
251 testCtxt.testPrint("OK [%s]", buffer)
254 testCtxt.SetDesc("SubFailBuffer")
255 testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")