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"
31 TREX_DOWNLOAD="https://trex-tgn.cisco.com/trex/release/v2.05.tar.gz"
32 DPDK_DOWNLOAD="http://dpdk.org/browse/dpdk/snapshot/dpdk-16.07.zip"
33 VIRTUAL_VENV="$INSTALL_BIN_PATH/yardstick_venv"
36 # Install libs needed for NSB
40 echo "Install libs needed to build and run NSB Testing..."
41 apt-get update > /dev/null 2>&1
42 pkg=(git build-essential python-dev virtualenv python-virtualenv virtualenv linux-headers-$(uname -r) unzip python-pip libpcap-dev)
43 for i in "${pkg[@]}"; do
44 dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
45 if [ "$?" -eq "1" ]; then
46 apt-get -y install "${i}";
54 echo "Create install directory... $INSTALL_BIN_PATH"
55 mkdir -p $INSTALL_BIN_PATH
56 echo "Install yardstick dependencies and build Yardstick in venv..."
60 virtualenv $VIRTUAL_VENV
61 if [ ! -f "$INSTALL_BIN_PATH/yardstick_venv/bin/activate" ]; then
62 echo "Installation Error. Failed to create yardstick virtual env..."
65 source $VIRTUAL_VENV/bin/activate
67 python setup.py install
71 echo "Copying yardstick sample conf & pod file to /etc/yardstick/nodes"
72 mkdir -p /etc/yardstick/nodes
73 cp "$REPO_DIR/etc/yardstick/yardstick.conf.sample" "/etc/yardstick/yardstick.conf"
74 cp "$REPO_DIR/etc/yardstick/nodes/pod.yaml.nsb.sample" "/etc/yardstick/nodes/"
79 # Install trex for TH setup
83 TREX_DIR=$INSTALL_BIN_PATH/trex/scripts
84 if [ -d "$TREX_DIR" ]; then
85 echo "Trex v2.05already installed. Make sure it contains PYTHONPATH which is required to run TRex"
87 echo "Build TRex and installing Trex TG in $INSTALL_BIN_PATH/trex"
88 rm -rf ${TREX_DOWNLOAD##*/}
89 if [ ! -e ${TREX_DOWNLOAD##*/} ] ; then
92 tar zxvf ${TREX_DOWNLOAD##*/}
98 cd trex/scripts/ko/src/
101 # workaround trex module issue
102 touch "$REPO_DIR/trex/scripts/automation/trex_control_plane/stl/__init__.py"
103 cp "$REPO_DIR/trex/scripts/dpdk_nic_bind.py" "$INSTALL_BIN_PATH"
111 if [ -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
112 echo "DPDK already installed make sure.. igb_uio is loaded."
114 echo "Build DPDK 16.07..."
116 rm -rf ${DPDK_DOWNLOAD##*/}
117 rm -rf "$REPO_DIR/dpdk-16.07/"
118 if [ ! -e ${DPDK_DOWNLOAD##*/} ] ; then
119 wget ${DPDK_DOWNLOAD}
121 unzip -o ${DPDK_DOWNLOAD##*/}
124 make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc
125 cd x86_64-native-linuxapp-gcc
126 echo "Enable Port Stats..."
127 sed -i -e 's/CONFIG_RTE_PORT_STATS_COLLECT=n/CONFIG_RTE_PORT_STATS_COLLECT=y/g' .config
128 sed -i -e 's/CONFIG_RTE_PORT_PCAP=n/CONFIG_RTE_PORT_PCAP=y/g' .config
129 sed -i -e 's/CONFIG_RTE_TABLE_STATS_COLLECT=n/CONFIG_RTE_TABLE_STATS_COLLECT=y/g' .config
130 sed -i -e 's/CONFIG_RTE_PIPELINE_STATS_COLLECT=n/CONFIG_RTE_PIPELINE_STATS_COLLECT=y/g' .config
133 echo "Load DPDK modules and setup hugepages"
135 mkdir -p "/lib/modules/$(uname -r)/extra"
136 cp -r "kmod/igb_uio.ko" "/lib/modules/$(uname -r)/extra"
139 sh -c "echo 'uio\nigb_uio\n' > /etc/modules-load.d/nsb.conf"
141 HUGEPGSZ=$(cat < /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' ')
143 if [[ "$HUGEPGSZ" = "2048kB" ]] ; then
146 grep nr_hugepages /etc/sysctl.conf
147 if [[ "$?" -eq '1' ]] ; then
148 sh -c "echo 'vm.nr_hugepages=$Pages' >> /etc/sysctl.conf"
150 echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" > .echo_tmp
151 echo "Reserving hugepages"
156 echo "Creating /mnt/huge and mounting as hugetlbfs"
157 sudo mkdir -p /mnt/huge
159 grep -s '/mnt/huge' /proc/mounts > /dev/null
160 if [ $? -ne 0 ] ; then
161 sudo mount -t hugetlbfs nodev /mnt/huge
164 mv "$REPO_DIR/dpdk-16.07" "$INSTALL_BIN_PATH"
167 export RTE_SDK="$INSTALL_BIN_PATH/dpdk-16.07"
168 export RTE_TARGET=x86_64-native-linuxapp-gcc
170 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
172 echo "Building vPE VNF..."
173 cd $INSTALL_BIN_PATH/dpdk-16.07/examples/ip_pipeline/
176 cp build/ip_pipeline $INSTALL_BIN_PATH/vPE_vnf
185 if [ ! -d "$INSTALL_BIN_PATH/trex" ]; then
186 cp -fr "$REPO_DIR/trex" "$INSTALL_BIN_PATH"
188 rm -rf "$REPO_DIR/trex"
190 if [ -d "$INSTALL_BIN_PATH/trex" ]; then
191 echo "Setup Environment variables for Test Harness...."
192 PYTHONPATH="$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane:$INSTALL_BIN_PATH/trex/scripts/automation/trex_control_plane/stl"
193 PY_PATH=$(grep PYTHONPATH ~/.bash_profile)
194 if [ "$PY_PATH" = "" ] ; then
195 sh -c "echo export PYTHONPATH=$PYTHONPATH >> ~/.bash_profile" > /dev/null
197 echo "Your ~/.bash_profile already contains a PYTHONPATH definition."
198 echo "Make sure it contains $PYTHONPATH which is required to run TRex"
201 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.sh" "$INSTALL_BIN_PATH"
202 cp "$REPO_DIR/yardstick/network_services/nfvi/collectd.conf" "$INSTALL_BIN_PATH"
203 cp "$REPO_DIR/nsb_setup.sh" "$INSTALL_BIN_PATH"
207 check_installed_files()
209 if [ ! -f "$INSTALL_BIN_PATH/yardstick_venv/bin/activate" ]; then
210 echo "Installation Error. Failed to create yardstick virtual env..."
214 if [ ! -d "$INSTALL_BIN_PATH/dpdk-16.07" ]; then
215 echo "Installation Error. Failed to download and install dpdk-16.07..."
219 if [ ! -d "$INSTALL_BIN_PATH/trex" ]; then
220 echo "Installation Error. Failed to download and configure Trex"
224 if [ ! -f "$INSTALL_BIN_PATH/vPE_vnf" ]; then
225 echo "Installation Error. vPE VNF not present in install dir $INSTALL_BIN_PATH"
230 if [ "$1" == "dpdk" ]; then
239 check_installed_files
241 echo "Installation completed..."
242 echo "Virtual Environment : $INSTALL_BIN_PATH/yardstick_venv"
243 echo "Please Refer README.NSB.rst document on how to get started on VNF testing."