From: sjana Date: Mon, 13 Apr 2020 14:53:34 +0000 (-0400) Subject: Adding Dockerfile to the repo X-Git-Tag: 1.0.0~9 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=60af3c9e625d903c1659c703bd1e41167a972c59;p=ric-app%2Fhw.git Adding Dockerfile to the repo Issue-ID: RICAPP-30 Signed-off-by: sjana Change-Id: I04ad0c7d50cc665ea92108493217466f8f6fbe6d --- diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..fbc58bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,173 @@ +#/* +#================================================================================== +# Copyright (c) 2018-2019 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. +#================================================================================== +#*/ +ARG SCHEMA_PATH=schemas +ARG STAGE_DIR=/tmp/helloworld-xapp + +#================================================================================== +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go@sha256:f4ebcc792b501f283c7848018b6f106bbcecf1f9e699035950614460b3c330f8 as ricbuild + +# to override repo base, pass in repo argument when running docker build: +# docker build --build-arg REPOBASE=http://abc.def.org . .... +ARG REPOBASE=https://gerrit.oran-osc.org/r +ARG SCHEMA_FILE +ARG SCHEMA_PATH +ARG STAGE_DIR + +# Install necessary packages +WORKDIR ${STAGE_DIR} +RUN apt-get update \ + && apt-get install -y \ + libcurl4-openssl-dev \ + libcurl3 \ + cmake \ + git \ + build-essential \ + automake \ + autoconf-archive \ + autoconf \ + pkg-config \ + gawk \ + libtool \ + wget \ + zlib1g-dev \ + libffi-dev \ + && apt-get clean + +# Install mdclog using debian package hosted at packagecloud.io +ARG MDC_VER=0.0.4-1 +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog_${MDC_VER}_amd64.deb/download.deb +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog-dev_${MDC_VER}_amd64.deb/download.deb +RUN dpkg -i mdclog_${MDC_VER}_amd64.deb +RUN dpkg -i mdclog-dev_${MDC_VER}_amd64.deb + +# Install RMr using debian package hosted at packagecloud.io +ARG RMR_VER=3.6.5 +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMR_VER}_amd64.deb/download.deb +RUN dpkg -i rmr_${RMR_VER}_amd64.deb +RUN dpkg -i rmr-dev_${RMR_VER}_amd64.deb + +## Install SDL Libraries +WORKDIR ${STAGE_DIR} +RUN apt-get install -y cpputest +RUN apt-get remove -y libboost-all-dev +RUN apt-get install -y libboost-all-dev +RUN apt-get install -y libhiredis-dev +RUN apt-get install -y valgrind + +RUN git config --global http.proxy http://one.proxy.att.com:8080 +RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/dbaas +RUN cd dbaas/redismodule && \ + ./autogen.sh && \ + ./configure && \ + make all && \ +# make test && \ + make install + +WORKDIR ${STAGE_DIR} +RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/sdl +RUN cd sdl && \ + ./autogen.sh && \ + ./configure && \ + make all && \ +# make test && \ + make install + +RUN git config --global --unset http.proxy + +WORKDIR ${STAGE_DIR} +## Install rapidjson + #git checkout tags/v1.1.0 && \ + +RUN git clone https://github.com/Tencent/rapidjson && \ + cd rapidjson && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + make install && \ + cd ${STAGE_DIR} && \ + rm -rf rapidjson + +### Copy RNIB library and include rnib. +RUN mkdir /usr/local/include/rnib + +##----------------------------------- +# Now install the program +#------------------------------------ +COPY ./ ${STAGE_DIR} +RUN ls -al +COPY ${STAGE}/rnib/*.h /usr/local/include/rnib/ +COPY ${STAGE}/rnibreader_old.a /usr/local/lib/ + +RUN export CPATH=$CPATH:/usr/local/include && \ + cd src && \ + make clean && \ + make install + +COPY ${SCHEMA_PATH}/* /etc/xapp/ +COPY init/init_script.py /etc/xapp/init_script.py + +#--------------------------------------------- +# #Build the final version + +FROM ubuntu:16.04 + +ARG SCHEMA_PATH +ARG STAGE_DIR + +## copy just the needed libraries install it into the final image +COPY --from=ricbuild ${STAGE_DIR}/*.deb /tmp/ +#COPY --from=ricbuild /usr/local/libexec/. /usr/local/libexec/. +COPY --from=ricbuild /usr/local/lib/librmr_si* /usr/local/lib/ +COPY --from=ricbuild /usr/local/lib/libsdl* /usr/local/lib/ +COPY --from=ricbuild /usr/local/libexec/redismodule/libredis* /usr/local/libexec/redismodule/ +RUN dpkg -i /tmp/*.deb +RUN apt-get update && \ + apt-get install -y libcurl3 python3 && \ + apt-get install -y libboost-all-dev cpputest libhiredis-dev valgrind && \ + apt-get clean +COPY --from=ricbuild /etc/xapp/* /etc/xapp/ +COPY --from=ricbuild /usr/local/bin/hw_xapp_main /usr/local/bin/hw_xapp_main +COPY --from=ricbuild ${STAGE_DIR}/rnib/*.h /usr/local/include/rnib/ +COPY --from=ricbuild ${STAGE_DIR}/rnibreader_old.a /usr/local/lib/ + +##COPY --from=ricbuild /usr/local/bin/e2e-test-client /usr/local/bin/e2e-test-client +##COPY --from=ricbuild /usr/local/bin/mock-e2term-server /usr/local/bin/mock-e2term-server +##COPY --from=ricbuild /usr/local/bin/e2e-perf-client /usr/local/bin/e2e-perf-client +##COPY --from=ricbuild /usr/local/bin/e2e-perf-server /usr/local/bin/e2e-perf-server +##COPY --from=ricbuild /usr/local/bin/mock-a1-server /usr/local/bin/mock-a1-server + + +RUN ldconfig +RUN sysctl -w net.ipv6.conf.lo.disable_ipv6=1 + +##ENV PYTHONHOME=/opt/python3 \ +## PYTHONPATH=/opt/python3 \ +ENV RMR_RTG_SVC="9999" \ + LD_LIBRARY_PATH="/usr/local/lib:/usr/local/libexec" \ + NAME=ADM_CTRL_XAPP \ + PORT=tcp:4560 \ + THREADS=1\ + VERBOSE=0 \ + MESSAGE_TYPE=10002 \ + RATE=1 \ + CONFIG_FILE=/opt/ric/config/config-file.json + + + +CMD python3 /etc/xapp/init_script.py $CONFIG_FILE diff --git a/Dockerfile-Unit-Tests b/Dockerfile-Unit-Tests new file mode 100755 index 0000000..60efaca --- /dev/null +++ b/Dockerfile-Unit-Tests @@ -0,0 +1,186 @@ +#/* +#================================================================================== +# Copyright (c) 2018-2019 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. +#================================================================================== +#*/ +ARG SCHEMA_PATH=schemas +ARG STAGE_DIR=/tmp/helloworld-xapp + +#================================================================================== +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go@sha256:f4ebcc792b501f283c7848018b6f106bbcecf1f9e699035950614460b3c330f8 as ricbuild + +# to override repo base, pass in repo argument when running docker build: +# docker build --build-arg REPOBASE=http://abc.def.org . .... +ARG REPOBASE=https://gerrit.oran-osc.org/r +ARG SCHEMA_FILE +ARG SCHEMA_PATH +ARG STAGE_DIR + +# Install necessary packages +WORKDIR ${STAGE_DIR} +RUN apt-get update \ + && apt-get install -y \ + libcurl4-openssl-dev \ + libcurl3 \ + cmake \ + git \ + build-essential \ + automake \ + autoconf-archive \ + autoconf \ + pkg-config \ + gawk \ + libtool \ + wget \ + zlib1g-dev \ + libffi-dev \ + && apt-get clean + +# Install mdclog using debian package hosted at packagecloud.io +ARG MDC_VER=0.0.4-1 +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog_${MDC_VER}_amd64.deb/download.deb +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog-dev_${MDC_VER}_amd64.deb/download.deb +RUN dpkg -i mdclog_${MDC_VER}_amd64.deb +RUN dpkg -i mdclog-dev_${MDC_VER}_amd64.deb + +# Install RMr using debian package hosted at packagecloud.io +ARG RMR_VER=3.6.2 +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb +RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMR_VER}_amd64.deb/download.deb +RUN dpkg -i rmr_${RMR_VER}_amd64.deb +RUN dpkg -i rmr-dev_${RMR_VER}_amd64.deb + +##Iinstall Google test + +WORKDIR ${STAGE_DIR} +RUN apt-get install libgtest-dev +RUN cd /usr/src/gtest \ + && cmake CMakeLists.txt \ + && make \ + && cp *.a /usr/local/lib + + +## Install SDL Libraries +WORKDIR ${STAGE_DIR} +RUN apt-get install -y cpputest +RUN apt-get remove -y libboost-all-dev +RUN apt-get install -y libboost-all-dev +RUN apt-get install -y libhiredis-dev +RUN apt-get install -y valgrind + +RUN git config --global http.proxy http://one.proxy.att.com:8080 +RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/dbaas +RUN cd dbaas/redismodule && \ + ./autogen.sh && \ + ./configure && \ + make all && \ +## make test && \ + make install + +WORKDIR ${STAGE_DIR} +RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/sdl +RUN cd sdl && \ + ./autogen.sh && \ + ./configure && \ + make all && \ +# make test && \ + make install + +RUN git config --global --unset http.proxy + +WORKDIR ${STAGE_DIR} +## Install rapidjson + #git checkout tags/v1.1.0 && \ + +RUN git clone https://github.com/Tencent/rapidjson && \ + cd rapidjson && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + make install && \ + cd ${STAGE_DIR} && \ + rm -rf rapidjson + +### Copy RNIB library and include rnib. +RUN mkdir /usr/local/include/rnib + +##----------------------------------- +# Now install the program +#------------------------------------ +COPY ./ ${STAGE_DIR} +RUN ls -al +COPY ${STAGE}/rnib/*.h /usr/local/include/rnib/ +COPY ${STAGE}/rnibreader_old.a /usr/local/lib/ + +RUN export CPATH=$CPATH:/usr/local/include && \ + cd test && \ + make clean && \ + make install + +COPY ${SCHEMA_PATH}/* /etc/xapp/ +COPY init/init_script.py /etc/xapp/init_script.py + + +#--------------------------------------------- +# #Build the final version +##FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go:1-u16.04-nng1.1.1 + +FROM ubuntu:16.04 + +ARG SCHEMA_PATH +ARG STAGE_DIR + +## copy just the needed libraries install it into the final image +COPY --from=ricbuild ${STAGE_DIR}/*.deb /tmp/ +#COPY --from=ricbuild /usr/local/libexec/. /usr/local/libexec/. +COPY --from=ricbuild /usr/local/lib/librmr_si* /usr/local/lib/ +COPY --from=ricbuild /usr/local/lib/libgtest* /usr/local/lib/ +COPY --from=ricbuild /usr/local/lib/libsdl* /usr/local/lib/ +COPY --from=ricbuild /usr/local/libexec/redismodule/libredis* /usr/local/libexec/redismodule/ +RUN dpkg -i /tmp/*.deb +RUN apt-get update && \ + apt-get install -y libcurl3 python3 && \ + apt-get install -y libboost-all-dev cpputest libhiredis-dev valgrind && \ + apt-get clean +COPY --from=ricbuild /etc/xapp/* /etc/xapp/ +COPY --from=ricbuild /usr/local/bin/hw_unit_tests /usr/local/bin/hw_unit_tests +COPY --from=ricbuild ${STAGE_DIR}/rnib/*.h /usr/local/include/rnib/ +COPY --from=ricbuild ${STAGE_DIR}/rnibreader_old.a /usr/local/lib/ + +##COPY --from=ricbuild /usr/local/bin/e2e-test-client /usr/local/bin/e2e-test-client +##COPY --from=ricbuild /usr/local/bin/mock-e2term-server /usr/local/bin/mock-e2term-server +##COPY --from=ricbuild /usr/local/bin/e2e-perf-client /usr/local/bin/e2e-perf-client +##COPY --from=ricbuild /usr/local/bin/e2e-perf-server /usr/local/bin/e2e-perf-server +##COPY --from=ricbuild /usr/local/bin/mock-a1-server /usr/local/bin/mock-a1-server + + +RUN ldconfig + + +##ENV PYTHONHOME=/opt/python3 \ +## PYTHONPATH=/opt/python3 \ +ENV RMR_RTG_SVC="9999" \ + LD_LIBRARY_PATH="/usr/local/lib:/usr/local/libexec" \ + NAME=ADM_CTRL_XAPP \ + PORT=tcp:4560 \ + THREADS=1\ + VERBOSE=0 \ + MESSAGE_TYPE=10002 \ + RATE=1 \ + CONFIG_FILE=/opt/ric/config/config-file.json \ + EXE_FILE=/usr/local/bin/hw_unit_tests + + +CMD python3 /etc/xapp/init_script.py $CONFIG_FILE $EXE_FILE diff --git a/init/config-file.json b/init/config-file.json index 72c7926..a3ca2e7 100644 --- a/init/config-file.json +++ b/init/config-file.json @@ -8,15 +8,15 @@ "protPort": "tcp:4560", "maxSize": 2072, "numWorkers": 1, - "txMessages": ["RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ", "A1_POLICY_RESP", "A1_POLICY_QUERY"], - "rxMessages": ["RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION", "RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE", "A1_POLICY_REQ"], + "txMessages": ["RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ", "A1_POLICY_RESP", "A1_POLICY_QUERY","RIC_HEALTH_CHECK_RESP"], + "rxMessages": ["RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION", "RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE","RIC_HEALTH_CHECK_REQ", "A1_POLICY_REQ"], "policies": ["1","00000"], "file_path":"/tmp/routeinfo/routes.txt", - "contents": "newrt|start\nrte|0|localhost:4560\nrte|2|localhost:38000\nrte|10002|localhost:4560\nrte|10005|localhost:4560\nrte|10003|localhost:38000\nrte|12010|localhost:38000\nrte|12020|localhost:38000\nrte|12011|localhost:4560\nrte|12012|localhost:4560\nrte|12021|localhost:4560\nrte|12022|localhost:4560\nrte|20000|localhost:4560\nrte|12040|localhost:38000\nrte|20001|localhost:4566\nrte|20011|localhost:4560\nrte|20012|localhost:4560\nnewrt|end" + "contents": "newrt|start\nrte|0|127.0.0.1:4560\nrte|100|127.0.0.1:4560\nrte|2|127.0.0.1:38000\nrte|10002|127.0.0.1:4560\nrte|10005|127.0.0.1:4560\nrte|10003|127.0.0.1:38000\nrte|12010|127.0.0.1:38000\nrte|12020|127.0.0.1:38000\nrte|12011|127.0.0.1:4560\nrte|12012|127.0.0.1:4560\nrte|12021|127.0.0.1:4560\nrte|12022|127.0.0.1:4560\nrte|20000|127.0.0.1:4560\nrte|12040|127.0.0.1:38000\nrte|20001|127.0.0.1:4566\nrte|20010|127.0.0.1:4560\nrte|20012|127.0.0.1:4560\nnewrt|end" }, "envs":{ - "RMR_SEED_RT":"../src/routes.txt", + "RMR_SEED_RT":"/tmp/routeinfo/routes.txt", "RMR_RTG_SVC":"9999", "DBAAS_SERVICE_HOST":"127.0.0.1", "DBAAS_SERVICE_PORT":"6379", diff --git a/init/init_script.py b/init/init_script.py index b88ca35..c6c1421 100644 --- a/init/init_script.py +++ b/init/init_script.py @@ -133,14 +133,15 @@ xapp_port = 0; ParseSection["rmr"] = getRMRTable; ParseSection["envs"] = getEnvs; -default_routing_file = "../src/routes.txt"; +default_routing_file = "/tmp/routeinfo/routes.txt"; #================================================================ if __name__ == "__main__": import subprocess; - cmd = ["../src/hw_xapp_main"]; +# cmd = ["../src/hw_xapp_main"]; + cmd = ["/usr/local/bin/hw_xapp_main"]; if xapp_port > 0: cmd.append("-p"); cmd.append(xapp_port); diff --git a/src/.routes.txt.swp b/src/.routes.txt.swp new file mode 100644 index 0000000..e36a7e7 Binary files /dev/null and b/src/.routes.txt.swp differ diff --git a/src/Makefile b/src/Makefile index eb52483..62bac72 100755 --- a/src/Makefile +++ b/src/Makefile @@ -32,7 +32,7 @@ E2SMFLAGS = -I$(E2SMSRC) ########libs -LIBS= -lsdl -lrmr_nng -lnng -lpthread -lm $(LOG_LIBS) $(CURL_LIBS) $(RNIB_LIBS) +LIBS= -lsdl -lrmr_si -lpthread -lm $(LOG_LIBS) $(CURL_LIBS) $(RNIB_LIBS) COV_FLAGS= -fprofile-arcs -ftest-coverage ####### diff --git a/src/xapp.cc b/src/xapp.cc index 54b75fd..c9cd5da 100644 --- a/src/xapp.cc +++ b/src/xapp.cc @@ -157,6 +157,9 @@ void Xapp::set_rnib_gnblist(void) { const Value& gnblist = doc["gnb_list"]; + if (gnblist.IsNull()) + return; + assert(gnblist.IsArray()); for (SizeType i = 0; i < gnblist.Size(); i++) // Uses SizeType instead of size_t diff --git a/test/Makefile b/test/Makefile index 10089f7..0fd285f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -32,7 +32,7 @@ E2SMFLAGS = -I$(E2SMSRC) ########libs -LIBS= -lsdl -lrmr_nng -lnng -lpthread -lm $(LOG_LIBS) $(CURL_LIBS) $(RNIB_LIBS) $(GTEST_LIBS) +LIBS= -lsdl -lrmr_si -lpthread -lm $(LOG_LIBS) $(CURL_LIBS) $(RNIB_LIBS) $(GTEST_LIBS) COV_FLAGS= -fprofile-arcs -ftest-coverage ####### @@ -76,7 +76,7 @@ print-% : ; @echo $* = $($*) hw_unit_tests: $(OBJ) $(CXX) -o $@ $(OBJ) $(LIBS) $(RNIBFLAGS) $(CPPFLAGS) $(CLOGFLAGS) -install: test_rnib +install: hw_unit_tests install -D hw_unit_tests /usr/local/bin/hw_unit_tests clean: diff --git a/test/hw_unit_tests.cc b/test/hw_unit_tests.cc index a1bd3ca..d6c9339 100644 --- a/test/hw_unit_tests.cc +++ b/test/hw_unit_tests.cc @@ -37,7 +37,8 @@ using namespace std; int main(int argc, char* argv[]) { - char rmr_seed[80]="RMR_SEED_RT=../src/routes.txt"; +// char rmr_seed[80]="RMR_SEED_RT=../src/routes.txt"; + char rmr_seed[80]="/tmp/routeinfo/routes.txt"; putenv(rmr_seed); testing::InitGoogleTest(&argc, argv); diff --git a/test/test_rnib.h b/test/test_rnib.h deleted file mode 100644 index 67d1094..0000000 --- a/test/test_rnib.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -================================================================================== - - Copyright (c) 2018-2019 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_RNIB_H_ -#define TEST_TEST_RNIB_H_ - -#include -#include -#include "xapp.hpp" - -using namespace std; - -TEST(Xapp, getGNBlist) -{ - XappSettings config; - XappRmr rmr("4560"); - - Xapp hw_xapp(std::ref(config),std::ref(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 -#include -#include "xapp_sdl.hpp" - -using namespace std; - -TEST(Xapp, SDLData){ - - //Xapp's SDL namespace. - std::string nmspace = "hw-xapp"; - XappSDL xappsdl(nmspace); - - std::unique_ptr sdl(shareddatalayer::SyncStorage::create()); - bool res = xappsdl.set_data(sdl.get()); - ASSERT_TRUE(res); - - xappsdl.get_data(sdl.get()); - -} - - -#endif /* TEST_TEST_SDL_H_ */