2 * Copyright (c) 2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 * platform project (RICP).
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
33 Test permutations of x2 setup response to protobuf enb
36 func TestUnpackEndcX2SetupFailureResponseAndExtract(t *testing.T) {
37 logger, _ := logger.InitLogger(logger.InfoLevel)
39 var testCases = []struct {
45 response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
49 procedureCode_t = 0x24
53 ProtocolIE_Container_elm
58 ProtocolIE_Container_elm
62 ProtocolIE_Container_elm
65 CriticalityDiagnostics
66 procedureCode_t = 0x21
67 triggeringMessage_t = 0x2
68 procedureCriticality_t = 0x2
69 iEsCriticalityDiagnostics_t:
70 CriticalityDiagnostics_IE_List_elm
75 packedPdu: "4024001a0000030005400200000016400100001140087821a00000008040"},
77 /**** shares the same code with x2setup failure response to protobuf ****/
80 converter := NewEndcSetupFailureResponseConverter(logger)
82 for _, tc := range testCases {
83 t.Run(tc.packedPdu, func(t *testing.T) {
86 _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
88 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
91 response, err := converter.UnpackEndcSetupFailureResponseAndExtract(payload)
94 if tc.failure == nil {
95 t.Errorf("want: success, got: error: %v\n", err)
97 if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
98 t.Errorf("want: %s, got: %s", tc.failure, err)
104 if tc.failure == nil {
105 t.Errorf("want: response=%s, got: empty response", tc.response)
108 nb := &entities.NodebInfo{}
109 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED_SETUP_FAILED
110 nb.SetupFailure = response
111 nb.FailureType = entities.Failure_X2_SETUP_FAILURE
112 respStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, response)
113 if !strings.EqualFold(respStr, tc.response) {
114 t.Errorf("want: response=[%s], got: [%s]", tc.response, respStr)