diff --git a/.azure-pipelines/steps/run-tests-windows.yml b/.azure-pipelines/steps/run-tests-windows.yml index 6ce5d1cc010..a8a4781714f 100644 --- a/.azure-pipelines/steps/run-tests-windows.yml +++ b/.azure-pipelines/steps/run-tests-windows.yml @@ -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') }}: @@ -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