Skip to content

Commit 18a781f

Browse files
committed
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python into webpubsub-review-2021-10-25
* 'main' of https://github.com/Azure/azure-sdk-for-python: (99 commits) Add Mixed Reality Remote Rendering SDK (#16643) [AutoRelease] t2-monitor-2021-11-03-63776 (#21559) Latest API(2021-10-31-preview) changes implementation in azure-communication-identity (#21331) [AutoRelease] t2-eventgrid-2021-10-21-28743 (#21361) STG79 Preview (#21591) delete redundant network version (#21612) [WebPubSub] Use consistent service description and introduction across all languages (#21544) [formrecognizer] Remove get children methods (#21602) [SchemaRegistry] generate GA SR from swagger (#21570) [SchemaRegistry] update core + SR version (#21573) update changelog (#21608) Revert "Update azure-core version to unbreak Search. (#21599)" (#21610) [acr] regen with autorest 5.11.0, bump min core dep to 1.20.0 (#21600) Update azure-core version to unbreak Search. (#21599) [formrecognizer] Update changelog for release (#21555) update type hints to reflect actual document body (#21593) Increment package version after release of azure-core (#21594) adding exception to regression tests for telemetry-exporter (#21576) [SchemaRegistry] final api review changes (#21589) Add prompt before replasing latest release title on prepare release run (#21579) ...
2 parents 3948eb4 + ddcd001 commit 18a781f

File tree

2,558 files changed

+168331
-343364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,558 files changed

+168331
-343364
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
This file claims the rules how Python decide next version number for package.
2+
3+
The package version contains two part:
4+
1. the package is preview or stable?
5+
2. version number
6+
7+
# How to judge preview or stable?
8+
Python SDK is generated with [swagger](https://github.com/Azure/azure-rest-api-specs), so if swagger content is preview,
9+
the package is preview; if swagger content is stable, the package is stable.
10+
11+
(1) For single api package(for example: [datadog](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/datadog)),
12+
as long as the current tag is preview, the package version should be preview
13+
14+
(2) For multi api package(for example: [network](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/network/azure-mgmt-network)),
15+
there will be `DEFAULT_API_VERSION`(for example: [`DEFAULT_API_VERSION` of network](https://github.com/Azure/azure-sdk-for-python/blob/59709af16b7cd29a51d562137bc5bbfdf53f9327/sdk/network/azure-mgmt-network/azure/mgmt/network/_network_management_client.py#L60)).
16+
As long as it is preview, then the package version is preview.
17+
18+
(note1: If the name of tag contains 'preview' or the tag contains files of 'preview' folder, then the tag is preview tag.
19+
For exampe: [preview tag](https://github.com/Azure/azure-rest-api-specs/tree/main/specification/compute/resource-manager#tag-package-2021-06-01-preview))
20+
21+
(note2: If the api-version contains 'preview', then it is preview api-version. for example: [preview api-version](https://github.com/Azure/azure-rest-api-specs/blob/69eacf00a36d565d3220d5dd6f4a5293664f1ae9/specification/network/resource-manager/Microsoft.Network/preview/2015-05-01-preview/network.json#L6))
22+
23+
(note3: The difference about single api and multi api, please see the detailed file)
24+
25+
(note4: preview package version contains `b`, for example: `1.0.0b1`)
26+
27+
# How to decide next version number
28+
1\. If current version is preview version, the new tag is preview tag, then next version is `x.x.xbx+1`
29+
30+
2\. If current version is stable version, the new tag is stable tag, then :
31+
* if there is breaking change, next version is `x+1.x.x`
32+
* if there is new feature but no breaking change, next version is `x.x+1.x`
33+
* if there is only bugfix, next version is `x.x.x+1`
34+
35+
3\. If current version is stable version, the new tag is preview tag, calculate version number according to `2`
36+
and then append `b1` in the result
37+
38+
39+
According to the up rules, we could summarize all the possibilities in the following table:
40+
41+
![img.png](version_summary.png)
42+
43+
(`-` means that this item doesn't influence result)
44+
11.1 KB
Binary file not shown.
14.2 KB
Loading

doc/dev/test_proxy_migration_guide.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ class TestExample(AzureTestCase):
2828
### New test structure
2929

3030
To use the proxy, test classes should inherit from AzureRecordedTestCase and recorded test methods should use a
31-
RecordedByProxy decorator:
31+
`recorded_by_proxy` decorator:
3232

3333
```py
34-
from devtools_testutils import AzureRecordedTestCase, RecordedByProxy
34+
from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy
3535

3636
class TestExample(AzureRecordedTestCase):
3737

38-
@RecordedByProxy
38+
@recorded_by_proxy
3939
def test_example(self):
4040
...
4141

4242
@ExamplePreparer()
43-
@RecordedByProxy
43+
@recorded_by_proxy
4444
def test_example_with_preparer(self):
4545
...
4646
```
4747

48-
For async tests, import the RecordedByProxyAsync decorator from `devtools_testutils.aio` and use it in the same
49-
way as RecordedByProxy.
48+
For async tests, import the `recorded_by_proxy_async` decorator from `devtools_testutils.aio` and use it in the same
49+
way as `recorded_by_proxy`.
5050

5151
> **Note:** since AzureRecordedTestCase doesn't inherit from `unittest.TestCase`, test class names need to start
5252
> with "Test" in order to be properly collected by pytest by default. For more information, please refer to
@@ -135,6 +135,43 @@ made to `https://fakeendpoint-secondary.table.core.windows.net`, and URIs will a
135135

136136
For more details about sanitizers and their options, please refer to [devtools_testutils/sanitizers.py][py_sanitizers].
137137

138+
### Record test variables
139+
140+
To run recorded tests successfully when there's an element of non-secret randomness to them, the test proxy provides a
141+
[`variables` API](https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy#storing-variables).
142+
This makes it possible for a test to record the values of variables that were used during recording and use the same
143+
values in playback mode without a sanitizer.
144+
145+
For example, imagine that a test uses a randomized `table_name` variable when creating resources. The same random value
146+
for `table_name` can be used in playback mode by using this `variables` API.
147+
148+
There are two requirements for a test to use recorded variables. First, the test method should accept `**kwargs` and/or
149+
a `variables` parameter. Second, the test method should `return` a dictionary with any test variables that it wants to
150+
record. This dictionary will be stored in the recording when the test is run live, and will be passed to the test as a
151+
`variables` keyword argument when the test is run in playback.
152+
153+
Below is a code example of how a test method could use recorded variables:
154+
155+
```python
156+
from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy
157+
158+
class TestExample(AzureRecordedTestCase):
159+
160+
@recorded_by_proxy
161+
def test_example(self, variables):
162+
# in live mode, variables is an empty dictionary
163+
# in playback mode, the value of variables is {"table_name": "random-value"}
164+
if self.is_live:
165+
table_name = "random-value"
166+
variables = {"table_name": table_name}
167+
168+
# use variables["table_name"] when using the table name throughout the test
169+
...
170+
171+
# return the variables at the end of the test
172+
return variables
173+
```
174+
138175
## Implementation details
139176

140177
### What does the test proxy do?
@@ -147,7 +184,7 @@ For example, if an operation would typically make a GET request to
147184
`https://localhost:5001/Tables` instead. The original endpoint should be stored in an `x-recording-upstream-base-uri` --
148185
the proxy will send the original request and record the result.
149186

150-
The RecordedByProxy and RecordedByProxyAsync decorators patch test requests to do this for you.
187+
The `recorded_by_proxy` and `recorded_by_proxy_async` decorators patch test requests to do this for you.
151188

152189
### How does the test proxy know when and what to record or play back?
153190

@@ -179,7 +216,7 @@ Running tests in playback follows the same pattern, except that requests will be
179216
`/playback/stop` instead. A header, `x-recording-mode`, should be set to `record` for all requests when recording and
180217
`playback` when playing recordings back. More details can be found [here][detailed_docs].
181218

182-
The RecordedByProxy and RecordedByProxyAsync decorators send the appropriate requests at the start and end of each test
219+
The `recorded_by_proxy` and `recorded_by_proxy_async` decorators send the appropriate requests at the start and end of each test
183220
case.
184221

185222
[detailed_docs]: https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md

eng/common/TestResources/New-TestResources.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ try {
334334
$serviceName = if (Split-Path $ServiceDirectory) {
335335
Split-Path -Leaf $ServiceDirectory
336336
} else {
337-
$ServiceDirectory
337+
$ServiceDirectory.Trim('/')
338338
}
339339

340340
$ResourceGroupName = if ($ResourceGroupName) {
@@ -600,7 +600,7 @@ try {
600600
$outputFile = "$($templateFile.originalFilePath).env"
601601

602602
$environmentText = $deploymentOutputs | ConvertTo-Json;
603-
$bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText)
603+
$bytes = [System.Text.Encoding]::UTF8.GetBytes($environmentText)
604604
$protectedBytes = [Security.Cryptography.ProtectedData]::Protect($bytes, $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)
605605

606606
Set-Content $outputFile -Value $protectedBytes -AsByteStream -Force
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parameters:
2+
- name: ContainerRegistryClientId
3+
type: string
4+
- name: ContainerRegistryClientSecret
5+
type: string
6+
- name: ImageId
7+
type: string
8+
steps:
9+
- pwsh: |
10+
$containerRegistry = ("${{parameters.ImageId}}" -split "\/")[0]
11+
docker login $containerRegistry -u "${{ parameters.ContainerRegistryClientId }}" -p "${{ parameters.ContainerRegistryClientSecret }}"
12+
displayName: Login container registry
13+
- pwsh: |
14+
docker pull '${{ parameters.ImageId}}'
15+
displayName: Pull docker image ${{ parameters.ImageId }}

eng/common/pipelines/templates/steps/sparse-checkout.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ steps:
3838
} else {
3939
Write-Host "Repository $($repository.Name) is being initialized."
4040
41-
Write-Host "git clone --no-checkout --filter=tree:0 git://github.com/$($repository.Name) ."
42-
git clone --no-checkout --filter=tree:0 git://github.com/$($repository.Name) .
41+
Write-Host "git clone --no-checkout --filter=tree:0 https://github.com/$($repository.Name) ."
42+
git clone --no-checkout --filter=tree:0 https://github.com/$($repository.Name) .
4343
4444
Write-Host "git sparse-checkout init"
4545
git sparse-checkout init

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,15 @@ function Remove-EmptySections {
351351
}
352352
$ChangeLogEntry.ReleaseContent = $sanitizedReleaseContent.ToArray()
353353
}
354+
}
355+
356+
function Get-LatestReleaseDateFromChangeLog
357+
{
358+
param (
359+
[Parameter(Mandatory = $true)]
360+
$ChangeLogLocation
361+
)
362+
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
363+
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
364+
return ($latestVersion -as [DateTime])
354365
}

eng/common/scripts/Invoke-GitHubAPI.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,36 @@ function New-GitHubPullRequest {
157157
-MaximumRetryCount 3
158158
}
159159

160+
function New-GitHubIssue {
161+
param (
162+
[Parameter(Mandatory = $true)]
163+
$RepoOwner,
164+
[Parameter(Mandatory = $true)]
165+
$RepoName,
166+
[Parameter(Mandatory = $true)]
167+
$Title,
168+
[Parameter(Mandatory = $true)]
169+
$Description,
170+
[ValidateNotNullOrEmpty()]
171+
[Parameter(Mandatory = $true)]
172+
$AuthToken
173+
)
174+
175+
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues"
176+
177+
$parameters = @{
178+
title = $Title
179+
body = $Description
180+
}
181+
182+
return Invoke-RestMethod `
183+
-Method POST `
184+
-Body ($parameters | ConvertTo-Json) `
185+
-Uri $uri `
186+
-Headers (Get-GitHubApiHeaders -token $AuthToken) `
187+
-MaximumRetryCount 3
188+
}
189+
160190
function Add-GitHubIssueComment {
161191
param (
162192
[Parameter(Mandatory = $true)]

eng/common/scripts/Prepare-Release.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ else
109109
$releaseDateString = $ParsedReleaseDate.ToString("MM/dd/yyyy")
110110
$month = $ParsedReleaseDate.ToString("MMMM")
111111

112-
Write-Host
113112
Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green
113+
if (Test-Path "Function:GetExistingPackageVersions")
114+
{
115+
$releasedVersions = GetExistingPackageVersions -PackageName $packageProperties.Name -GroupId $packageProperties.Group
116+
$latestReleasedVersion = $releasedVersions[$releasedVersions.Count - 1]
117+
Write-Host "Latest released version: ${latestReleasedVersion}" -ForegroundColor Green
118+
}
114119

115120
$currentProjectVersion = $packageProperties.Version
116-
117121
$newVersion = Read-Host -Prompt "Input the new version, or press Enter to use use current project version '$currentProjectVersion'"
118122

119123
if (!$newVersion)
@@ -173,8 +177,17 @@ if ($releaseTrackingOnly)
173177

174178
if (Test-Path "Function:SetPackageVersion")
175179
{
176-
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion -ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
177-
-PackageProperties $packageProperties
180+
$replaceLatestEntryTitle = $true
181+
$latestVersion = Get-LatestReleaseDateFromChangeLog -ChangeLogLocation $packageProperties.ChangeLogPath
182+
if ($latestVersion)
183+
{
184+
$promptMessage = "The latest entry in the CHANGELOG.md already has a release date. Do you want to replace the latest entry title? Please enter (y or n)."
185+
while (($readInput = Read-Host -Prompt $promptMessage) -notmatch '^[yn]$'){ }
186+
$replaceLatestEntryTitle = ($readInput -eq "y")
187+
}
188+
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion `
189+
-ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
190+
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle
178191
}
179192
else
180193
{

0 commit comments

Comments
 (0)