Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
iamshital committed Oct 30, 2018
2 parents a676659 + 4318173 commit 067d2eb
Show file tree
Hide file tree
Showing 32 changed files with 1,329 additions and 333 deletions.
2 changes: 1 addition & 1 deletion Libraries/CommonFunctions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Function ProvisionVMsForLisa($allVMData, $installPackagesOnRoleNames)
foreach ( $vmData in $allVMData )
{
LogMsg "Configuring $($vmData.RoleName) for LISA test..."
RemoteCopy -uploadTo $vmData.PublicIP -port $vmData.SSHPort -files ".\Testscripts\Linux\enableRoot.sh,.\Testscripts\Linux\enablePasswordLessRoot.sh,.\Testscripts\Linux\provisionLinuxForLisa.sh" -username $user -password $password -upload
RemoteCopy -uploadTo $vmData.PublicIP -port $vmData.SSHPort -files ".\Testscripts\Linux\utils.sh,.\Testscripts\Linux\enableRoot.sh,.\Testscripts\Linux\enablePasswordLessRoot.sh,.\Testscripts\Linux\provisionLinuxForLisa.sh" -username $user -password $password -upload
$Null = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort -username $user -password $password -command "chmod +x /home/$user/*.sh" -runAsSudo
$rootPasswordSet = RunLinuxCmd -ip $vmData.PublicIP -port $vmData.SSHPort `
-username $user -password $password -runAsSudo `
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Test-Framework.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function Enable-RootUser {

foreach ($VM in $VMData) {
RemoteCopy -upload -uploadTo $VM.PublicIP -Port $VM.SSHPort `
-files ".\Testscripts\Linux\enableRoot.sh" -Username $Username -password $Password
-files ".\Testscripts\Linux\utils.sh,.\Testscripts\Linux\enableRoot.sh" -Username $Username -password $Password
$cmdResult = RunLinuxCmd -Command "bash enableRoot.sh -password ${RootPassword}" -runAsSudo `
-Username $Username -password $Password -ip $VM.PublicIP -Port $VM.SSHPort
if (-not $cmdResult) {
Expand Down
2 changes: 1 addition & 1 deletion Run-LisaV2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ try {
Set-Variable -Name shortRandomWord -Value $(-join ((65..90) | Get-Random -Count 4 | ForEach-Object {[char]$_})) -Scope Global
if ( $WorkingDirectory.Length -gt $MaxDirLength) {
$OriginalWorkingDirectory = $WorkingDirectory
Write-Output "Current working directory '$WorkingDirectory' length is greather than $MaxDirLength."
Write-Output "Current working directory '$WorkingDirectory' length is greater than $MaxDirLength."
$TempWorkspace = "$(Split-Path $OriginalWorkingDirectory -Qualifier)"
New-Item -ItemType Directory -Path "$TempWorkspace\LISAv2" -Force -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory -Path "$TempWorkspace\LISAv2\$shortRandomWord$shortRandomNumber" -Force -ErrorAction SilentlyContinue | Out-Null
Expand Down
2 changes: 1 addition & 1 deletion Testscripts/Linux/BVT-CORE-TIME-CLOCKSOURCE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CheckSource()
fi

# check dmesg with hyperv_clocksource
if [[ detect_linux_distribution -eq clear-linux-os ]]; then
if [[ $(detect_linux_distribution) == clear-linux-os ]]; then
__dmesg_output=$(dmesg | grep -e "clocksource $clocksource")
else
__dmesg_output=$(grep -rnw '/var/log' -e "clocksource $clocksource" --ignore-case)
Expand Down
13 changes: 11 additions & 2 deletions Testscripts/Linux/SR-IOV-Utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ VerifyVF()
fi

interface=$(ls /sys/class/net/ | grep -v 'eth0\|eth1\|lo' | head -1)
ifconfig -a | grep $interface
if [ $? -ne 0 ]; then
ip a | grep $interface
if [ $? -ne 0 ]; then
LogErr "VF device, $interface , was not found!"
SetTestStateFailed
exit 1
Expand Down Expand Up @@ -235,6 +235,15 @@ InstallDependencies()
# Check if iPerf3 is already installed
iperf3 -v > /dev/null 2>&1
if [ $? -ne 0 ]; then
update_repos
gcc -v
if [ $? -ne 0 ]; then
install_package "gcc"
fi
make -v
if [ $? -ne 0 ]; then
install_package "make"
fi
wget $iperf3_url
if [ $? -ne 0 ]; then
LogErr "Failed to download iperf3 from $iperf3_url"
Expand Down
108 changes: 108 additions & 0 deletions Testscripts/Linux/SRIOV-DisableVF.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License.
#
# Description:
# Disable VF, verify SR-IOV Failover is working
#
########################################################################
remote_user="root"
if [ ! -e sriov_constants.sh ]; then
cp /${remote_user}/sriov_constants.sh .
fi
# Source SR-IOV_Utils.sh. This is the script that contains all the
# SR-IOV basic functions (checking drivers, checking VFs, assigning IPs)
. SR-IOV-Utils.sh || {
echo "ERROR: unable to source SR-IOV_Utils.sh!"
echo "TestAborted" > state.txt
exit 0
}

# Check if the SR-IOV driver is in use
VerifyVF
if [ $? -ne 0 ]; then
LogErr "VF is not loaded! Make sure you are using compatible hardware"
SetTestStateFailed
exit 0
fi
# Create an 1gb file to be sent from VM1 to VM2
Create1Gfile
if [ $? -ne 0 ]; then
LogErr "Could not create the 1gb file on VM1!"
SetTestStateFailed
exit 0
fi

# Check if the VF count inside the VM is the same as the expected count
vf_count=$(find /sys/devices -name net -a -ipath '*vmbus*' | grep -c pci)
if [ $vf_count -ne $NIC_COUNT ]; then
LogErr "Expected VF count: $NIC_COUNT. Actual VF count: $vf_count"
SetTestStateFailed
exit 0
fi
UpdateSummary "Expected VF count: $NIC_COUNT. Actual VF count: $vf_count"

# Extract VF name
synthetic_interface=$(ip addr | grep $VF_IP1 | awk '{print $NF}')
LogMsg "Synthetic interface found: $synthetic_interface"
vf_interface=$(find /sys/devices/* -name "*${synthetic_interface}*" | grep "pci" | sed 's/\// /g' | awk '{print $12}')
LogMsg "Virtual function found: $vf_interface"

# Put VF down
ip link set dev $vf_interface down
ping -c 11 "$VF_IP2" >/dev/null 2>&1
if [ 0 -eq $? ]; then
LogMsg "Successfully pinged $VF_IP2 with VF down"
else
LogErr "Unable to ping $VF_IP2 with VF down"
SetTestStateFailed
exit 0
fi
# Send 1GB file from VM1 to VM2 via synthetic interface
scp -i "$HOME"/.ssh/"$SSH_PRIVATE_KEY" -o StrictHostKeyChecking=no "$output_file" "$remote_user"@"$VF_IP2":/tmp/"$output_file"
if [ 0 -ne $? ]; then
LogErr "Unable to send the file from VM1 to VM2 ($VF_IP2)"
SetTestStateFailed
exit 0
else
LogMsg "Successfully sent $output_file to $VF_IP2"
fi
# Get TX value for synthetic interface after sending the file
tx_value=$(cat /sys/class/net/${synthetic_interface}/statistics/tx_packets)
LogMsg "TX value after sending the file: $tx_value"
if [ $tx_value -lt 10000 ]; then
LogErr "Insufficient TX packets sent on ${synthetic_interface}"
SetTestStateFailed
exit 0
fi

# Put VF up
ip link set dev $vf_interface up
ping -c 11 "$VF_IP2" >/dev/null 2>&1
if [ 0 -ne $? ]; then
LogErr "Unable to ping $VF_IP2 with VF down"
SetTestStateFailed
exit 0
fi
# Send 1GB file from VM1 to VM2 via VF
scp -i "$HOME"/.ssh/"$SSH_PRIVATE_KEY" -o StrictHostKeyChecking=no "$output_file" "$remote_user"@"$VF_IP2":/tmp/"$output_file"
if [ 0 -ne $? ]; then
LogErr "Unable to send the file from VM1 to VM2 ($VF_IP2)"
SetTestStateFailed
exit 0
else
LogMsg "Successfully sent $output_file to $VF_IP2"
fi
# Get TX value for VF after sending the file
tx_value=$(cat /sys/class/net/${vf_interface}/statistics/tx_packets)
LogMsg "TX value after sending the file: $tx_value"
if [ $tx_value -lt 10000 ]; then
LogErr "Insufficient TX packets sent on ${vf_interface}"
SetTestStateFailed
exit 0
fi

UpdateSummary "Successfully disabled and enabled VF"
SetTestStateCompleted
exit 0
92 changes: 92 additions & 0 deletions Testscripts/Linux/SRIOV-Iperf-Stress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License.
#
# Description:
# This SR-IOV test will run iPerf3 for 30 minutes and checks
# if network connectivity is lost at any point
#
########################################################################
remote_user="root"
if [ ! -e sriov_constants.sh ]; then
cp /${remote_user}/sriov_constants.sh .
fi
export PATH="/usr/local/bin:${PATH}"
# Source SR-IOV_Utils.sh. This is the script that contains all the
# SR-IOV basic functions (checking drivers, checking VFs, assigning IPs)
. SR-IOV-Utils.sh || {
echo "ERROR: unable to source SR-IOV_Utils.sh!"
echo "TestAborted" > state.txt
exit 0
}

# Check if the SR-IOV driver is in use
VerifyVF
if [ $? -ne 0 ]; then
LogErr "VF is not loaded! Make sure you are using compatible hardware"
SetTestStateFailed
exit 0
fi

# Check if the VF count inside the VM is the same as the expected count
vf_count=$(find /sys/devices -name net -a -ipath '*vmbus*' | grep pci | wc -l)
if [ $vf_count -ne $NIC_COUNT ]; then
LogErr "Expected VF count: $NIC_COUNT. Actual VF count: $vf_count"
SetTestStateFailed
exit 0
fi
UpdateSummary "Expected VF count: $NIC_COUNT. Actual VF count: $vf_count"

# Start iPerf server on dependency VM
ssh -i "$HOME"/.ssh/"$SSH_PRIVATE_KEY" -o StrictHostKeyChecking=no "$remote_user"@"$VF_IP2" 'iperf3 -s > perfResults.log &'
if [ $? -ne 0 ]; then
LogErr "Could not start iPerf3 on VM2 (VF_IP: ${VF_IP2})"
SetTestStateFailed
exit 0
fi

# Start iPerf client
iperf3 -t 1800 -c ${VF_IP2} --logfile perfResults.log
if [ $? -ne 0 ]; then
LogErr "Could not start iPerf3 on VM1 (VF_IP: ${VF_IP1})"
SetTestStateFailed
exit 0
fi

# Check for errors
if [ ! -e perfResults.log ]; then
LogErr "iPerf3 didn't run!"
SetTestStateFailed
exit 0
fi

iperf_errors=$(cat perfResults.log | grep -i error)
if [ $? -eq 0 ]; then
LogErr "iPerf3 had errors while running"
LogErr $iperf_errors
SetTestStateFailed
exit 0
fi

# Get the throughput
throughput=$(tail -4 perfResults.log | head -1 | awk '{print $7}')
UpdateSummary "iPerf3 throughput is $throughput gbps"

# Check the connection again
ping -c 11 ${VF_IP2} > pingResults.log
if [ $? -ne 0 ]; then
LogErr "Could not ping from VM1 to VM2 after iPerf3 finished the run"
SetTestStateFailed
exit 0
fi
cat pingResults.log | grep " 0%"
if [ $? -ne 0 ]; then
LogErr "Ping shows that packets were lost between VM1 and VM"
SetTestStateFailed
exit 0
fi

UpdateSummary "Ping was succesful between VM1 and VM2 after iPerf3 finished the run"
SetTestStateCompleted
exit 0
Loading

0 comments on commit 067d2eb

Please sign in to comment.