Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR Microsoft.Azure.Management.Billing] Remove billingProfile from PartnerLed transfer APIs. #44

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fe16a5a
Add pull config
Aug 7, 2019
d7314fe
[Datafactory] Enable Avro Dataset in SDK (#7112)
yuzhangyi Aug 7, 2019
843b460
Bump up SDK version (#7152)
serkantkaraca Aug 7, 2019
fc70a18
Expose storage path on Task and Job OutputStorage (#7146)
matthchr Aug 7, 2019
c55db6e
Change TestUtility.cs and add EventHubScope
Jul 29, 2019
54703c0
Track One Event Hubs Tests Infrastructure Updates
Jul 30, 2019
91769b8
Track One Event Hubs Tests Infrastructure Updates
Jul 30, 2019
9c4e740
11111111
Jul 30, 2019
19cb91e
Update TestUtility.cs
tzhanl Jul 30, 2019
6f7ac7e
Update EventHubScope.cs
tzhanl Jul 30, 2019
1166b55
Track One Event Hubs Processor Live Tests Updates
Jul 30, 2019
2b426ad
remove comments
tzhanl Jul 31, 2019
ee7ec42
Track One Event Hubs Tests Infrastructure Updates
Luyunmt Aug 1, 2019
0d0bf5e
Update ProcessorTestBase.cs
tzhanl Aug 1, 2019
f6aec13
Update for Clienttest
wantedfast Aug 1, 2019
501a5c9
Update the WebSocketTest
wantedfast Aug 1, 2019
5c12631
Update the method name
wantedfast Aug 1, 2019
f1fd0a3
update
wantedfast Aug 1, 2019
8634fdf
Modified Client Tests
Aug 1, 2019
356f468
Update style
tzhanl Aug 1, 2019
cb77582
add attribute [LiveTest]
Luyunmt Aug 2, 2019
8eabda3
Track one Test update
Luyunmt Aug 6, 2019
f15f04b
add back live test
tzhanl Aug 6, 2019
5a7c90d
add back live test
tzhanl Aug 6, 2019
5b97864
remove space
tzhanl Aug 7, 2019
8e54f70
Merge pull request #8 from Azure/master
pull[bot] Aug 7, 2019
342964d
Shorten diagnostics event names (#7186)
serkantkaraca Aug 8, 2019
f049e02
Rename KeyVault secret ReadMe (#7205)
chidozieononiwu Aug 8, 2019
0a2921e
Update Microsoft.Azure.Management.Subscription.csproj (#7195)
navysingla Aug 8, 2019
88ebfb6
Add support for azure mysql sink (#7207)
xiaoyingQQ Aug 8, 2019
0f29499
Generate new compute import for SDK (#7087)
szimmer-dev Aug 8, 2019
6681b14
Regenerate Batch Management SDK (#7168)
matthchr Aug 8, 2019
eeca153
Generated code for 2019-07-01 version of Microsoft.Resources swagger.…
Tiano2017 Aug 8, 2019
403c86e
move autorest metadata to right place (#7076)
erich-wang Aug 8, 2019
81d0699
[Event Hubs Client] Track Two: Second Preview (ReadMe Instructions)
jsquire Aug 8, 2019
1366d12
Remove accidentally added .binlog file (#7213)
pakrym Aug 8, 2019
2e5f9c6
[Event Hubs Client] Track Two: Second Preview (.NET Core 3 Fix) …
jsquire Aug 8, 2019
4d299ff
Limit SemaphoreSlim concurrency to 1 (#7203)
serkantkaraca Aug 8, 2019
19c940f
Safe-Close AMQP session when link creation fails (#7216)
serkantkaraca Aug 8, 2019
182061b
[Event Hubs Client] Track One: Diagnostic Test Fixes
jsquire Aug 8, 2019
68e67bc
Adding challenge based auth support for keyvault clients (#6620)
schaabs Aug 8, 2019
f13dc27
Updating version to 4.0.0 and adding changelog (#7088)
nemakam Aug 8, 2019
eba077b
[Event Hubs Client] Track Two: Samples (Consume Events With Event Pro…
kinelski Aug 8, 2019
64b1157
A nebadr/add roles to luis authoring (#6955)
nebadr Aug 8, 2019
7839e7d
[Azure search] Expose new skills, recursive inputs for shaper skill a…
arv100kri Aug 8, 2019
39a7efd
[Event Hubs Client] Track Two: Second Preview (Test Metadata) …
jsquire Aug 8, 2019
57e2255
Adding new EPH constructor (#7201)
serkantkaraca Aug 8, 2019
b22a9e3
Concurrency supported in Smoke Tests (#7169)
JonathanCrd Aug 8, 2019
a24f879
Add exception error level (#7194)
serkantkaraca Aug 8, 2019
5a5ca8c
[Azure Search] Add URL encode + decode field mapping functions (#7126)
arv100kri Aug 8, 2019
212b717
Add Track 2 Test Framework doc (#7228)
pakrym Aug 9, 2019
ee8678c
Update SourceLink Package (#7226)
chidozieononiwu Aug 9, 2019
975a040
Generated from abcb289f2ad4e9326be3301a79ad01e0a44f1e05
Aug 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://github.com/wei/pull#advanced-setup-with-config
version: "1"
rules:
- base: master
upstream: Azure:master
mergeMethod: rebase
label: "AutoPull"
191 changes: 191 additions & 0 deletions Documentation/Track2TestFramework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Accquring TestFramework

To start using test framework import `sdk\core\Azure.Core\tests\TestFramework.props` into test `.csproj`:

``` xml
<Project Sdk="Microsoft.NET.Sdk">

...
<Import Project="..\..\..\core\Azure.Core\tests\TestFramework.props" />
...

</Project>

```

# Sync-async tests

The test framework provides an ability to write test using async client methods and automatically run them using sync overloads. To write sync-async client tests inherit from `ClientTestBase` class and use `InstrumentClient` method call to wrap client into a proxy class that would automatically forward async calls to their sync overloads.

``` C#
public class ConfigurationLiveTests: ClientTestBase
{
public ConfigurationLiveTests(bool isAsync) : base(isAsync)
{
}

private ConfigurationClient GetClient()
{
return InstrumentClient(new ConfigurationClient(...));
}

public async Task DeleteSettingNotFound()
{
ConfigurationClient service = GetClient();

var response = await service.DeleteAsync("Setting");

Assert.AreEqual(204, response.Status);
response.Dispose();
}
}
```

In the test explorer async tests would display as `TestClassName(true)` and sync tests as `TestClassName(false)`.

When using sync-async tests with recorded tests two sessions files would get generated async test session would have `Async.json` suffix.

You can disable the sync-forwarding for an individual test by applying the `[AsyncOnly]` attribute to the test method.


__Limitation__: all method calls/properties that are being used have to be `virtual`.

# Recorded tests

Test framework provides an ability to record HTTP requests and responses and replay them for offline test runs.

To use recorded test functionality inherit from `RecordedTestBase` class and use `Recording.InstrumentClientOptions` method when creating the client instance.


``` C#
public class ConfigurationLiveTests: RecordedTestBase
{
public ConfigurationLiveTests(bool isAsync) : base(isAsync)
{
}

private ConfigurationClient GetClient()
{
return InstrumentClient(
new ConfigurationClient(
...,
Recording.InstrumentClientOptions(new ConfigurationClientOptions())));
}

public async Task DeleteSettingNotFound()
{
ConfigurationClient service = GetClient();

var response = await service.DeleteAsync("Setting");

Assert.AreEqual(204, response.Status);
response.Dispose();
}
}
```

By default tests are run in playback mode. To change the mode use `AZURE_TEST_MODE` environment variable and set it to one of the followind values: `Live`, `Playback`, `Record`.

In development scenarios where it's required to change mode quickly without restarting the Visual Studio use the two-parameter constructor of `RecordedTestBase` to change the mode:

``` C#
public class ConfigurationLiveTests: RecordedTestBase
{
public ConfigurationLiveTests(bool isAsync) : base(isAsync, RecordedTestMode.Record)
{
}
}
```

## Recording

When tests are run in recording mode session records are being saved to `artifacts/bin/<ProjectName>/<TargetFramework>/SessionRecords` directory. You can copy recordings to the project directory manually or by executing `dotnet msbuild /t:UpdateSessionRecords` in the test project directory.

__NOTE:__ recordings are copied from `netcoreapp2.1` directory by default, make sure you are running the right target framework.

## Sanitizing

Secrets that are part of requests, responses, headers or connections strings should be sanitized before saving the record. Common headers like `Authentication` are sanitized automatically but if custom logic is required `RecordedTest.Sanitizer` should be used as extension point.

For example:

``` C#
public class ConfigurationRecordedTestSanitizer : RecordedTestSanitizer
{
public override void SanitizeConnectionString(ConnectionString connectionString)
{
const string secretKey = "secret";

if (connectionString.Pairs.ContainsKey(secretKey))
{
connectionString.Pairs[secretKey] = "";
}
}
}

public class ConfigurationLiveTests: RecordedTestBase
{
public ConfigurationLiveTests(bool isAsync) : base(isAsync)
{
Sanitizer = new ConfigurationRecordedTestSanitizer();
}
}
```

## Matching

When tests are ran in replay mode HTTP method, uri and headers are used to match request to response. Some headers change on every request and are not controlled by the client code and should be ignored during the matching. Common headers like `Date`, `x-ms-date`, `x-ms-client-request-id`, `User-Agent`, `Request-Id` are ignored by default but if more headers need to be ignored use `Recording.Matcher` extensions point.


``` C#
public class ConfigurationRecordMatcher : RecordMatcher
{
public ConfigurationRecordMatcher(RecordedTestSanitizer sanitizer) : base(sanitizer)
{
ExcludeHeaders.Add("Sync-Token");
}
}

public class ConfigurationLiveTests: RecordedTestBase
{
public ConfigurationLiveTests(bool isAsync) : base(isAsync)
{
Sanitizer = new ConfigurationRecordedTestSanitizer();
Matcher = new ConfigurationRecordMatcher(Sanitizer);
}
}
```
## TokenCredential

If test uses `TokenCredential` to construct the client use `Recording.GetCredential(...)` to wrap it:

``` C#
public abstract class KeysTestBase : RecordedTestBase
{
internal KeyClient GetClient()
{
return InstrumentClient
(new KeyClient(
new Uri(recording.GetVariableFromEnvironment(AzureKeyVaultUrlEnvironmentVariable)),
/* --------> */ recording.GetCredential(new DefaultAzureCredential()),
recording.InstrumentClientOptions(new KeyClientOptions())));
}
}

```

## Misc

You can use `Recording.GenerateId()` to generate repeatable random IDs.

You should only use `Recording.Random` for random values (and you MUST make the same number of random calls in the same order every test run)

You can use `Recording.Now` and `Recording.UtcNow` if you need certain values to capture the time the test was recorded

It's possible to add additional recording variables for advanced scenarios (like custom test configuration, etc.) but using `Recording.GetVariableFromEnvironment`, `Recording.GetVariable` or `Recording.GetConnectionStringFromEnvironment`.

You can use `if (Mode == RecordingMode.Playback) { ... }` to change behavior for playback only scenarios (in particular to make polling times instantaneous)

You can use `using (Recording.DisableRecording()) { ... }` to disable recording in the code block (useful for polling methods)


2 changes: 1 addition & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<PackageReference Update="Microsoft.ServiceFabric.Data" Version="3.3.624" />
<PackageReference Update="Microsoft.ServiceFabric.Services" Version="3.3.624" />
<PackageReference Update="Microsoft.ServiceFabric" Version="6.4.624" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19351-01" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
<PackageReference Update="Microsoft.Spatial" Version="7.5.3" />
<PackageReference Update="Microsoft.VisualStudio.TextTemplating.14.0" Version="14.3.25407" />
<PackageReference Update="Moq" Version="4.10.1" />
Expand Down
14 changes: 14 additions & 0 deletions eng/mgmt/mgmtmetadata/batch_resource-manager.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installing AutoRest version: latest
AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/batch/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\work\github\azure-sdk-for-net\sdk
2019-08-07 15:41:13 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: ad759850354ddb7b4ffea0a49b70243fd9ec5a42
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4283
6 changes: 3 additions & 3 deletions eng/mgmt/mgmtmetadata/compute_resource-manager.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/compute/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=E:\hylee-sdk\july2\sdk
2019-07-18 00:16:54 UTC
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/compute/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=G:\Code\azure-sdk-for-net\sdk
2019-08-02 00:21:49 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 6b6a445819212313e466b2f77f8b3e6d4f9d18fb
Commit: ab88105b1fd4d8b982869c43b1fbf365f24fc0af
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4283
6 changes: 3 additions & 3 deletions eng/mgmt/mgmtmetadata/datafactory_resource-manager.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/datafactory/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --tag=package-2018-06 --csharp-sdks-folder=D:\Git\AdmsSdkChange\sdk
2019-08-07 01:45:14 UTC
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/datafactory/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --tag=package-2018-06 --csharp-sdks-folder=C:\Users\xiaoyz\Source\Repos\azure-sdk-for-net-wenbo\sdk
2019-08-07 02:33:49 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 694f153a2f2eb22fdab6035ba9dc9eaaf375a386
Commit: f80a6c182c85879a415d4c668473c592147416f3
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4283
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/search/data-plane/Microsoft.Azure.Search.Service/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=D:\src\azure-sdk-for-net\sdk
2019-08-01 17:40:34 UTC
2019-08-08 17:18:20 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 39c47bb0623a056d760175c63688d688e0020faa
Commit: 397e41997764b35729dd4f39ec80a0f98c4456eb
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4283
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/BlobStorageTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Storage.Blobs;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Storage.Blobs;
using System;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -27,7 +31,7 @@ public static async Task RunTests()

string connectionString = Environment.GetEnvironmentVariable("BLOB_CONNECTION_STRING");
string containerName = "mycontainer"; //The container must exists, this sample is not creating it.
string blobName = "netSmokeTestBlob";
string blobName = $"netSmokeTestBlob-{Guid.NewGuid()}.txt";
serviceClient = new BlobServiceClient(connectionString);
blobClient = serviceClient.GetBlobContainerClient(containerName).GetBlockBlobClient(blobName);

Expand Down
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/CosmosDBTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Storage.Blobs.Models;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Storage.Blobs.Models;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Newtonsoft.Json;
Expand Down Expand Up @@ -34,7 +38,7 @@ public class Moon
class CosmosDBTest
{
private static DocumentClient client;
private const string DataBaseName = "netSolarSystemDB";
private static string DataBaseName = $"netSolarSystemDB-{Guid.NewGuid()}";
private const string CollectionName = "PlanetsCollection";
private static List<Planet> planets = new List<Planet>();

Expand Down
29 changes: 7 additions & 22 deletions samples/SmokeTest/SmokeTest/EventHubsTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure;
using Azure.Messaging.EventHubs;
using Microsoft.Azure.Amqp.Framing;
using System;
Expand Down Expand Up @@ -79,35 +83,16 @@ private static async Task SendAndReceiveEvents()
{
receivedEvents.AddRange(await receiver.ReceiveAsync(eventBatch.Length + 10, TimeSpan.FromMilliseconds(25)));
}
index = 0;

//Check if at least one event was received in order to start validation
if (receivedEvents.Count == 0)
{
throw new Exception(String.Format("Error, No events received."));
}
Console.Write(receivedEvents.Count() + " events received.\n");

Console.WriteLine("Beginning validation...");
foreach (var receivedEvent in receivedEvents)
if (receivedEvents.Count() < eventBatch.Count())
{
var receivedEventMessage = Encoding.UTF8.GetString(receivedEvent.Body.ToArray());
var sentEventMessage = Encoding.UTF8.GetString(eventBatch[index].Body.ToArray());

if (receivedEventMessage == sentEventMessage)
{
Console.WriteLine("\tEvent '" + receivedEventMessage + "' correctly validated.");
}
else
{
throw new Exception(String.Format("Error, Event: '" + receivedEventMessage + "' was not expected."));
}
index++;
}

if (index < eventBatch.Count())
{
throw new Exception(String.Format("Error, expecting " + eventBatch.Count().ToString() + " events, but only got " + index.ToString() + "."));
throw new Exception(String.Format($"Error, expecting {eventBatch.Count()} events, but only got {receivedEvents.Count().ToString()}."));
}

Console.WriteLine("done");
Expand Down
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/KeyVaultTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Identity;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using System;
using System.Threading.Tasks;
Expand All @@ -7,7 +11,7 @@ namespace SmokeTest
{
class KeyVaultTest
{
private const string SecretName = "SmokeTestSecret";
private static string SecretName = $"SmokeTestSecret-{Guid.NewGuid()}";
private const string SecretValue = "smokeTestValue";
private static SecretClient client;

Expand Down
7 changes: 6 additions & 1 deletion samples/SmokeTest/SmokeTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Azure.Messaging.EventHubs;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
// ------------------------------------
using Azure.Messaging.EventHubs;
using System;
using System.Reflection.Metadata;
using System.Threading.Tasks;
Expand Down
Loading