Commit a0a92be2 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

test/common: parallelize vm_setup.sh



We can significantly speed up the vm_setup.sh process by installing
dependencies in parallel.

Change-Id: I424efdf6da26a7f1394fbdca1cb6129e7329fc16
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/426981


Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 5ae73530
Loading
Loading
Loading
Loading
+235 −198
Original line number Diff line number Diff line
@@ -27,115 +27,8 @@ INSTALL=false
CONF="librxe,iscsi,rocksdb,fio,flamegraph,tsocks,qemu,vpp,libiscsi,nvmecli"
CONF_PATH="${VM_SETUP_PATH}/vm_setup.conf"

function usage()
function install_rxe_cfg()
{
    echo "This script is intended to automate the environment setup for a fedora linux virtual machine."
    echo "Please run this script as your regular user. The script will make calls to sudo as needed."
    echo ""
    echo "./vm_setup.sh"
    echo "  -h --help"
    echo "  -u --upgrade Run dnf upgrade"
    echo "  -i --install-deps Install dnf based dependencies"
    echo "  -t --test-conf List of test configurations to enable (${CONF})"
    echo "  -c --conf-path Path to configuration file"
    exit 0
}

while getopts 'iuht:c:-:' optchar; do
    case "$optchar" in
        -)
        case "$OPTARG" in
            help) usage;;
            upgrade) UPGRADE=true;;
            install-deps) INSTALL=true;;
            test-conf=*) CONF="${OPTARG#*=}";;
            conf-path=*) CONF_PATH="${OPTARG#*=}";;
            *) echo "Invalid argument '$OPTARG'"
            usage;;
        esac
        ;;
    h) usage;;
    u) UPGRADE=true;;
    i) INSTALL=true;;
    t) CONF="$OPTARG";;
    c) CONF_PATH="$OPTARG";;
    *) echo "Invalid argument '$OPTARG'"
    usage;;
    esac
done

if [ ! -f "$CONF_PATH" ]; then
	echo Configuration file does not exist: "$CONF_PATH"
	exit 1
fi

cd ~

source "$CONF_PATH"

jobs=$(($(nproc)*2))

if $UPGRADE; then
    sudo dnf upgrade -y
fi

if $INSTALL; then
    sudo dnf install -y git
fi

mkdir -p spdk_repo/output

if [ -d spdk_repo/spdk ]; then
    echo "spdk source already present, not cloning"
else
    git -C spdk_repo clone "${GIT_REPO_SPDK}"
fi
git -C spdk_repo/spdk config submodule.dpdk.url "${GIT_REPO_DPDK}"
git -C spdk_repo/spdk submodule update --init --recursive

if $INSTALL; then
    sudo ./scripts/pkgdep.sh

    if echo $CONF | grep -q tsocks; then
        sudo dnf install -y tsocks
    fi

    sudo dnf install -y \
    valgrind \
    jq \
    nvme-cli \
    ceph \
    gdb \
    fio \
    librbd-devel \
    kernel-devel \
    gflags-devel \
    libasan \
    libubsan \
    autoconf \
    automake \
    libtool \
    libmount-devel \
    iscsi-initiator-utils \
    isns-utils-devel \
    pmempool \
    perl-open \
    glib2-devel \
    pixman-devel \
    astyle-devel \
    elfutils \
    elfutils-libelf-devel \
    flex \
    bison \
    targetcli \
    perl-Switch \
    librdmacm-utils \
    libibverbs-utils \
    gdisk \
    socat \
    sshfs
fi

    if echo $CONF | grep -q librxe; then
        # rxe_cfg is used in the NVMe-oF tests
        # The librxe-dev repository provides a command line tool called rxe_cfg which makes it
@@ -155,7 +48,10 @@ if echo $CONF | grep -q librxe; then
            sudo make -C librxe-dev install
        fi
    fi
}

function install_iscsi_adm()
{
    if echo $CONF | grep -q iscsi; then
        # iscsiadm is used in the iscsi_tgt tests
        # The version of iscsiadm that ships with fedora 26 was broken as of November 3 2017.
@@ -187,11 +83,11 @@ if echo $CONF | grep -q iscsi; then
            fi
        fi
    fi
}

sudo mkdir -p /usr/src

function install_rocksdb()
{
    if echo $CONF | grep -q rocksdb; then

        # Rocksdb is installed for use with the blobfs tests.
        if [ ! -d /usr/src/rocksdb ]; then
            git clone "${GIT_REPO_ROCKSDB}"
@@ -202,7 +98,10 @@ if echo $CONF | grep -q rocksdb; then
            echo "rocksdb already in /usr/src. Not checking out again"
        fi
    fi
}

function install_fio()
{
    if echo $CONF | grep -q fio; then
        # This version of fio is installed in /usr/src/fio to enable
        # building the spdk fio plugin.
@@ -224,7 +123,10 @@ if echo $CONF | grep -q fio; then
            echo "fio already in /usr/src/fio. Not installing"
        fi
    fi
}

function install_flamegraph()
{
    if echo $CONF | grep -q flamegraph; then
        # Flamegraph is used when printing out timing graphs for the tests.
        if [ ! -d /usr/local/FlameGraph ]; then
@@ -235,7 +137,10 @@ if echo $CONF | grep -q flamegraph; then
            echo "flamegraph already installed. Skipping"
        fi
    fi
}

function install_qemu()
{
    if echo $CONF | grep -q qemu; then
        # Qemu is used in the vhost tests.
        SPDK_QEMU_BRANCH=spdk-2.12
@@ -262,7 +167,10 @@ if echo $CONF | grep -q qemu; then
        make -C ./qemu/$SPDK_QEMU_BRANCH -j${jobs}
        sudo make -C ./qemu/$SPDK_QEMU_BRANCH install
    fi
}

function install_vpp()
{
    if echo $CONF | grep -q vpp; then
        # Vector packet processing (VPP) is installed for use with iSCSI tests.
        # At least on fedora 28, the yum setup that vpp uses is deprecated and fails.
@@ -314,7 +222,10 @@ if echo $CONF | grep -q vpp; then
            sudo rm -f /etc/sysctl.d/80-vpp.conf
        fi
    fi
}

function install_nvmecli()
{
    if echo $CONF | grep -q nvmecli; then
        if [ ! -d nvme-cli ]; then
            git clone "${GIT_REPO_SPDK_NVME_CLI}"
@@ -322,7 +233,10 @@ if echo $CONF | grep -q nvmecli; then
            echo "nvme-cli already checked out. Skipping"
        fi
    fi
}

function install_libiscsi()
{
    if echo $CONF | grep -q libiscsi; then
        # We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need
        # to later. Cloning from git is just future proofing the machines.
@@ -335,7 +249,130 @@ if echo $CONF | grep -q libiscsi; then
        make -C ./libiscsi -j${jobs}
        sudo make -C ./libiscsi install
    fi
}

function usage()
{
    echo "This script is intended to automate the environment setup for a fedora linux virtual machine."
    echo "Please run this script as your regular user. The script will make calls to sudo as needed."
    echo ""
    echo "./vm_setup.sh"
    echo "  -h --help"
    echo "  -u --upgrade Run dnf upgrade"
    echo "  -i --install-deps Install dnf based dependencies"
    echo "  -t --test-conf List of test configurations to enable (${CONF})"
    echo "  -c --conf-path Path to configuration file"
    exit 0
}

while getopts 'iuht:c:-:' optchar; do
    case "$optchar" in
        -)
        case "$OPTARG" in
            help) usage;;
            upgrade) UPGRADE=true;;
            install-deps) INSTALL=true;;
            test-conf=*) CONF="${OPTARG#*=}";;
            conf-path=*) CONF_PATH="${OPTARG#*=}";;
            *) echo "Invalid argument '$OPTARG'"
            usage;;
        esac
        ;;
    h) usage;;
    u) UPGRADE=true;;
    i) INSTALL=true;;
    t) CONF="$OPTARG";;
    c) CONF_PATH="$OPTARG";;
    *) echo "Invalid argument '$OPTARG'"
    usage;;
    esac
done

if [ ! -f "$CONF_PATH" ]; then
	echo Configuration file does not exist: "$CONF_PATH"
	exit 1
fi

cd ~

source "$CONF_PATH"

jobs=$(($(nproc)*2))

if $UPGRADE; then
    sudo dnf upgrade -y
fi

if $INSTALL; then
    sudo dnf install -y git
fi

mkdir -p spdk_repo/output

if [ -d spdk_repo/spdk ]; then
    echo "spdk source already present, not cloning"
else
    git -C spdk_repo clone "${GIT_REPO_SPDK}"
fi
git -C spdk_repo/spdk config submodule.dpdk.url "${GIT_REPO_DPDK}"
git -C spdk_repo/spdk submodule update --init --recursive

if $INSTALL; then
    sudo ./scripts/pkgdep.sh

    if echo $CONF | grep -q tsocks; then
        sudo dnf install -y tsocks
    fi

    sudo dnf install -y \
    valgrind \
    jq \
    nvme-cli \
    ceph \
    gdb \
    fio \
    librbd-devel \
    kernel-devel \
    gflags-devel \
    libasan \
    libubsan \
    autoconf \
    automake \
    libtool \
    libmount-devel \
    iscsi-initiator-utils \
    isns-utils-devel \
    pmempool \
    perl-open \
    glib2-devel \
    pixman-devel \
    astyle-devel \
    elfutils \
    elfutils-libelf-devel \
    flex \
    bison \
    targetcli \
    perl-Switch \
    librdmacm-utils \
    libibverbs-utils \
    gdisk \
    socat \
    sshfs
fi

sudo mkdir -p /usr/src

install_rxe_cfg&
install_iscsi_adm&
install_rocksdb&
install_fio&
install_flamegraph&
install_qemu&
install_vpp&
install_nvmecli&
install_libiscsi&

wait
# create autorun-spdk.conf in home folder. This is sourced by the autotest_common.sh file.
# By setting any one of the values below to 0, you can skip that specific test. If you are
# using your autotest platform to do sanity checks before uploading to the build pool, it is