azure-linux-automation/remote-scripts/perf_ntttcp.sh

203 строки
7.8 KiB
Bash

#!/bin/bash
#######################################################################
#
# Linux on Hyper-V and Azure Test Code, ver. 1.0.0
# Copyright (c) Microsoft Corporation
#
# All rights reserved.
# 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
#
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
# ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
# PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
#
#######################################################################
#######################################################################
#
# perf_ntttcp.sh
# Author : SHITAL SAVEKAR <v-shisav@microsoft.com>
#
# Description:
# Download and run ntttcp network performance tests.
# This script needs to be run on client VM.
#
# Supported Distros:
# Ubuntu 16.04
#######################################################################
CONSTANTS_FILE="./constants.sh"
ICA_TESTRUNNING="TestRunning" # The test is running
ICA_TESTCOMPLETED="TestCompleted" # The test completed successfully
ICA_TESTABORTED="TestAborted" # Error during the setup of the test
ICA_TESTFAILED="TestFailed" # Error occurred during the test
touch ./ntttcpTest.log
InstallNTTTCP() {
DISTRO=`grep -ihs "buntu\|Suse\|Fedora\|Debian\|CentOS\|Red Hat Enterprise Linux" /etc/{issue,*release,*version}`
if [[ $DISTRO =~ "Ubuntu" ]];
then
LogMsg "Detected UBUNTU"
LogMsg "Configuring ${1} for ntttcp test..."
ssh ${1} "apt-get update"
ssh ${1} "apt-get -y install libaio1 sysstat git bc make gcc"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
elif [[ $DISTRO =~ "Red Hat Enterprise Linux Server release 6" ]];
then
LogMsg "Detected Redhat 6.x"
ssh ${1} "rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm"
ssh ${1} "yum -y --nogpgcheck install libaio1 sysstat git bc make gcc"
ssh ${1} "yum -y --nogpgcheck install gcc-c++"
ssh ${1} "wget http://ftp.heanet.ie/mirrors/gnu/libc/glibc-2.14.1.tar.gz"
ssh ${1} "tar xvf glibc-2.14.1.tar.gz"
ssh ${1} "mv glibc-2.14.1 glibc-2.14 && cd glibc-2.14 && mkdir build && cd build && ../configure --prefix=/opt/glibc-2.14 && make && make install && export LD_LIBRARY_PATH=/opt/glibc-2.14/lib:$LD_LIBRARY_PATH"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
ssh ${1} "iptables -F"
elif [[ $DISTRO =~ "Red Hat Enterprise Linux Server release 7" ]];
then
LogMsg "Detected Redhat 7.x"
ssh ${1} "rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
ssh ${1} "yum -y --nogpgcheck install libaio1 sysstat git bc make gcc"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
ssh ${1} "iptables -F"
elif [[ $DISTRO =~ "CentOS Linux release 6" ]];
then
LogMsg "Detected CentOS 6.x"
ssh ${1} "rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm"
ssh ${1} "yum -y --nogpgcheck install libaio1 sysstat git bc make gcc"
ssh ${1} "yum -y --nogpgcheck install gcc-c++"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
ssh ${1} "iptables -F"
elif [[ $DISTRO =~ "CentOS Linux release 7" ]];
then
LogMsg "Detected CentOS 7.x"
ssh ${1} "rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
ssh ${1} "yum -y --nogpgcheck install libaio1 sysstat git bc make gcc"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
ssh ${1} "iptables -F"
elif [[ $DISTRO =~ "SUSE Linux Enterprise Server 12" ]];
then
LogMsg "Detected SLES12"
ssh ${1} "zypper --no-gpg-checks --non-interactive --gpg-auto-import-keys remove gettext-runtime-mini*"
ssh ${1} "zypper --no-gpg-checks --non-interactive --gpg-auto-import-keys install sysstat git bc make gcc grub2"
ssh ${1} "git clone https://github.com/Microsoft/ntttcp-for-linux.git"
ssh ${1} "cd ntttcp-for-linux/src/ && make && make install"
ssh ${1} "cp ntttcp-for-linux/src/ntttcp ."
ssh ${1} "rm -rf lagscope"
ssh ${1} "git clone https://github.com/Microsoft/lagscope"
ssh ${1} "cd lagscope/src && make && make install"
ssh ${1} "iptables -F"
else
LogMsg "Unknown Distro"
UpdateTestState "TestAborted"
UpdateSummary "Unknown Distro, test aborted"
return 1
fi
}
LogMsg()
{
echo `date "+%b %d %Y %T"` : "${1}" # Add the time stamp to the log message
echo "${1}" >> ./ntttcpTest.log
}
UpdateTestState()
{
echo "${1}" > ./state.txt
}
if [ -e ${CONSTANTS_FILE} ]; then
source ${CONSTANTS_FILE}
else
errMsg="Error: missing ${CONSTANTS_FILE} file"
LogMsg "${errMsg}"
UpdateTestState $ICA_TESTABORTED
exit 10
fi
if [ ! ${server} ]; then
errMsg="Please add/provide value for server in constants.sh. server=<server ip>"
LogMsg "${errMsg}"
echo "${errMsg}" >> ./summary.log
UpdateTestState $ICA_TESTABORTED
exit 1
fi
if [ ! ${client} ]; then
errMsg="Please add/provide value for client in constants.sh. client=<client ip>"
LogMsg "${errMsg}"
echo "${errMsg}" >> ./summary.log
UpdateTestState $ICA_TESTABORTED
exit 1
fi
if [ ! ${testDuration} ]; then
errMsg="Please add/provide value for testDuration in constants.sh. testDuration=60"
LogMsg "${errMsg}"
echo "${errMsg}" >> ./summary.log
UpdateTestState $ICA_TESTABORTED
exit 1
fi
#Make & build ntttcp on client and server Machine
LogMsg "Configuring client ${client}..."
InstallNTTTCP ${client}
LogMsg "Configuring server ${server}..."
InstallNTTTCP ${server}
#Now, start the ntttcp client on client VM.
ssh root@${client} "wget https://raw.githubusercontent.com/iamshital/linux_performance_test/master/run_ntttcp-for-linux/run-ntttcp-and-tcping.sh"
ssh root@${client} "wget https://raw.githubusercontent.com/iamshital/linux_performance_test/master/run_ntttcp-for-linux/report-ntttcp-and-tcping.sh"
ssh root@${client} "chmod +x run-ntttcp-and-tcping.sh && chmod +x report-ntttcp-and-tcping.sh"
LogMsg "Now running NTTTCP test"
ssh root@${client} "rm -rf ntttcp-test-logs"
ssh root@${client} "./run-ntttcp-and-tcping.sh ntttcp-test-logs ${server} root ${testDuration}"
ssh root@${client} "./report-ntttcp-and-tcping.sh ntttcp-test-logs"
ssh root@${client} "cp ntttcp-test-logs/* ."
UpdateTestState ICA_TESTCOMPLETED