Skip to content

Commit d653fa8

Browse files
committed
Put Temp on RAM Disk for Azure Pipelines tests
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.
1 parent be13cf9 commit d653fa8

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

.azure-pipelines/steps/run-tests-windows.yml

+54-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,62 @@ steps:
88
versionSpec: '$(python.version)'
99
architecture: '$(python.architecture)'
1010

11+
- powershell: |
12+
echo "Installing FS-iSCSITarget-Server"
13+
Install-WindowsFeature -Name FS-iSCSITarget-Server
14+
15+
# Allow connection on loopback interface.
16+
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\iSCSI Target' -Name AllowLoopBack -Value 1
17+
18+
echo "Starting MsiSCSI"
19+
Start-Service msiscsi
20+
$retry = 10
21+
do
22+
{
23+
$count = (Get-Service msiscsi | ? {$_.status -eq "Running"}).count
24+
$retry--
25+
sleep -Milliseconds 500
26+
} until ($count -Eq 0 -or $retry -Eq 0)
27+
28+
$service = Get-Service msiscsi
29+
if ($service.Status -Ne "Running") {
30+
throw "msiscsi not running"
31+
}
32+
33+
echo "Configuring Firewall"
34+
Get-NetFirewallServiceFilter -Service msiscsi | Enable-NetFirewallRule
35+
36+
echo "Configuring RAMDisk"
37+
New-IscsiVirtualDisk -ComputerName localhost -Path ramdisk:RAMDISK1.vhdx -Size 1GB
38+
New-IscsiServerTarget Target1 -ComputerName localhost -InitiatorId "IQN:*"
39+
Add-IscsiVirtualDiskTargetMapping -ComputerName localhost -TargetName Target1 -Path ramdisk:RAMDISK1.vhdx -Lun 1
40+
41+
echo "Connecting to iSCSI"
42+
$ip = (Get-NetIPAddress -AddressFamily IPv4).ipaddress[0]
43+
New-IscsiTargetPortal -TargetPortalAddress $ip
44+
Get-IscsiTarget | Connect-IscsiTarget
45+
46+
echo "Configuring disk"
47+
Get-IscsiConnection | Get-Disk | Set-Disk -IsOffline $False
48+
Get-IscsiConnection | Get-Disk | Initialize-Disk -PartitionStyle MBR
49+
Get-IscsiConnection | Get-Disk | New-Partition -UseMaximumSize -DriveLetter R
50+
Format-Volume -DriveLetter R -NewFileSystemLabel Temp -FileSystem NTFS
51+
52+
echo "Adding permissions"
53+
mkdir R:\Temp
54+
$acl = Get-Acl "R:\Temp"
55+
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
56+
$acl.AddAccessRule($rule)
57+
Set-Acl "R:\Temp" $acl
58+
displayName: Setup RAM Disk
59+
1160
- bash: pip install --upgrade setuptools tox
1261
displayName: Install Tox
1362

14-
- script: tox -e py -- -m unit -n 3 --junit-xml=junit/unit-test.xml
63+
- script:
64+
tox -e py -- -m unit --junit-xml=junit/unit-test.xml
65+
env:
66+
TEMP: "R:\\Temp"
1567
displayName: Tox run unit tests
1668

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

0 commit comments

Comments
 (0)