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")
39 err, packedMsg := e2SubsReq.Pack(areqenc)
41 testCtxt.testError(t, "Pack failed: %s", err.Error())
44 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
45 testCtxt.testPrint("unpack")
47 err, areqdec := e2SubsReq.UnPack(packedMsg)
49 testCtxt.testError(t, "UnPack failed: %s", err.Error())
52 testCtxt.testPrint("print:\n%s", e2SubsReq.String())
54 testCtxt.testValueEquality(t, "msg", areqenc, areqdec)
55 testCtxt.testValueEquality(t, "EventTriggerDefinition", &areqenc.EventTriggerDefinition, &areqdec.EventTriggerDefinition)
57 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequest(t *testing.T, msgContent *SubscriptionTestMsgContent) {
59 areqenc := e2ap.E2APSubscriptionRequest{}
60 areqenc.RequestId.Id = 1
61 areqenc.RequestId.InstanceId = 22
62 areqenc.FunctionId = 33
64 if msgContent.NBX2EventTriggerDefinitionPresent {
65 areqenc.EventTriggerDefinition.Data.Length = 1
66 areqenc.EventTriggerDefinition.Data.Data = make([]uint8, areqenc.EventTriggerDefinition.Data.Length)
67 areqenc.EventTriggerDefinition.Data.Data[0] = 1
68 } else if msgContent.NBNRTEventTriggerDefinitionPresent {
69 areqenc.EventTriggerDefinition.Data.Length = 1
70 areqenc.EventTriggerDefinition.Data.Data = make([]uint8, areqenc.EventTriggerDefinition.Data.Length)
71 areqenc.EventTriggerDefinition.Data.Data[0] = 100
74 for index := 0; index < 1; /*16*/ index++ {
75 item := e2ap.ActionToBeSetupItem{}
76 item.ActionId = uint64(index)
77 item.ActionType = e2ap.E2AP_ActionTypeInsert
79 item.RicActionDefinitionPresent = true
81 if item.RicActionDefinitionPresent {
82 if msgContent.ActionDefinitionX2Format1Present {
83 item.ActionDefinitionChoice.Data.Length = 1
84 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
85 item.ActionDefinitionChoice.Data.Data[0] = 1
86 } else if msgContent.ActionDefinitionX2Format2Present {
87 item.ActionDefinitionChoice.Data.Length = 1
88 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
89 item.ActionDefinitionChoice.Data.Data[0] = 2
90 } else if msgContent.ActionDefinitionNRTFormat1Present {
91 item.ActionDefinitionChoice.Data.Length = 1
92 item.ActionDefinitionChoice.Data.Data = make([]uint8, item.ActionDefinitionChoice.Data.Length)
93 item.ActionDefinitionChoice.Data.Data[0] = 3
96 item.SubsequentAction.Present = true
97 item.SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
98 item.SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW100ms
99 areqenc.ActionSetups = append(areqenc.ActionSetups, item)
101 testCtxt.E2ApTestMsgSubscriptionRequestWithData(t, &areqenc)
104 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponse(t *testing.T) {
106 testCtxt.SetDesc("SubsResp")
108 e2SubsResp := testCtxt.packerif.NewPackerSubscriptionResponse()
110 testCtxt.testPrint("########## ##########")
111 testCtxt.testPrint("init")
113 arespenc := e2ap.E2APSubscriptionResponse{}
114 arespenc.RequestId.Id = 1
115 arespenc.RequestId.InstanceId = 22
116 arespenc.FunctionId = 33
117 for index := uint64(0); index < 16; index++ {
118 item := e2ap.ActionAdmittedItem{}
119 item.ActionId = index
120 arespenc.ActionAdmittedList.Items = append(arespenc.ActionAdmittedList.Items, item)
122 for index := uint64(0); index < 16; index++ {
123 item := e2ap.ActionNotAdmittedItem{}
124 item.ActionId = index
125 item.Cause.Content = 1
127 arespenc.ActionNotAdmittedList.Items = append(arespenc.ActionNotAdmittedList.Items, item)
130 testCtxt.testPrint("pack")
131 err, packedMsg := e2SubsResp.Pack(&arespenc)
133 testCtxt.testError(t, "Pack failed: %s", err.Error())
136 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
137 testCtxt.testPrint("unpack")
138 err, arespdec := e2SubsResp.UnPack(packedMsg)
140 testCtxt.testError(t, "UnPack failed: %s", err.Error())
143 testCtxt.testPrint("print:\n%s", e2SubsResp.String())
144 testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
147 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailure(t *testing.T) {
149 testCtxt.SetDesc("SubsFail")
151 e2SubsFail := testCtxt.packerif.NewPackerSubscriptionFailure()
153 testCtxt.testPrint("########## ##########")
154 testCtxt.testPrint("init")
156 afailenc := e2ap.E2APSubscriptionFailure{}
157 afailenc.RequestId.Id = 1
158 afailenc.RequestId.InstanceId = 22
159 afailenc.Cause.Content = e2ap.E2AP_CauseContent_RICrequest
160 afailenc.Cause.Value = e2ap.E2AP_CauseValue_RICrequest_control_message_invalid
162 // NOT SUPPORTED CURRENTLY
163 afailenc.CriticalityDiagnostics.Present = false
164 // afailenc.CriticalityDiagnostics.ProcCodePresent = true
165 // afailenc.CriticalityDiagnostics.ProcCode = 1
166 // afailenc.CriticalityDiagnostics.TrigMsgPresent = true
167 // afailenc.CriticalityDiagnostics.TrigMsg = 2
168 // afailenc.CriticalityDiagnostics.ProcCritPresent = true
169 // afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
170 // for index := uint32(0); index < 256; index++ {
171 // ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
172 // ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
173 // ieitem.IeID = index
174 // ieitem.TypeOfError = 1
175 // afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
178 testCtxt.testPrint("pack")
179 err, packedMsg := e2SubsFail.Pack(&afailenc)
181 testCtxt.testError(t, "Pack failed: %s", err.Error())
184 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
185 testCtxt.testPrint("unpack")
186 err, afaildec := e2SubsFail.UnPack(packedMsg)
188 testCtxt.testError(t, "UnPack failed: %s", err.Error())
191 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
192 testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
195 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
197 testfunc := func(buffer string) {
198 packedData := testCtxt.toPackedData(t, buffer)
199 if packedData == nil {
202 e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
203 err, _ := e2SubResp.UnPack(packedData)
205 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
208 testCtxt.testPrint("OK [%s]", buffer)
211 testCtxt.SetDesc("SubReqBuffer")
212 testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
215 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
217 testfunc := func(buffer string) {
218 packedData := testCtxt.toPackedData(t, buffer)
219 if packedData == nil {
222 e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
223 err, _ := e2SubResp.UnPack(packedData)
225 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
228 testCtxt.testPrint("OK [%s]", buffer)
231 testCtxt.SetDesc("SubRespBuffer")
232 testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
233 testfunc("20c9401d000003ea7e0005004eec0004ea6300020001ea6c000700ea6d40020000")
237 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
239 testfunc := func(buffer string) {
240 packedData := testCtxt.toPackedData(t, buffer)
241 if packedData == nil {
244 e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
245 err, _ := e2SubResp.UnPack(packedData)
247 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
250 testCtxt.testPrint("OK [%s]", buffer)
253 testCtxt.SetDesc("SubFailBuffer")
254 testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")