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 v2.20 already installed. Make sure it contains PYTHONPATH which is required to run TRex"
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 # workaround trex module issue
103 touch "$REPO_DIR/trex/scripts/automation/trex_control_plane/stl/__init__.py"
104 cp "$REPO_DIR/trex/scripts/dpdk_nic_bind.py" "$INSTALL_BIN_PATH"
112 if [ -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
113 echo "DPDK already installed make sure.. igb_uio is loaded."
115 echo "Build DPDK 16.07..."
117 rm -rf ${DPDK_DOWNLOAD##*/}
118 rm -rf "$REPO_DIR/dpdk-16.07/"
119 if [ ! -e ${DPDK_DOWNLOAD##*/} ] ; then
120 wget ${DPDK_DOWNLOAD}
122 unzip -o ${DPDK_DOWNLOAD##*/}
125 make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc
126 cd x86_64-native-linuxapp-gcc
127 echo "Enable Port Stats..."
128 sed -i -e 's/CONFIG_RTE_PORT_STATS_COLLECT=n/CONFIG_RTE_PORT_STATS_COLLECT=y/g' .config
129 sed -i -e 's/CONFIG_RTE_PORT_PCAP=n/CONFIG_RTE_PORT_PCAP=y/g' .config
130 sed -i -e 's/CONFIG_RTE_TABLE_STATS_COLLECT=n/CONFIG_RTE_TABLE_STATS_COLLECT=y/g' .config
131 sed -i -e 's/CONFIG_RTE_PIPELINE_STATS_COLLECT=n/CONFIG_RTE_PIPELINE_STATS_COLLECT=y/g' .config
134 echo "Load DPDK modules and setup hugepages"
136 mkdir -p "/lib/modules/$(uname -r)/extra"
137 cp -r "kmod/igb_uio.ko" "/lib/modules/$(uname -r)/extra"
140 sh -c "echo 'uio\nigb_uio\n' > /etc/modules-load.d/nsb.conf"
142 HUGEPGSZ=$(cat < /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' ')
144 if [[ "$HUGEPGSZ" = "2048kB" ]] ; then
147 grep nr_hugepages /etc/sysctl.conf
148 if [[ "$?" -eq '1' ]] ; then
149 sh -c "echo 'vm.nr_hugepages=$Pages' >> /etc/sysctl.conf"
151 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" > .echo_tmp
152 echo "Reserving hugepages"
157 echo "Creating /mnt/huge and mounting as hugetlbfs"
158 sudo mkdir -p /mnt/huge
160 grep -s '/mnt/huge' /proc/mounts > /dev/null
161 if [ $? -ne 0 ] ; then
162 sudo mount -t hugetlbfs nodev /mnt/huge
165 mv "$REPO_DIR/dpdk-16.07" "$INSTALL_BIN_PATH"
168 export RTE_SDK="$INSTALL_BIN_PATH/dpdk-16.07"
169 export RTE_TARGET=x86_64-native-linuxapp-gcc
171 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
173 echo "Building vPE VNF..."
174 cd $INSTALL_BIN_PATH/dpdk-16.07/examples/ip_pipeline/
177 cp build/ip_pipeline $INSTALL_BIN_PATH/vPE_vnf
186 if [ ! -d "$INSTALL_BIN_PATH/trex/scripts" ]; then
187 cp -fr "$REPO_DIR/trex" "$INSTALL_BIN_PATH"
189 rm -rf "$REPO_DIR/trex"
191 if [ -d "$INSTALL_BIN_PATH/trex" ]; then
192 echo "Setup Environment variables for Test Harness...."
193 PYTHONPATH="$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane:$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane/stl"
194 PY_PATH=$(grep PYTHONPATH ~/.bash_profile)
195 if [ "$PY_PATH" = "" ] ; then
196 sh -c "echo export PYTHONPATH=$PYTHONPATH >> ~/.bash_profile" > /dev/null
198 echo "Your ~/.bash_profile already contains a PYTHONPATH definition."
199 echo "Make sure it contains $PYTHONPATH which is required to run TRex"
202 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.sh" "$INSTALL_BIN_PATH"
203 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.conf" "$INSTALL_BIN_PATH"
204 cp "$REPO_DIR/nsb_setup.sh" "$INSTALL_BIN_PATH"
208 check_installed_files()
210 if [ ! -f "$INSTALL_BIN_PATH/yardstick_venv/bin/activate" ]; then
211 echo "Installation Error. Failed to create yardstick virtual env..."
215 if [ ! -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
216 echo "Installation Error. Failed to download and install dpdk-16.07..."
220 if [ ! -d "$INSTALL_BIN_PATH/trex" ]; then
221 echo "Installation Error. Failed to download and configure Trex"
225 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
226 echo "Installation Error. vPE VNF not present in install dir $INSTALL_BIN_PATH"
231 if [ "$1" == "dpdk" ]; then
240 check_installed_files
242 echo "Installation completed..."
243 echo "Virtual Environment : $INSTALL_BIN_PATH/yardstick_venv"
244 echo "Please refer to Chapter 13 of the Yardstick User Guide for how to get started with VNF testing."