xapp-bs-connector --> xapp-sm-connector
This commit is contained in:
83
setup/xapp-sm-connector/test/Makefile
Normal file
83
setup/xapp-sm-connector/test/Makefile
Normal file
@@ -0,0 +1,83 @@
|
||||
CXX:= g++ --std=c++14 -O2 -L/usr/local/lib
|
||||
CC:= gcc -O2 -L/usr/local/lib
|
||||
|
||||
TEST:=./
|
||||
SRC:=../src
|
||||
UTILSRC=../src/xapp-utils
|
||||
MGMTSRC:=../src/xapp-mgmt
|
||||
|
||||
ASNSRC:=../asn1c_defs
|
||||
E2APSRC:=../src/xapp-asn/e2ap
|
||||
E2SMSRC:=../src/xapp-asn/e2sm
|
||||
|
||||
####### Logging library and flags
|
||||
CLOGFLAGS:= `pkg-config mdclog --cflags`
|
||||
LOG_LIBS:= `pkg-config mdclog --libs`
|
||||
CURL_LIBS:= `pkg-config libcurl --libs`
|
||||
RNIB_LIBS:= -pthread /usr/local/include/rnib/rnibreader.a
|
||||
GTEST_LIBS:= -lgtest -lgtest_main
|
||||
######## Keep include dirs separate so we have transparency
|
||||
|
||||
|
||||
BASEFLAGS= -Wall -std=c++14 $(CLOGFLAGS)
|
||||
C_BASEFLAGS= -Wall $(CLOGFLAGS) -DASN_DISABLE_OER_SUPPORT
|
||||
|
||||
XAPPFLAGS= -I$(SRC)
|
||||
UTILFLAGS= -I$(UTILSRC)
|
||||
MGMTFLAGS= -I$(MGMTSRC)
|
||||
|
||||
ASNFLAGS=-I$(ASNSRC) -DASN_DISABLE_OER_SUPPORT
|
||||
E2APFLAGS = -I$(E2APSRC)
|
||||
E2SMFLAGS = -I$(E2SMSRC)
|
||||
|
||||
########libs
|
||||
|
||||
LIBS= -lsdl -lrmr_si -lpthread -lm $(LOG_LIBS) $(CURL_LIBS) $(RNIB_LIBS) $(GTEST_LIBS)
|
||||
COV_FLAGS= -fprofile-arcs -ftest-coverage
|
||||
|
||||
#######
|
||||
TEST_SRC= hw_unit_tests.cc
|
||||
XAPP_SRC= ../src/xapp.cc
|
||||
TEST_HDR=$(wildcard $(TEST)/*.h)
|
||||
UTIL_SRC= $(wildcard $(UTILSRC)/*.cc)
|
||||
MGMT_SRC= $(wildcard $(MGMTSRC)/*.cc)
|
||||
|
||||
E2AP_SRC= $(wildcard $(E2APSRC)/*.cc)
|
||||
E2SM_SRC= $(wildcard $(E2SMSRC)/*.cc)
|
||||
ASN1C_SRC= $(wildcard $(ASNSRC)/*.c)
|
||||
|
||||
##############Objects
|
||||
UTIL_OBJ=${UTIL_SRC:.cc=.o}
|
||||
MGMT_OBJ=${MGMT_SRC:.cc=.o}
|
||||
XAPP_OBJ=${XAPP_SRC:.cc=.o}
|
||||
TEST_OBJ=${TEST_SRC:.cc=.o}
|
||||
|
||||
E2AP_OBJ = $(E2AP_SRC:.cc=.o)
|
||||
E2SM_OBJ = $(E2SM_SRC:.cc=.o)
|
||||
|
||||
ASN1C_MODULES = $(ASN1C_SRC:.c=.o)
|
||||
$(ASN1C_MODULES): export CFLAGS = $(C_BASEFLAGS) $(ASNFLAGS)
|
||||
|
||||
$(UTIL_OBJ):export CPPFLAGS=$(BASEFLAGS) $(UTILFLAGS) $(MGMTFLAGS)
|
||||
$(MGMT_OBJ):export CPPFLAGS=$(BASEFLAGS) $(MGMTFLAGS) $(ASNFLAGS) $(E2APFLAGS) $(E2SMFLAGS)
|
||||
|
||||
$(E2AP_OBJ): export CPPFLAGS = $(BASEFLAGS) $(ASNFLAGS) $(E2APFLAGS)
|
||||
$(E2SM_OBJ): export CPPFLAGS = $(BASEFLAGS) $(ASNFLAGS) $(E2SMFLAGS)
|
||||
$(XAPP_OBJ): export CPPFLAGS = $(BASEFLAGS) $(XAPPFLAGS) $(UTILFLAGS) $(MGMTFLAGS) $(E2APFLAGS) $(E2SMFLAGS) $(ASNFLAGS)
|
||||
|
||||
$(TEST_OBJ):export CPPFLAGS=$(BASEFLAGS) $(XAPPFLAGS) $(UTILFLAGS) $(MGMTFLAGS) $(E2APFLAGS) $(E2SMFLAGS) $(ASNFLAGS)
|
||||
$(TEST_OBJ) = $(TEST_HDR) $(TEST_OBJ)
|
||||
|
||||
|
||||
OBJ= $(TEST_OBJ) $(UTIL_OBJ) $(MGMT_OBJ) $(ASN1C_MODULES) $(E2AP_OBJ) $(E2SM_OBJ) $(XAPP_OBJ)
|
||||
|
||||
print-% : ; @echo $* = $($*)
|
||||
|
||||
hw_unit_tests: $(OBJ)
|
||||
$(CXX) -o $@ $(OBJ) $(LIBS) $(RNIBFLAGS) $(CPPFLAGS) $(CLOGFLAGS)
|
||||
|
||||
install: hw_unit_tests
|
||||
install -D hw_unit_tests /usr/local/bin/hw_unit_tests
|
||||
|
||||
clean:
|
||||
-rm *.o $(E2APSRC)/*.o $(UTILSRC)/*.o $(E2SMSRC)/*.o $(MGMTSRC)/*.o $(SRC)/*.o hw_unit_tests
|
67
setup/xapp-sm-connector/test/hw_unit_tests.cc
Normal file
67
setup/xapp-sm-connector/test/hw_unit_tests.cc
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
/*
|
||||
* hw_unit_tests.cc
|
||||
*
|
||||
* Created on: Mar, 2020
|
||||
* Author: Shraboni Jana
|
||||
*/
|
||||
|
||||
#include<iostream>
|
||||
#include<stdlib.h>
|
||||
#include<gtest/gtest.h>
|
||||
|
||||
#include "test_db.h"
|
||||
#include "test_rmr.h"
|
||||
#include "test_hc.h"
|
||||
#include "test_subs.h"
|
||||
#include "test_e2sm.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char *aux;
|
||||
aux=getenv("RMR_SEED_RT");
|
||||
if (aux==NULL || *aux == '\0'){
|
||||
|
||||
char rmr_seed[80]="RMR_SEED_RT=../init/routes.txt";
|
||||
putenv(rmr_seed);
|
||||
}
|
||||
//get configuration
|
||||
XappSettings config;
|
||||
//change the priority depending upon application requirement
|
||||
config.loadDefaultSettings();
|
||||
config.loadEnvVarSettings();
|
||||
|
||||
//initialize rmr
|
||||
std::unique_ptr<XappRmr> rmr = std::make_unique<XappRmr>("38000");
|
||||
rmr->xapp_rmr_init(true);
|
||||
|
||||
//create a dummy xapp
|
||||
std::unique_ptr<Xapp> dm_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
|
||||
dm_xapp->Run();
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
int res = RUN_ALL_TESTS();
|
||||
|
||||
|
||||
|
||||
return res;
|
||||
}
|
13
setup/xapp-sm-connector/test/routes.txt
Normal file
13
setup/xapp-sm-connector/test/routes.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
newrt|start
|
||||
rte|100|127.0.0.1:4560
|
||||
rte|101|127.0.0.1:38000
|
||||
rte|20010|127.0.0.1:4560
|
||||
rte|20011|127.0.0.1:38000
|
||||
rte|20012|127.0.0.1:4560
|
||||
rte|12010|127.0.0.1:38000
|
||||
rte|12011|127.0.0.1:4560
|
||||
rte|12012|127.0.0.1:4560
|
||||
rte|12020|127.0.0.1:38000
|
||||
rte|12021|127.0.0.1:4560
|
||||
rte|12022|127.0.0.1:4560
|
||||
newrt|end
|
67
setup/xapp-sm-connector/test/test_db.h
Normal file
67
setup/xapp-sm-connector/test/test_db.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
/*
|
||||
* test_rnib.h
|
||||
*
|
||||
* Created on: Mar 23, 2020
|
||||
* Author: Shraboni Jana
|
||||
*/
|
||||
|
||||
#ifndef TEST_TEST_DB_H_
|
||||
#define TEST_TEST_DB_H_
|
||||
|
||||
#include<iostream>
|
||||
#include<gtest/gtest.h>
|
||||
#include "xapp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TEST(Xapp, getGNBlist)
|
||||
{
|
||||
XappSettings config;
|
||||
XappRmr rmr("7001");
|
||||
|
||||
Xapp hw_xapp(std::ref(config),rmr);
|
||||
hw_xapp.set_rnib_gnblist();
|
||||
auto gnblist = hw_xapp.get_rnib_gnblist();
|
||||
int sz = gnblist.size();
|
||||
EXPECT_GE(sz,0);
|
||||
std::cout << "************gnb ids retrieved using R-NIB**************" << std::endl;
|
||||
for(int i = 0; i<sz; i++){
|
||||
std::cout << gnblist[i] << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(Xapp, SDLData){
|
||||
|
||||
//Xapp's SDL namespace.
|
||||
std::string nmspace = "hw-xapp";
|
||||
XappSDL xappsdl(nmspace);
|
||||
|
||||
std::unique_ptr<shareddatalayer::SyncStorage> sdl(shareddatalayer::SyncStorage::create());
|
||||
bool res = xappsdl.set_data(sdl.get());
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
xappsdl.get_data(sdl.get());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* TEST_TEST_DB_H_ */
|
189
setup/xapp-sm-connector/test/test_e2sm.h
Normal file
189
setup/xapp-sm-connector/test/test_e2sm.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
/*
|
||||
* test_asn.h
|
||||
*
|
||||
* Created on: Apr, 2020
|
||||
* Author: Shraboni Jana
|
||||
*/
|
||||
|
||||
#ifndef TEST_TEST_ASN_H_
|
||||
#define TEST_TEST_ASN_H_
|
||||
#include<iostream>
|
||||
#include<gtest/gtest.h>
|
||||
|
||||
#include "subscription_request.hpp"
|
||||
#include "xapp.hpp"
|
||||
#include "e2sm_helpers.hpp"
|
||||
#include "e2sm_subscription.hpp"
|
||||
#include "e2sm_indication.hpp"
|
||||
#include "e2sm_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
TEST(E2SM, SubscriptionRequest)
|
||||
{
|
||||
|
||||
unsigned char event_buf[128];
|
||||
size_t event_buf_len = 128;
|
||||
|
||||
unsigned char act_buf[128];
|
||||
size_t act_buf_len = 128;
|
||||
|
||||
bool res;
|
||||
|
||||
|
||||
e2sm_subscription_helper e2sm_subsdata;
|
||||
std::unique_ptr<ranparam_helper> *ranhelp;
|
||||
e2sm_subscription e2sm_subs;
|
||||
|
||||
|
||||
e2sm_subsdata.triger_nature = 0;
|
||||
|
||||
int param_id = 1;
|
||||
unsigned char param_name[20];
|
||||
strcpy((char*)param_name,"ParamName");
|
||||
int param_name_len = strlen((const char*)param_name);
|
||||
|
||||
int param_test = 0;
|
||||
unsigned char param_value[20];
|
||||
strcpy((char*)param_value,"ParamValue");
|
||||
int param_value_len = strlen((const char*)param_value);
|
||||
|
||||
e2sm_subsdata.add_param(param_id, param_name, param_name_len, param_test, param_value, param_value_len);
|
||||
|
||||
|
||||
// Encode the event trigger definition
|
||||
res = e2sm_subs.encode_event_trigger(&event_buf[0], &event_buf_len, e2sm_subsdata);
|
||||
if(!res)
|
||||
std::cout << e2sm_subs.get_error() << std::endl;
|
||||
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
// Encode the action defintion
|
||||
res = e2sm_subs.encode_action_defn(&act_buf[0], &act_buf_len, e2sm_subsdata);
|
||||
if(!res)
|
||||
std::cout << e2sm_subs.get_error() << std::endl;
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
}
|
||||
TEST(E2SM, IndicationMessage)
|
||||
{
|
||||
|
||||
unsigned char header_buf[128];
|
||||
size_t header_buf_len = 128;
|
||||
|
||||
unsigned char msg_buf[128];
|
||||
size_t msg_buf_len = 128;
|
||||
|
||||
bool res;
|
||||
asn_dec_rval_t retval;
|
||||
|
||||
|
||||
e2sm_indication_helper e2sm_inddata;
|
||||
e2sm_indication e2sm_inds;
|
||||
|
||||
unsigned char msg[20] = "HelloWorld";
|
||||
|
||||
e2sm_inddata.header = 1001;
|
||||
e2sm_inddata.message = msg;
|
||||
e2sm_inddata.message_len = strlen((const char*)e2sm_inddata.message);
|
||||
|
||||
|
||||
// Encode the indication header
|
||||
res = e2sm_inds.encode_indication_header(&header_buf[0], &header_buf_len, e2sm_inddata);
|
||||
if(!res)
|
||||
std::cout << e2sm_inds.get_error() << std::endl;
|
||||
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
// Encode the indication message
|
||||
res = e2sm_inds.encode_indication_message(&msg_buf[0], &msg_buf_len, e2sm_inddata);
|
||||
if(!res)
|
||||
std::cout << e2sm_inds.get_error() << std::endl;
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
//decode the indication header
|
||||
e2sm_indication_helper e2sm_decodedata;
|
||||
|
||||
|
||||
E2SM_HelloWorld_IndicationHeader_t *header = 0; // used for decoding
|
||||
retval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationHeader, (void**)&(header), &header_buf[0], header_buf_len);
|
||||
|
||||
ASSERT_TRUE(retval.code == RC_OK);
|
||||
res = e2sm_inds.get_fields(header, e2sm_decodedata);
|
||||
|
||||
//decode the indication message
|
||||
|
||||
E2SM_HelloWorld_IndicationMessage_t *mesg = 0; // used for decoding
|
||||
retval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationMessage, (void**)&(mesg), &msg_buf[0], msg_buf_len);
|
||||
|
||||
ASSERT_TRUE(retval.code == RC_OK);
|
||||
res = e2sm_inds.get_fields(mesg, e2sm_decodedata);
|
||||
|
||||
|
||||
std::cout << "Indication Header:" << e2sm_decodedata.header << std::endl;
|
||||
std::cout << "Indication Message:" << e2sm_decodedata.message << std::endl;
|
||||
std::cout << "Indication Message Len:" << e2sm_decodedata.message_len << std::endl;
|
||||
|
||||
ASSERT_EQ(e2sm_inddata.header, e2sm_decodedata.header);
|
||||
ASSERT_EQ(e2sm_inddata.message_len, e2sm_decodedata.message_len);
|
||||
for (int i = 0; i < e2sm_inddata.message_len; ++i) {
|
||||
EXPECT_EQ(e2sm_inddata.message[i], e2sm_decodedata.message[i]) << "Encoded and Decoded Msg differ at index " << i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST(E2SM, ControlMessage)
|
||||
{
|
||||
|
||||
unsigned char header_buf[128];
|
||||
size_t header_buf_len = 128;
|
||||
|
||||
unsigned char msg_buf[128];
|
||||
size_t msg_buf_len = 128;
|
||||
|
||||
bool res;
|
||||
asn_dec_rval_t retval;
|
||||
|
||||
|
||||
e2sm_control_helper e2sm_cntrldata;
|
||||
e2sm_control e2sm_cntrl;
|
||||
|
||||
unsigned char msg[20] = "HelloWorld";
|
||||
|
||||
e2sm_cntrldata.header = 1001;
|
||||
e2sm_cntrldata.message = msg;
|
||||
e2sm_cntrldata.message_len = strlen((const char*)e2sm_cntrldata.message);
|
||||
|
||||
|
||||
// Encode the indication header
|
||||
res = e2sm_cntrl.encode_control_header(&header_buf[0], &header_buf_len, e2sm_cntrldata);
|
||||
if(!res)
|
||||
std::cout << e2sm_cntrl.get_error() << std::endl;
|
||||
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
// Encode the indication message
|
||||
res = e2sm_cntrl.encode_control_message(&msg_buf[0], &msg_buf_len, e2sm_cntrldata);
|
||||
if(!res)
|
||||
std::cout << e2sm_cntrl.get_error() << std::endl;
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
|
||||
#endif /* TEST_TEST_ASN_H_ */
|
113
setup/xapp-sm-connector/test/test_hc.h
Normal file
113
setup/xapp-sm-connector/test/test_hc.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
/*
|
||||
* test_a1.h
|
||||
*
|
||||
* Created on: Mar, 2020
|
||||
* Author: Shraboni Jana
|
||||
*/
|
||||
|
||||
#include<iostream>
|
||||
#include<gtest/gtest.h>
|
||||
#include<rapidjson/stringbuffer.h>
|
||||
#include<rapidjson/writer.h>
|
||||
#include<string.h>
|
||||
#include "xapp.hpp"
|
||||
#define HC_MSG_SIZE 512
|
||||
|
||||
|
||||
using namespace std;
|
||||
TEST(Xapp, RMRHealthCheck){
|
||||
|
||||
int total_num_msgs = 2;
|
||||
int num_attempts = 10;
|
||||
|
||||
std::unique_ptr<XappRmr> rmr;
|
||||
rmr = std::make_unique<XappRmr>("4560",num_attempts);
|
||||
rmr->xapp_rmr_init(true);
|
||||
|
||||
XappSettings config;
|
||||
|
||||
std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
|
||||
|
||||
std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp-id");
|
||||
|
||||
hw_xapp->start_xapp_receiver(std::ref(*mp_handler));
|
||||
sleep(5);
|
||||
|
||||
xapp_rmr_header hdr;
|
||||
hdr.message_type = RIC_HEALTH_CHECK_REQ;
|
||||
char strMsg[HC_MSG_SIZE];
|
||||
|
||||
for(int i = 0; i < total_num_msgs; i++){
|
||||
snprintf(strMsg,HC_MSG_SIZE, "HelloWorld: RMR Health Check %d", i);
|
||||
clock_gettime(CLOCK_REALTIME, &(hdr.ts));
|
||||
hdr.payload_length = strlen(strMsg);
|
||||
|
||||
bool res = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
|
||||
usleep(1);
|
||||
}
|
||||
sleep(2);
|
||||
hw_xapp->stop();
|
||||
|
||||
};
|
||||
|
||||
TEST(Xapp, A1HealthCheck){
|
||||
|
||||
//Read the json file and send it using rmr.
|
||||
//string json = "{\"policy_type_id\": \"1\",\"policy_instance_id\":\"3d2157af-6a8f-4a7c-810f-38c2f824bf12\",\"operation\": \"CREATE\"}";
|
||||
string json = "{\"operation\": \"CREATE\", \"policy_type_id\": 1, \"policy_instance_id\": \"hwpolicy321\", \"payload\": {\"threshold\": 5}}";
|
||||
int n = json.length();
|
||||
char strMsg[n + 1];
|
||||
strcpy(strMsg, json.c_str());
|
||||
Document d;
|
||||
d.Parse(strMsg);
|
||||
|
||||
int num_attempts = 5;
|
||||
|
||||
std::unique_ptr<XappRmr> rmr;
|
||||
rmr = std::make_unique<XappRmr>("4560",num_attempts);
|
||||
rmr->xapp_rmr_init(true);
|
||||
|
||||
XappSettings config;
|
||||
|
||||
std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
|
||||
|
||||
std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp-id");
|
||||
|
||||
hw_xapp->start_xapp_receiver(std::ref(*mp_handler));
|
||||
sleep(5);
|
||||
|
||||
xapp_rmr_header hdr;
|
||||
hdr.message_type = A1_POLICY_REQ;
|
||||
clock_gettime(CLOCK_REALTIME, &(hdr.ts));
|
||||
|
||||
|
||||
hdr.payload_length = strlen(strMsg);
|
||||
|
||||
bool res_msg1 = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
|
||||
ASSERT_TRUE(res_msg1);
|
||||
|
||||
usleep(1);
|
||||
|
||||
bool res_msg2 = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
|
||||
ASSERT_TRUE(res_msg2);
|
||||
|
||||
sleep(2);
|
||||
hw_xapp->stop();
|
||||
}
|
107
setup/xapp-sm-connector/test/test_rmr.h
Normal file
107
setup/xapp-sm-connector/test/test_rmr.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
/*
|
||||
* test_rmr_healthcheck.h
|
||||
*
|
||||
* Created on: Mar, 2020
|
||||
* Author: Shraboni Jana
|
||||
*/
|
||||
|
||||
#ifndef TEST_TEST_RMR_H_
|
||||
#define TEST_TEST_RMR_H_
|
||||
#include<iostream>
|
||||
#include<gtest/gtest.h>
|
||||
#include "xapp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TEST(RMR, Sender){
|
||||
|
||||
int total_num_msgs = 2;
|
||||
int num_attempts = 10;
|
||||
|
||||
std::unique_ptr<XappRmr> rmr;
|
||||
rmr = std::make_unique<XappRmr>("4560",num_attempts);
|
||||
rmr->xapp_rmr_init(false);
|
||||
|
||||
xapp_rmr_header hdr;
|
||||
hdr.message_type = RIC_HEALTH_CHECK_REQ;
|
||||
|
||||
for(int i = 0; i < total_num_msgs; i++){
|
||||
std::string temp="HelloWorld: RMR Health Check"+ std::to_string(i);
|
||||
int n = temp.length();
|
||||
char strMsg[n+1];
|
||||
std::strcpy(strMsg,temp.c_str());
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &(hdr.ts));
|
||||
hdr.payload_length = n+1;
|
||||
|
||||
bool res = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
|
||||
ASSERT_TRUE(res);
|
||||
usleep(1);
|
||||
}
|
||||
ASSERT_TRUE(true);
|
||||
}
|
||||
TEST(RMR, Receiver){
|
||||
//initialize rmr
|
||||
std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp-id");
|
||||
XappRmr *rmr = new XappRmr("4560");
|
||||
rmr->xapp_rmr_init(false);
|
||||
sleep(10);
|
||||
|
||||
rmr->xapp_rmr_receive(std::move(*mp_handler), rmr);
|
||||
ASSERT_TRUE(true);
|
||||
};
|
||||
|
||||
TEST(RMR, SendReceiveWithMEID) {
|
||||
XappSettings config;
|
||||
int total_num_msgs = 2;
|
||||
int num_attempts = 10;
|
||||
|
||||
std::unique_ptr<XappRmr> rmr;
|
||||
rmr = std::make_unique<XappRmr>("4560",num_attempts);
|
||||
rmr->xapp_rmr_init(true);
|
||||
|
||||
std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(config,std::ref(*rmr));
|
||||
std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp_ID");
|
||||
hw_xapp->start_xapp_receiver(std::ref(*mp_handler));
|
||||
|
||||
xapp_rmr_header hdr;
|
||||
//can be any message type. using as an example
|
||||
hdr.message_type = RIC_SUB_RESP;
|
||||
memset(hdr.meid,0,32);
|
||||
string meid = "NYC123";
|
||||
strcpy(reinterpret_cast<char*>(hdr.meid), meid.c_str());
|
||||
|
||||
for(int i = 0; i < total_num_msgs; i++){
|
||||
std::string temp="HelloWorld: RMR Health Check"+ std::to_string(i);
|
||||
int n = temp.length();
|
||||
char strMsg[n+1];
|
||||
std::strcpy(strMsg,temp.c_str());
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &(hdr.ts));
|
||||
hdr.payload_length = n+1;
|
||||
|
||||
bool res = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
|
||||
ASSERT_TRUE(res);
|
||||
usleep(1);
|
||||
}
|
||||
sleep(1);
|
||||
hw_xapp->stop();
|
||||
}
|
||||
#endif /* TEST_TEST_RMR_H_ */
|
64
setup/xapp-sm-connector/test/test_subs.h
Normal file
64
setup/xapp-sm-connector/test/test_subs.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
==================================================================================
|
||||
|
||||
Copyright (c) 2019-2020 AT&T Intellectual Property.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================================
|
||||
*/
|
||||
#ifndef TEST_TEST_SUBS_H_
|
||||
#define TEST_TEST_SUBS_H_
|
||||
|
||||
#include<iostream>
|
||||
#include<gtest/gtest.h>
|
||||
#include "xapp.hpp"
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
using namespace std;
|
||||
//generating a E2AP Subscription Message
|
||||
TEST(SUBSCRIPTION, Request){
|
||||
|
||||
|
||||
subscription_helper din;
|
||||
subscription_helper dout;
|
||||
|
||||
subscription_request sub_req;
|
||||
subscription_request sub_recv;
|
||||
|
||||
unsigned char buf[BUFFER_SIZE];
|
||||
size_t buf_size = BUFFER_SIZE;
|
||||
bool res;
|
||||
|
||||
|
||||
//Random Data for request
|
||||
int request_id = 1;
|
||||
int function_id = 0;
|
||||
std::string event_def = "HelloWorld Event Definition";
|
||||
|
||||
din.set_request(request_id);
|
||||
din.set_function_id(function_id);
|
||||
din.set_event_def(event_def.c_str(), event_def.length());
|
||||
|
||||
std::string act_def = "HelloWorld Action Definition";
|
||||
|
||||
din.add_action(1,1,(void*)act_def.c_str(), act_def.length(), 0);
|
||||
|
||||
res = sub_req.encode_e2ap_subscription(&buf[0], &buf_size, din);
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* TEST_TEST_SUBS_H_ */
|
14
setup/xapp-sm-connector/test/xapp_env.sh
Executable file
14
setup/xapp-sm-connector/test/xapp_env.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /bin/bash
|
||||
|
||||
export RMR_SEED_RT="../init/routes.txt"
|
||||
export RMR_RTG_SVC="9999"
|
||||
export MSG_MAX_BUFFER="2072"
|
||||
export THREADS="1"
|
||||
export VERBOSE="0"
|
||||
export CONFIG_FILE="config/config-file.json"
|
||||
export XAPP_ID="3489-er492k-92389"
|
||||
export LOG_LEVEL="MDCLOG_ERR"
|
||||
export DBAAS_SERVICE_HOST="127.0.0.1"
|
||||
export DBAAS_SERVICE_PORT="6379"
|
||||
|
||||
|
Reference in New Issue
Block a user