Skip to content

Commit

Permalink
Put Temp on RAM Disk for Azure Pipelines tests
Browse files Browse the repository at this point in the history
Profiling on Azure Pipelines indicates that the majority of our time is
spent waiting for filesystem operations to complete. As a quick way to
improve our test speed in this area, we can do operations on a RAM disk
instead of the default SSDs.
  • Loading branch information
chrahunt committed Oct 28, 2019
1 parent be13cf9 commit d653fa8
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions .azure-pipelines/steps/run-tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,62 @@ steps:
versionSpec: '$(python.version)'
architecture: '$(python.architecture)'

- powershell: |
echo "Installing FS-iSCSITarget-Server"
Install-WindowsFeature -Name FS-iSCSITarget-Server
# Allow connection on loopback interface.
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\iSCSI Target' -Name AllowLoopBack -Value 1
echo "Starting MsiSCSI"
Start-Service msiscsi
$retry = 10
do
{
$count = (Get-Service msiscsi | ? {$_.status -eq "Running"}).count
$retry--
sleep -Milliseconds 500
} until ($count -Eq 0 -or $retry -Eq 0)
$service = Get-Service msiscsi
if ($service.Status -Ne "Running") {
throw "msiscsi not running"
}
echo "Configuring Firewall"
Get-NetFirewallServiceFilter -Service msiscsi | Enable-NetFirewallRule
echo "Configuring RAMDisk"
New-IscsiVirtualDisk -ComputerName localhost -Path ramdisk:RAMDISK1.vhdx -Size 1GB
New-IscsiServerTarget Target1 -ComputerName localhost -InitiatorId "IQN:*"
Add-IscsiVirtualDiskTargetMapping -ComputerName localhost -TargetName Target1 -Path ramdisk:RAMDISK1.vhdx -Lun 1
echo "Connecting to iSCSI"
$ip = (Get-NetIPAddress -AddressFamily IPv4).ipaddress[0]
New-IscsiTargetPortal -TargetPortalAddress $ip
Get-IscsiTarget | Connect-IscsiTarget
echo "Configuring disk"
Get-IscsiConnection | Get-Disk | Set-Disk -IsOffline $False
Get-IscsiConnection | Get-Disk | Initialize-Disk -PartitionStyle MBR
Get-IscsiConnection | Get-Disk | New-Partition -UseMaximumSize -DriveLetter R
Format-Volume -DriveLetter R -NewFileSystemLabel Temp -FileSystem NTFS
echo "Adding permissions"
mkdir R:\Temp
$acl = Get-Acl "R:\Temp"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)
Set-Acl "R:\Temp" $acl
displayName: Setup RAM Disk

- bash: pip install --upgrade setuptools tox
displayName: Install Tox

- script: tox -e py -- -m unit -n 3 --junit-xml=junit/unit-test.xml
- script:
tox -e py -- -m unit --junit-xml=junit/unit-test.xml
env:
TEMP: "R:\\Temp"
displayName: Tox run unit tests

- ${{ if eq(parameters.runIntegrationTests, 'true') }}:
Expand All @@ -23,9 +75,7 @@ steps:
# Shorten paths to get under MAX_PATH or else integration tests will fail
# https://bugs.python.org/issue18199
subst T: $env:TEMP
$env:TEMP = "T:\"
$env:TMP = "T:\"
$env:TEMP = "R:\Temp"
tox -e py -- -m integration -n 3 --duration=5 --junit-xml=junit/integration-test.xml
displayName: Tox run integration tests
Expand Down

0 comments on commit d653fa8

Please sign in to comment.