diff --git a/.appveyor.yml b/.appveyor.yml index bc76d6919ed..b3b997c585f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,12 +1,12 @@ environment: - matrix: + matrix: [] # Unit and integration tests. - - PYTHON: "C:\\Python27-x64" - RUN_INTEGRATION_TESTS: "True" - - PYTHON: "C:\\Python35-x64" - RUN_INTEGRATION_TESTS: "True" - - PYTHON: "C:\\Python36-x64" - RUN_INTEGRATION_TESTS: "True" + #- PYTHON: "C:\\Python27-x64" + # RUN_INTEGRATION_TESTS: "True" + #- PYTHON: "C:\\Python35-x64" + # RUN_INTEGRATION_TESTS: "True" + #- PYTHON: "C:\\Python36-x64" + # RUN_INTEGRATION_TESTS: "True" # Unit tests only. # Nothing for the moment diff --git a/.azure-pipelines/jobs/test-windows.yml b/.azure-pipelines/jobs/test-windows.yml index ee869c87c89..17e98f16db2 100644 --- a/.azure-pipelines/jobs/test-windows.yml +++ b/.azure-pipelines/jobs/test-windows.yml @@ -9,9 +9,9 @@ jobs: vmImage: ${{ parameters.vmImage }} strategy: matrix: - Python27-x86: - python.version: '2.7' - python.architecture: x86 + #Python27-x86: + # python.version: '2.7' + # python.architecture: x86 Python37-x64: python.version: '3.7' python.architecture: x64 @@ -22,29 +22,29 @@ jobs: parameters: runIntegrationTests: true -- job: Test_Secondary - displayName: Test Secondary - # Don't run integration tests for these runs - # Run after Test_Primary so we don't devour time and jobs if tests are going to fail - dependsOn: Test_Primary - - pool: - vmImage: ${{ parameters.vmImage }} - strategy: - matrix: - # This is for Windows, so test x86 builds - Python35-x86: - python.version: '3.5' - python.architecture: x86 - Python36-x86: - python.version: '3.6' - python.architecture: x86 - Python37-x86: - python.version: '3.7' - python.architecture: x86 - maxParallel: 5 - - steps: - - template: ../steps/run-tests-windows.yml - parameters: - runIntegrationTests: false +#- job: Test_Secondary +# displayName: Test Secondary +# # Don't run integration tests for these runs +# # Run after Test_Primary so we don't devour time and jobs if tests are going to fail +# dependsOn: Test_Primary +# +# pool: +# vmImage: ${{ parameters.vmImage }} +# strategy: +# matrix: +# # This is for Windows, so test x86 builds +# Python35-x86: +# python.version: '3.5' +# python.architecture: x86 +# Python36-x86: +# python.version: '3.6' +# python.architecture: x86 +# Python37-x86: +# python.version: '3.7' +# python.architecture: x86 +# maxParallel: 5 +# +# steps: +# - template: ../steps/run-tests-windows.yml +# parameters: +# runIntegrationTests: false diff --git a/.azure-pipelines/linux.yml b/.azure-pipelines/linux.yml index 6965a15fc6d..83def29a1d8 100644 --- a/.azure-pipelines/linux.yml +++ b/.azure-pipelines/linux.yml @@ -3,6 +3,6 @@ jobs: parameters: vmImage: ubuntu-16.04 -- template: jobs/package.yml - parameters: - vmImage: ubuntu-16.04 +#- template: jobs/package.yml +# parameters: +# vmImage: ubuntu-16.04 diff --git a/.azure-pipelines/macos.yml b/.azure-pipelines/macos.yml index 7408a38840f..2e492fabf52 100644 --- a/.azure-pipelines/macos.yml +++ b/.azure-pipelines/macos.yml @@ -3,6 +3,6 @@ jobs: parameters: vmImage: xcode9-macos10.13 -- template: jobs/package.yml - parameters: - vmImage: xcode9-macos10.13 +#- template: jobs/package.yml +# parameters: +# vmImage: xcode9-macos10.13 diff --git a/.azure-pipelines/steps/run-tests-windows.yml b/.azure-pipelines/steps/run-tests-windows.yml index 6ce5d1cc010..fea22603bf7 100644 --- a/.azure-pipelines/steps/run-tests-windows.yml +++ b/.azure-pipelines/steps/run-tests-windows.yml @@ -8,12 +8,96 @@ 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: Test + +- powershell: | + Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/?linkid=2026036 -OutFile adksetup.exe + ./adksetup.exe /features OptionId.WindowsPerformanceToolkit /log adk-setup.log /ceip off /installpath "C:\Program Files (x86)\Windows Kits\10\" + # Wait for install to complete. + python -c " + import os, time + start = time.time() + last = start + while last - start < 60: + if os.path.exists('C:/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/wpr.exe'): + break + print('Waiting...') + time.sleep(2) + last = time.time() + " + Get-Content adk-setup.log + displayName: ADK Setup + - bash: pip install --upgrade setuptools tox displayName: Install Tox -- script: tox -e py -- -m unit -n 3 --junit-xml=junit/unit-test.xml +- script: mkdir traces + displayName: Make trace output directory + +- script: + tox -e py -- -m unit --junit-xml=junit/unit-test.xml + env: + TEMP: "R:\\Temp" displayName: Tox run unit tests +#- script: +# tracerpt -l traces/wpr-result.etl -export traces/providers.man +# displayName: Generate trace provider manifest +# +#- task: PublishBuildArtifacts@1 +# displayName: 'Publish trace results' +# inputs: +# pathtoPublish: traces +# artifactName: wpr-result-$(python.version)-$(python.architecture).etl +# condition: succeededOrFailed() + - ${{ if eq(parameters.runIntegrationTests, 'true') }}: - powershell: | # Fix Git SSL errors @@ -23,9 +107,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 diff --git a/.azure-pipelines/windows.yml b/.azure-pipelines/windows.yml index 9d1bf5385d0..bf5526fd2c4 100644 --- a/.azure-pipelines/windows.yml +++ b/.azure-pipelines/windows.yml @@ -3,6 +3,6 @@ jobs: parameters: vmImage: vs2017-win2016 -- template: jobs/package.yml - parameters: - vmImage: vs2017-win2016 +#- template: jobs/package.yml +# parameters: +# vmImage: vs2017-win2016 diff --git a/.github/workflows/python-linters.yml b/.github/workflows.ignore/python-linters.yml similarity index 100% rename from .github/workflows/python-linters.yml rename to .github/workflows.ignore/python-linters.yml diff --git a/.travis.yml b/.travis.yml index c61e41702be..5e31c84d40a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,45 +12,45 @@ stages: - secondary jobs: - include: - # Basic Checks - - stage: primary - env: TOXENV=docs - - env: TOXENV=lint - - env: TOXENV=vendoring - # Latest CPython - - env: GROUP=1 - python: 2.7 - - env: GROUP=2 - python: 2.7 - - env: GROUP=1 - - env: GROUP=2 + include: [] + ## Basic Checks + #- stage: primary + # env: TOXENV=docs + #- env: TOXENV=lint + #- env: TOXENV=vendoring + ## Latest CPython + #- env: GROUP=1 + # python: 2.7 + #- env: GROUP=2 + # python: 2.7 + #- env: GROUP=1 + #- env: GROUP=2 - # Complete checking for ensuring compatibility - # PyPy - - stage: secondary - env: GROUP=1 - python: pypy3.5-6.0 - - env: GROUP=2 - python: pypy3.5-6.0 - - env: GROUP=1 - python: pypy2.7-6.0 - - env: GROUP=2 - python: pypy2.7-6.0 - # Other Supported CPython - - env: GROUP=1 - python: 3.6 - - env: GROUP=2 - python: 3.6 - - env: GROUP=1 - python: 3.5 - - env: GROUP=2 - python: 3.5 + ## Complete checking for ensuring compatibility + ## PyPy + #- stage: secondary + # env: GROUP=1 + # python: pypy3.5-6.0 + #- env: GROUP=2 + # python: pypy3.5-6.0 + #- env: GROUP=1 + # python: pypy2.7-6.0 + #- env: GROUP=2 + # python: pypy2.7-6.0 + ## Other Supported CPython + #- env: GROUP=1 + # python: 3.6 + #- env: GROUP=2 + # python: 3.6 + #- env: GROUP=1 + # python: 3.5 + #- env: GROUP=2 + # python: 3.5 - - env: GROUP=1 - python: 3.8-dev - - env: GROUP=2 - python: 3.8-dev + #- env: GROUP=1 + # python: 3.8-dev + #- env: GROUP=2 + # python: 3.8-dev fast_finish: true # It's okay to fail on the in-development CPython version. diff --git a/tests/conftest.py b/tests/conftest.py index 7a54373b8ec..9fcd09308c4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,12 @@ from tests.lib.venv import VirtualEnvironment +sys.path.append(os.path.dirname(os.path.dirname(__file__))) + + +pytest_plugins = "tests.plugins.wpr" + + def pytest_addoption(parser): parser.addoption( "--keep-tmpdir", action="store_true", diff --git a/tests/plugins/__init__.py b/tests/plugins/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/plugins/wpr.py b/tests/plugins/wpr.py new file mode 100644 index 00000000000..1961dc07702 --- /dev/null +++ b/tests/plugins/wpr.py @@ -0,0 +1,105 @@ +import os +import re +import subprocess +import sys +from itertools import chain, repeat + + +def pytest_addoption(parser): + group = parser.getgroup('wpr') + group.addoption( + '--use-wpr', + action='store_true', + ) + group.addoption( + '--wpr-path', + default=None, + ) + group.addoption( + '--wpr-output', + default=None, + ) + group.addoption( + '--wpr-profile', + action='append', + ) + + +class Plugin(object): + def __init__(self, config): + self.config = config + + def pytest_runtest_logstart(self, nodeid, location): + wpr_path = self.config.getoption('--wpr-path') + if not wpr_path: + return + msg = "{} ({}) - begin".format(nodeid, os.getpid()) + create_mark(wpr_path, msg) + + def pytest_runtest_logfinish(self, nodeid, location): + wpr_path = self.config.getoption('--wpr-path') + if not wpr_path: + return + msg = "{} ({}) - end".format(nodeid, os.getpid()) + create_mark(wpr_path, msg) + + +def pytest_configure(config): + if sys.platform != 'win32': + return + + if not config.getoption('--use-wpr'): + return + + config.pluginmanager.register(Plugin(config)) + + wpr_path = config.getoption('--wpr-path') + wpr_profiles = config.getoption('--wpr-profile') + + start_wpr(wpr_path, wpr_profiles) + + +def pytest_unconfigure(config): + if sys.platform != 'win32': + return + + if not config.getoption('--use-wpr'): + return + + wpr_path = config.getoption('--wpr-path') + wpr_output = config.getoption('--wpr-output') + + stop_wpr(wpr_path, wpr_output) + + +_name_re = re.compile(r"(?P.+?)::(?P.+?) \(.*\)$") + + +def current_test_name(): + try: + name = os.environ["PYTEST_CURRENT_TEST"] + except KeyError: + return "" + m = _name_re.match(name) + if not m: + raise RuntimeError( + "Could not extract test name from {}".format(name) + ) + return m.group("name") + + +def start_wpr(executable, profiles): + # type: (str, List[str]) -> None + args = [executable] + args.extend(chain.from_iterable(zip(repeat('-start'), profiles))) + subprocess.check_call(args) + + +def stop_wpr(executable, output_path): + # type: (str, str) -> None + subprocess.check_call([executable, '-stop', output_path]) + + +def create_mark(executable, message): + # type: (str, str) -> None + subprocess.check_call([executable, '-marker', message]) diff --git a/tools/requirements/tests.txt b/tools/requirements/tests.txt index 53601160b22..909f7140d32 100644 --- a/tools/requirements/tests.txt +++ b/tools/requirements/tests.txt @@ -3,6 +3,7 @@ mock pretend pytest==3.8.2 pytest-cov +pytest-custom_exit_code # Prevent installing 7.0 which has install_requires "pytest >= 3.10". pytest-rerunfailures<7.0 pytest-timeout diff --git a/wpr-result-37.etl b/wpr-result-37.etl new file mode 100644 index 00000000000..e18ae692bb3 Binary files /dev/null and b/wpr-result-37.etl differ