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.FunctionId = 33
160 for index := uint64(0); index < 16; index++ {
161 item := e2ap.ActionNotAdmittedItem{}
162 item.ActionId = index
163 item.Cause.Content = 1
165 afailenc.ActionNotAdmittedList.Items = append(afailenc.ActionNotAdmittedList.Items, item)
167 // NOT SUPPORTED CURRENTLY
168 afailenc.CriticalityDiagnostics.Present = false
169 // afailenc.CriticalityDiagnostics.ProcCodePresent = true
170 // afailenc.CriticalityDiagnostics.ProcCode = 1
171 // afailenc.CriticalityDiagnostics.TrigMsgPresent = true
172 // afailenc.CriticalityDiagnostics.TrigMsg = 2
173 // afailenc.CriticalityDiagnostics.ProcCritPresent = true
174 // afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
175 // for index := uint32(0); index < 256; index++ {
176 // ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
177 // ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
178 // ieitem.IeID = index
179 // ieitem.TypeOfError = 1
180 // afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
183 testCtxt.testPrint("pack")
184 err, packedMsg := e2SubsFail.Pack(&afailenc)
186 testCtxt.testError(t, "Pack failed: %s", err.Error())
189 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
190 testCtxt.testPrint("unpack")
191 err, afaildec := e2SubsFail.UnPack(packedMsg)
193 testCtxt.testError(t, "UnPack failed: %s", err.Error())
196 testCtxt.testPrint("print:\n%s", e2SubsFail.String())
197 testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
200 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionRequestBuffers(t *testing.T) {
202 testfunc := func(buffer string) {
203 packedData := testCtxt.toPackedData(t, buffer)
204 if packedData == nil {
207 e2SubResp := testCtxt.packerif.NewPackerSubscriptionRequest()
208 err, _ := e2SubResp.UnPack(packedData)
210 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
213 testCtxt.testPrint("OK [%s]", buffer)
216 testCtxt.SetDesc("SubReqBuffer")
217 testfunc("00c9402c000003ea7e00050000010000ea6300020001ea810016000b00130051407b000000054000ea6b000420000000")
220 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionResponseBuffers(t *testing.T) {
222 testfunc := func(buffer string) {
223 packedData := testCtxt.toPackedData(t, buffer)
224 if packedData == nil {
227 e2SubResp := testCtxt.packerif.NewPackerSubscriptionResponse()
228 err, _ := e2SubResp.UnPack(packedData)
230 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
233 testCtxt.testPrint("OK [%s]", buffer)
236 testCtxt.SetDesc("SubRespBuffer")
237 testfunc("20c9402a000004ea7e00050000018009ea6300020001ea6c000700ea6d00020000ea6e000908ea6f000400000040")
238 testfunc("20c9401d000003ea7e0005004eec0004ea6300020001ea6c000700ea6d40020000")
242 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionFailureBuffers(t *testing.T) {
244 testfunc := func(buffer string) {
245 packedData := testCtxt.toPackedData(t, buffer)
246 if packedData == nil {
249 e2SubResp := testCtxt.packerif.NewPackerSubscriptionFailure()
250 err, _ := e2SubResp.UnPack(packedData)
252 testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
255 testCtxt.testPrint("OK [%s]", buffer)
258 testCtxt.SetDesc("SubFailBuffer")
259 testfunc("40c94017000003ea7e000500000106f3ea6300020001ea6e000100")