5 # Run specified app using LD_PRELOAD to fetch a page from
6 # nginx running in vpp1 net-namespace.
8 # Specify the following environment variables:
10 # STRACE_ONLY - Run app with strace instead of LD_PRELOAD.
11 # TEST_APP - App to run (default: curl)
14 # Configuration variables.
16 vpp_dk_name="VPP-TEST-NGINX"
17 # Comment out the next line to run the VPP release version
19 vpp_app="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/bin/vpp"
22 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
23 running_vpp="$(eval $grep_for_vpp)"
27 if [ -z "$WS_ROOT" ] ; then
28 echo "ERROR: WS_ROOT environment variable not set!" >&2
29 echo " Please set WS_ROOT to VPP workspace root directory." >&2
32 if [ -z "$LDP_DIR" ] ; then
33 echo "WARNING: LDP_DIR environment variable is not set!"
34 echo " Sourcing $WS_ROOT/extras/vcl-ldpreload/env.sh"
35 source $WS_ROOT/extras/vcl-ldpreload/env.sh
38 TEST_APP="${TEST_APP:-curl}"
39 LDP_TEST_DIR="${LDP_TEST_DIR:-${LDP_DIR}/test}"
40 LDP_LIB="${LDP_LIB:-${VCL_LDPRELOAD_LIB_DIR}/libvcl_ldpreload.so.0.0.0}"
42 if [ ! -f "$LDP_LIB" ] ; then
43 echo "ERROR: Missing VCL-LDPRELOAD Library: $LDP_LIB"
44 echo " See $LDP_DIR/README.md for build instructions!"
48 if [ -z "$(docker ps -qf name=$vpp_dk_name)" ] ; then
49 echo "Starting NGINX in docker container ($vpp_dk_name)"
50 docker run --rm --name $vpp_dk_name -v $LDP_TEST_DIR/common/nginx_welcome.html:/usr/share/nginx/html/index.html:ro -d nginx
52 echo "Configuring network interfaces"
53 sudo ip link del dev vpp_dk
54 sudo ip link add name vpp_dk type veth peer name vpp1
55 sudo ip link set dev vpp_dk up
56 sudo ip link set dev vpp1 up
57 sudo ip link set dev lo up
58 sudo brctl addif docker0 vpp_dk
61 export LD_LIBRARY_PATH="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/lib64/:$LDP_DIR/src/.libs:"
63 # Extract nginx IPv4 address from docker bridge
65 nginx_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '{print $2}' | sed -e 's,/16,,' -e 's,",,g' -e 's/,//')
67 if [ -z "$nginx_addr" ] ; then
68 echo "ERROR: Unable to determine docker container address!"
72 if [ -n "$STRACE_ONLY" ] ; then
73 echo "Running strace -tt $TEST_APP http://$nginx_addr"
74 strace -tt $TEST_APP http://$nginx_addr
77 if [ -z "$running_vpp" ] ; then
78 echo "Starting VPP ('telnet 0 5002' to connect to cli)"
79 sudo $vpp_app unix { cli-listen localhost:5002 exec $LDP_TEST_DIR/common/vpp_docker.conf } api-segment { gid $(id -g) }
82 echo "Running LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr"
83 LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr