2 # Copyright (c) 2016-2017 Intel Corporation
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.
17 # Change to yardstick directory ( <current-dir>/.. ), and export it as REPO_DIR
19 cd "$(dirname "${BASH_SOURCE[0]}")"
21 echo "------------------------------------------------------------------------------"
22 echo " REPO_DIR exported as $REPO_DIR"
23 echo "------------------------------------------------------------------------------"
25 if [ "$(whoami)" != "root" ]; then
26 echo "Must be root to run $0"
30 INSTALL_BIN_PATH="/opt/nsb_bin"
32 TREX_DOWNLOAD="https://trex-tgn.cisco.com/trex/release/$TREX_VERSION.tar.gz"
33 DPDK_DOWNLOAD="http://dpdk.org/browse/dpdk/snapshot/dpdk-16.07.zip"
34 VIRTUAL_VENV="$INSTALL_BIN_PATH/yardstick_venv"
37 # Install libs needed for NSB
41 echo "Install libs needed to build and run NSB Testing..."
42 apt-get update > /dev/null 2>&1
43 pkg=(git build-essential python-dev virtualenv python-virtualenv virtualenv linux-headers-$(uname -r) unzip python-pip libpcap-dev cmake)
44 for i in "${pkg[@]}"; do
45 dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
46 if [ "$?" -eq "1" ]; then
47 apt-get -y install "${i}";
55 echo "Create install directory... $INSTALL_BIN_PATH"
56 mkdir -p $INSTALL_BIN_PATH
57 echo "Install yardstick dependencies and build Yardstick in venv..."
61 virtualenv $VIRTUAL_VENV
62 if [ ! -f "$INSTALL_BIN_PATH/yardstick_venv/bin/activate" ]; then
63 echo "Installation Error. Failed to create yardstick virtual env..."
66 source $VIRTUAL_VENV/bin/activate
68 python setup.py install
72 echo "Copying yardstick sample conf & pod file to /etc/yardstick/nodes"
73 mkdir -p /etc/yardstick/nodes
74 cp "$REPO_DIR/etc/yardstick/yardstick.conf.sample" "/etc/yardstick/yardstick.conf"
75 cp "$REPO_DIR/etc/yardstick/nodes/pod.yaml.nsb.sample" "/etc/yardstick/nodes/"
80 # Install trex for TH setup
84 TREX_DIR=$INSTALL_BIN_PATH/trex/scripts
85 if [ -d "$TREX_DIR" ]; then
86 echo "Trex $TREX_VERSION already installed."
88 echo "Build TRex and installing Trex TG in $INSTALL_BIN_PATH/trex"
89 rm -rf ${TREX_DOWNLOAD##*/}
90 if [ ! -e ${TREX_DOWNLOAD##*/} ] ; then
93 tar zxvf ${TREX_DOWNLOAD##*/}
97 mv $TREX_VERSION trex/scripts
98 rm -rf $TREX_VERSION.tar.gz
99 cd trex/scripts/ko/src/
102 ln -s $TREX_DIR/automation/trex_control_plane $INSTALL_BIN_PATH/trex_client
110 if [ -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
111 echo "DPDK already installed make sure.. igb_uio is loaded."
113 echo "Build DPDK 16.07..."
115 rm -rf ${DPDK_DOWNLOAD##*/}
116 rm -rf "$REPO_DIR/dpdk-16.07/"
117 if [ ! -e ${DPDK_DOWNLOAD##*/} ] ; then
118 wget ${DPDK_DOWNLOAD}
120 unzip -o ${DPDK_DOWNLOAD##*/}
123 make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc
124 cd x86_64-native-linuxapp-gcc
125 echo "Enable Port Stats..."
126 sed -i -e 's/CONFIG_RTE_PORT_STATS_COLLECT=n/CONFIG_RTE_PORT_STATS_COLLECT=y/g' .config
127 sed -i -e 's/CONFIG_RTE_PORT_PCAP=n/CONFIG_RTE_PORT_PCAP=y/g' .config
128 sed -i -e 's/CONFIG_RTE_TABLE_STATS_COLLECT=n/CONFIG_RTE_TABLE_STATS_COLLECT=y/g' .config
129 sed -i -e 's/CONFIG_RTE_PIPELINE_STATS_COLLECT=n/CONFIG_RTE_PIPELINE_STATS_COLLECT=y/g' .config
132 echo "Load DPDK modules and setup hugepages"
134 mkdir -p "/lib/modules/$(uname -r)/extra"
135 cp -r "kmod/igb_uio.ko" "/lib/modules/$(uname -r)/extra"
138 sh -c "echo 'uio\nigb_uio\n' > /etc/modules-load.d/nsb.conf"
140 HUGEPGSZ=$(cat < /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' ')
142 if [[ "$HUGEPGSZ" = "2048kB" ]] ; then
145 grep nr_hugepages /etc/sysctl.conf
146 if [[ "$?" -eq '1' ]] ; then
147 sh -c "echo 'vm.nr_hugepages=$Pages' >> /etc/sysctl.conf"
149 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" > .echo_tmp
150 echo "Reserving hugepages"
155 echo "Creating /mnt/huge and mounting as hugetlbfs"
156 sudo mkdir -p /mnt/huge
158 grep -s '/mnt/huge' /proc/mounts > /dev/null
159 if [ $? -ne 0 ] ; then
160 sudo mount -t hugetlbfs nodev /mnt/huge
163 mv "$REPO_DIR/dpdk-16.07" "$INSTALL_BIN_PATH"
166 export RTE_SDK="$INSTALL_BIN_PATH/dpdk-16.07"
167 export RTE_TARGET=x86_64-native-linuxapp-gcc
169 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
171 echo "Building vPE VNF..."
172 cd $INSTALL_BIN_PATH/dpdk-16.07/examples/ip_pipeline/
175 cp build/ip_pipeline $INSTALL_BIN_PATH/vPE_vnf
184 if [ ! -d "$INSTALL_BIN_PATH/trex/scripts" ]; then
185 cp -fr "$REPO_DIR/trex" "$INSTALL_BIN_PATH"
187 rm -rf "$REPO_DIR/trex"
189 if [ -d "$INSTALL_BIN_PATH/trex" ]; then
190 echo "Setup Environment variables for Test Harness...."
191 PYTHONPATH="$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane:$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane/stl"
192 PY_PATH=$(grep PYTHONPATH ~/.bash_profile)
193 if [ "$PY_PATH" = "" ] ; then
194 sh -c "echo export PYTHONPATH=$PYTHONPATH >> ~/.bash_profile" > /dev/null
196 echo "Your ~/.bash_profile already contains a PYTHONPATH definition."
197 echo "Make sure it contains $PYTHONPATH which is required to run TRex"
200 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.sh" "$INSTALL_BIN_PATH"
201 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.conf" "$INSTALL_BIN_PATH"
202 cp "$REPO_DIR/nsb_setup.sh" "$INSTALL_BIN_PATH"
204 # Get "dpdk-devbind.py" to find the ports for VNF to run
205 wget http://dpdk.org/browse/dpdk/plain/usertools/dpdk-devbind.py?h=v17.05 -O dpdk-devbind.py
206 chmod 777 dpdk-devbind.py
207 mv dpdk-devbind.py "$INSTALL_BIN_PATH"
208 ln "$INSTALL_BIN_PATH"/dpdk-devbind.py "$INSTALL_BIN_PATH"/dpdk_nic_bind.py
212 check_installed_files()
214 if [ ! -f "$INSTALL_BIN_PATH/yardstick_venv/bin/activate" ]; then
215 echo "Installation Error. Failed to create yardstick virtual env..."
219 if [ ! -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
220 echo "Installation Error. Failed to download and install dpdk-16.07..."
224 if [ ! -d "$INSTALL_BIN_PATH/trex" ]; then
225 echo "Installation Error. Failed to download and configure Trex"
229 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
230 echo "Installation Error. vPE VNF not present in install dir $INSTALL_BIN_PATH"
235 if [ "$1" == "dpdk" ]; then
244 check_installed_files
246 echo "Installation completed..."
247 echo "Virtual Environment : $INSTALL_BIN_PATH/yardstick_venv"
248 echo "Please refer to Chapter 13 of the Yardstick User Guide for how to get started with VNF testing."