-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathsmoke-test-steps.yml
118 lines (102 loc) · 4.42 KB
/
smoke-test-steps.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
parameters:
- name: Daily
default: true
- name: Artifact
type: object
default: {}
- name: ArtifactName
type: string
default: "not-specified"
steps:
- task: UsePythonVersion@0
displayName: "Use Python $(PythonVersion)"
inputs:
versionSpec: $(PythonVersion)
- script: |
python -m pip install pip==20.0.2
pip --version
displayName: pip --version
- ${{ if eq(parameters.Daily, false) }}:
- download: current
artifact: ${{ parameters.ArtifactName }}
timeoutInMinutes: 5
- pwsh: |
$packages = Get-ChildItem "$(Pipeline.Workspace)/${{ parameters.ArtifactName }}/${{ parameters.Artifact.name }}/*.tar.gz"
Write-Host "Artifacts found:"
$artifacts = $packages | ForEach-Object {
if ($_.Name -match "([a-zA-Z\-_]+)\-(.*).tar.gz") {
Write-Host "$($matches[1]): $($matches[2])"
return @{ "name" = $matches[1].ToString().Replace("_", "-"); "version" = $matches[2] }
}
}
if ($artifacts.name -notcontains "${{parameters.Artifact.name}}") {
Write-Host "Can't find package ${{parameters.Artifact.name}}"
exit 1
}
$dependencies = Get-Content $(requirements) | ForEach-Object {
$line = $_
if ($line -match "([a-zA-Z\-]+)(\W+)(.*)") {
$override = ($artifacts | Where-Object { $_.Name -eq $matches[1] }).Version
if ($override) {
$line = $line -replace '([a-zA-Z\-]+)(\W+)(.*)', ('${1}${2}' + $override)
Write-Host "Overriding dependency to: $line"
}
}
return $line
}
$dependencies | Out-File $(requirements)
displayName: Override requirements with pipeline build artifact versions
# Retry for pip install due to delay in package availability after publish
# The package is expected to be available for download/installation within 10 minutes
- pwsh: |
$ErrorActionPreference = "Continue"
while ($retries++ -lt 15) {
Write-Host "python -m pip install -r $(requirements) --no-deps --upgrade --no-cache-dir"
python -m pip install -r "$(requirements)" --no-deps --upgrade --no-cache-dir
if ($LASTEXITCODE) {
if ($retries -ge 15) {
exit $LASTEXITCODE
}
Write-Host "Installation failed, retrying in 1 minute..."
sleep 60
} else {
break
}
}
displayName: Install requirements without dependencies
- ${{ if eq(parameters.Daily, true) }}:
- pwsh: |
python -m pip install -r "$(requirements)" --pre --no-deps --upgrade `
--index-url https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple
displayName: Install requirements from dev feed without dependencies
- pwsh: python -m pip install -r $(Build.SourcesDirectory)/common/smoketest/requirements_async.txt
displayName: "Install requirements_async.txt"
condition: and(succeeded(), ne(variables['SkipAsyncInstall'], true))
- pwsh: |
python $(Build.SourcesDirectory)/common/smoketest/dependencies.py -r "$(requirements)" `
| Out-File $(Build.SourcesDirectory)/common/smoketest/requirements_dependencies.txt
displayName: Create dependency list from installed packages
- script: python -m pip install -r $(Build.SourcesDirectory)/common/smoketest/requirements_dependencies.txt
displayName: Install package dependencies from PyPI
- script: python -m pip freeze
displayName: Show installed packages (pip freeze)
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
ServiceDirectory: '$(Build.SourcesDirectory)/common/smoketest/'
ServiceConnection: azure-sdk-tests-public
- task: AzurePowerShell@5
displayName: Run Smoke Tests
env:
# Enable samples tests that use DefaultAzureCredential to load the federated pipeline credential
AZURE_POD_IDENTITY_AUTHORITY_HOST: 'FakeAuthorityHost'
inputs:
azureSubscription: azure-sdk-tests-public
azurePowerShellVersion: LatestVersion
pwsh: true
ScriptType: InlineScript
Inline: >-
python $(Build.SourcesDirectory)/common/smoketest/program.py
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: '$(Build.SourcesDirectory)/common/smoketest/'
ServiceConnection: azure-sdk-tests-public