From 7ba6980da4a086c963912c0a8cc51652552f85dc Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 07:59:04 -0700 Subject: [PATCH 01/16] Adding log lines --- .../SynchronizationContextTests.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index 7721c41e7b..0a0e65dcf0 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests using System.Linq; using System.Threading; using Microsoft.Azure.Cosmos.Linq; + using Microsoft.Azure.Cosmos.Services.Management.Tests; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] @@ -27,28 +28,29 @@ public void VerifySynchronizationContextDoesNotLock() { using (CosmosClient client = TestCommon.CreateCosmosClient()) { + Logger.LogLine("1"); Cosmos.Database database = client.CreateDatabaseAsync(databaseId).GetAwaiter().GetResult(); database = client.CreateDatabaseIfNotExistsAsync(databaseId).GetAwaiter().GetResult(); database.ReadStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); database.ReadAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - + Logger.LogLine("2"); QueryDefinition databaseQuery = new QueryDefinition("select * from T where T.id = @id").WithParameter("@id", databaseId); FeedIterator databaseIterator = client.GetDatabaseQueryIterator(databaseQuery); while (databaseIterator.HasMoreResults) { databaseIterator.ReadNextAsync().GetAwaiter().GetResult(); } - + Logger.LogLine("3"); Container container = database.CreateContainerAsync(Guid.NewGuid().ToString(), "/pk").GetAwaiter().GetResult(); container = database.CreateContainerIfNotExistsAsync(container.Id, "/pk").GetAwaiter().GetResult(); - + Logger.LogLine("4"); ToDoActivity testItem = ToDoActivity.CreateRandomToDoActivity(); ItemResponse response = container.CreateItemAsync(item: testItem).ConfigureAwait(false).GetAwaiter().GetResult(); Assert.IsNotNull(response); string diagnostics = response.Diagnostics.ToString(); Assert.IsTrue(diagnostics.Contains("Synchronization Context")); - + Logger.LogLine("5"); using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); try @@ -65,7 +67,7 @@ public void VerifySynchronizationContextDoesNotLock() string exception = oe.ToString(); Assert.IsTrue(exception.Contains("Synchronization Context")); } - + Logger.LogLine("6"); // Test read feed container.GetItemLinqQueryable( allowSynchronousQueryExecution: true, @@ -81,7 +83,7 @@ public void VerifySynchronizationContextDoesNotLock() { feedIterator.ReadNextAsync().GetAwaiter().GetResult(); } - + Logger.LogLine("7"); FeedIterator feedIteratorTyped = container.GetItemLinqQueryable() .ToFeedIterator(); @@ -89,7 +91,7 @@ public void VerifySynchronizationContextDoesNotLock() { feedIteratorTyped.ReadNextAsync().GetAwaiter().GetResult(); } - + Logger.LogLine("8"); // Test query container.GetItemLinqQueryable( allowSynchronousQueryExecution: true, @@ -105,6 +107,8 @@ public void VerifySynchronizationContextDoesNotLock() queryIterator.ReadNextAsync().GetAwaiter().GetResult(); } + Logger.LogLine("9"); + FeedIterator queryIteratorTyped = container.GetItemLinqQueryable() .Where(item => item.id != "").ToFeedIterator(); @@ -113,14 +117,17 @@ public void VerifySynchronizationContextDoesNotLock() queryIteratorTyped.ReadNextAsync().GetAwaiter().GetResult(); } + Logger.LogLine("10"); + double costAsync = container.GetItemLinqQueryable() .Select(x => x.cost).SumAsync().GetAwaiter().GetResult(); double cost = container.GetItemLinqQueryable( allowSynchronousQueryExecution: true).Select(x => x.cost).Sum(); - + Logger.LogLine("11"); ItemResponse deleteResponse = container.DeleteItemAsync(partitionKey: new Cosmos.PartitionKey(testItem.pk), id: testItem.id).ConfigureAwait(false).GetAwaiter().GetResult(); Assert.IsNotNull(deleteResponse); + Logger.LogLine("12"); } }, state: null); } From 64ded3660f38afe73f5d8dea380a1dbccd3000fe Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 09:11:18 -0700 Subject: [PATCH 02/16] More logs --- .../SynchronizationContextTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index 0a0e65dcf0..65f634656a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -30,9 +30,11 @@ public void VerifySynchronizationContextDoesNotLock() { Logger.LogLine("1"); Cosmos.Database database = client.CreateDatabaseAsync(databaseId).GetAwaiter().GetResult(); + Logger.LogLine("a"); database = client.CreateDatabaseIfNotExistsAsync(databaseId).GetAwaiter().GetResult(); - + Logger.LogLine("b"); database.ReadStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + Logger.LogLine("c"); database.ReadAsync().ConfigureAwait(false).GetAwaiter().GetResult(); Logger.LogLine("2"); QueryDefinition databaseQuery = new QueryDefinition("select * from T where T.id = @id").WithParameter("@id", databaseId); From 01061dbd0a550fa498bcb7e62f93cf99e9aa7ae9 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 09:54:54 -0700 Subject: [PATCH 03/16] Debugging further --- .../SynchronizationContextTests.cs | 8 + templates/build-test.yml | 150 +----------------- 2 files changed, 9 insertions(+), 149 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index 65f634656a..15b667c705 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -5,6 +5,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests { using System; + using System.Diagnostics; using System.Linq; using System.Threading; using Microsoft.Azure.Cosmos.Linq; @@ -14,10 +15,17 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests [TestClass] public class SynchronizationContextTests { + [TestCategory("TEST")] [TestMethod] [Timeout(30000)] public void VerifySynchronizationContextDoesNotLock() { + Type defaultTrace = Type.GetType("Microsoft.Azure.Cosmos.Core.Trace.DefaultTrace,Microsoft.Azure.Cosmos.Direct"); + TraceSource traceSource = (TraceSource)defaultTrace.GetProperty("TraceSource").GetValue(null); + traceSource.Switch.Level = SourceLevels.All; + traceSource.Listeners.Clear(); + traceSource.Listeners.Add(new ConsoleTraceListener()); + string databaseId = Guid.NewGuid().ToString(); SynchronizationContext prevContext = SynchronizationContext.Current; try diff --git a/templates/build-test.yml b/templates/build-test.yml index 3a016080e1..c94e117528 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -6,7 +6,7 @@ parameters: VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' EmulatorPipeline1Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & (TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal ' - EmulatorPipeline2Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" --verbosity normal ' + EmulatorPipeline2Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=TEST" ' EmulatorPipeline1CategoryListName: ' Query, ChangeFeed, ReadFeed, Batch ' # Divided in 2 categories to run them in parallel and reduce the PR feedback time EmulatorPipeline2CategoryListName: ' Others ' @@ -26,61 +26,6 @@ jobs: inputs: packageType: 'sdk' version: '6.x' - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Tests - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' - arguments: ${{ parameters.Arguments }} --configuration Debug /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true /p:OS=${{ parameters.OS }} - publishTestResults: true - nugetConfigPath: NuGet.config - testRunTitle: Microsoft.Azure.Cosmos.Tests - - script: | - dotnet tool install -g dotnet-reportgenerator-globaltool - reportgenerator -reports:$(Build.SourcesDirectory)/Microsoft.Azure.Cosmos/tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines;Cobertura - displayName: Create Code coverage report - - task: PublishCodeCoverageResults@1 - displayName: 'Publish code coverage' - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml' - reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage' - -- job: - displayName: PerformanceTests ${{ parameters.BuildConfiguration }} - pool: - vmImage: ${{ parameters.VmImage }} - - steps: - - checkout: self # self represents the repo where the initial Pipelines YAML file was found - clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching - - # Add this Command to Include the .NET 6 SDK - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.x' - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.PerformanceTests - Build - condition: succeeded() - inputs: - command: build - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/*.csproj' - arguments: -c Release - nugetConfigPath: NuGet.config - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.PerformanceTests - Run - condition: succeeded() - inputs: - command: run - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/*.csproj' - arguments: --configuration ${{ parameters.BuildConfiguration }} --no-restore --framework net6.0 --allCategories=GateBenchmark -- -j Short -m --BaselineValidation - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.PerformanceTests - job: displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline1CategoryListName }} @@ -112,96 +57,3 @@ jobs: nugetConfigPath: NuGet.config publishTestResults: true testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - -- job: - displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline2CategoryListName }} - timeoutInMinutes: 120 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - vmImage: ${{ parameters.VmImage }} - - steps: - - checkout: self # self represents the repo where the initial Pipelines YAML file was found - clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching - - # Add this Command to Include the .NET 6 SDK - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' - arguments: ${{ parameters.EmulatorPipeline2Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - -- job: - displayName: Encryption EmulatorTests ${{ parameters.BuildConfiguration }} - timeoutInMinutes: 90 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - vmImage: ${{ parameters.VmImage }} - - steps: - - checkout: self # self represents the repo where the initial Pipelines YAML file was found - clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching - - # Add this Command to Include the .NET 6 SDK - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Encryption.EmulatorTests - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos.Encryption/tests/EmulatorTests/*.csproj' - arguments: ${{ parameters.Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.Encryption.EmulatorTests - -- job: - displayName: Encryption.Custom EmulatorTests ${{ parameters.BuildConfiguration }} - timeoutInMinutes: 90 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - vmImage: ${{ parameters.VmImage }} - - steps: - - checkout: self # self represents the repo where the initial Pipelines YAML file was found - clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching - - # Add this Command to Include the .NET 6 SDK - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos.Encryption.Custom/tests/EmulatorTests/*.csproj' - arguments: ${{ parameters.Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests From c2afb581f560c6d90cc961ab462f1f03a05fb72b Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 09:59:07 -0700 Subject: [PATCH 04/16] Removing other builds --- azure-pipelines.yml | 45 +--------------------------------------- templates/build-test.yml | 6 ++---- 2 files changed, 3 insertions(+), 48 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 98490f0a62..9a8ad067d0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,51 +21,8 @@ variables: jobs: -- template: templates/static-tools.yml - parameters: - BuildConfiguration: Release - VmImage: $(VmImage) - -- template: templates/nuget-pack.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - ReleasePackage: false - OutputPath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/Release/Microsoft.Azure.Cosmos' - -- template: templates/build-ctl.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - -- template: templates/build-samples.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - - template: templates/build-test.yml parameters: BuildConfiguration: Release Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - -- template: templates/build-internal.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - -- template: templates/build-preview.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) - -- template: templates/build-benchmark.yml - parameters: - BuildConfiguration: Release - Arguments: $(ReleaseArguments) - VmImage: $(VmImage) + VmImage: $(VmImage) \ No newline at end of file diff --git a/templates/build-test.yml b/templates/build-test.yml index c94e117528..40aee3220e 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,10 +5,8 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & (TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal ' - EmulatorPipeline2Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=TEST" ' - EmulatorPipeline1CategoryListName: ' Query, ChangeFeed, ReadFeed, Batch ' # Divided in 2 categories to run them in parallel and reduce the PR feedback time - EmulatorPipeline2CategoryListName: ' Others ' + EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=TEST" ' + EmulatorPipeline1CategoryListName: ' Others ' jobs: - job: From cd7b8580471d3b980c0fa5e74bf7413df6c552f3 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 10:20:36 -0700 Subject: [PATCH 05/16] And more debugging --- .../SynchronizationContextTests.cs | 1 - templates/build-test.yml | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index 15b667c705..f9375de607 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -15,7 +15,6 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests [TestClass] public class SynchronizationContextTests { - [TestCategory("TEST")] [TestMethod] [Timeout(30000)] public void VerifySynchronizationContextDoesNotLock() diff --git a/templates/build-test.yml b/templates/build-test.yml index 40aee3220e..ee81e12bfe 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,26 +5,10 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=TEST" ' + EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory!=Quarantine & TestCategory!=Functional & (TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" ' EmulatorPipeline1CategoryListName: ' Others ' jobs: -- job: - displayName: Tests Debug - pool: - vmImage: ${{ parameters.VmImage }} - - steps: - - checkout: self # self represents the repo where the initial Pipelines YAML file was found - clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching - - # Add this Command to Include the .NET 6 SDK - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.x' - - job: displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline1CategoryListName }} timeoutInMinutes: 120 From b37e020a65849c5b1b5b6deef117d412f21c391a Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 10:47:52 -0700 Subject: [PATCH 06/16] Wrong build parameters --- templates/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/build-test.yml b/templates/build-test.yml index ee81e12bfe..5927a1eebd 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,7 +5,7 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory!=Quarantine & TestCategory!=Functional & (TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" ' + EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" ' EmulatorPipeline1CategoryListName: ' Others ' jobs: From 4f4a19b9095ee97b12cb2909ffba946a16f92135 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 10:52:06 -0700 Subject: [PATCH 07/16] Wrong category --- templates/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/build-test.yml b/templates/build-test.yml index 5927a1eebd..005f35f8a4 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,7 +5,7 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" ' + EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" ' EmulatorPipeline1CategoryListName: ' Others ' jobs: From 4bcd86d07d52b08f07b55e486e0c41a3372afc83 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Tue, 25 Oct 2022 13:35:51 -0700 Subject: [PATCH 08/16] Removing noise --- .../SummaryDiagnosticsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs index 9f200af263..6615b48fec 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs @@ -9,7 +9,7 @@ using Microsoft.Azure.Cosmos.Tracing.TraceData; using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] + //[TestClass] public class SummaryDiagnosticsTest { private Container Container = null; From 4210d4488719ff4eaebca09242b019f7b6c801f9 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Wed, 26 Oct 2022 11:51:18 -0700 Subject: [PATCH 09/16] Fixing test --- .../PartitionKeyRangeCacheTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PartitionKeyRangeCacheTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PartitionKeyRangeCacheTests.cs index 504f06467f..1b7d554772 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PartitionKeyRangeCacheTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PartitionKeyRangeCacheTests.cs @@ -19,11 +19,21 @@ public class PartitionKeyRangeCacheTests { private bool loopBackgroundOperaitons = false; - [TestMethod] - public async Task VerifyPkRangeCacheRefreshOnSplitWithErrorsAsync() + [TestInitialize] + public void TestInitialize() + { + this.loopBackgroundOperaitons = false; + } + + [TestCleanup] + public void TestCleanup() { this.loopBackgroundOperaitons = false; + } + [TestMethod] + public async Task VerifyPkRangeCacheRefreshOnSplitWithErrorsAsync() + { int throwOnPkRefreshCount = 3; int pkRangeCalls = 0; bool causeSplitExceptionInRntbdCall = false; From 19cbacfabceca7f7323ac231a1cfe947184569b4 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 07:56:29 -0700 Subject: [PATCH 10/16] Adding utils --- .../Utils/Util.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/Util.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/Util.cs index b17a575223..4533b2b562 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/Util.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/Util.cs @@ -5,11 +5,15 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests { using System; using System.Collections.Generic; + using System.Diagnostics; using System.Globalization; + using System.IO; using System.Linq; using System.Net; + using System.Text; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Services.Management.Tests; + using Microsoft.Azure.Cosmos.Telemetry; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Client; using Microsoft.Azure.Documents.Collections; @@ -514,5 +518,57 @@ internal static void LogRequestOptions(RequestOptions options, bool shouldLogOff options.OfferType, options.OfferThroughput); } + + internal static void EnableClientTelemetryEnvironmentVariables() + { + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEnabled, "true"); + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, "1"); + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint, "http://dummy.telemetry.endpoint/"); + } + + internal static void DisableClientTelemetryEnvironmentVariables() + { + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEnabled, null); + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, null); + Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint, null); + } + + /// + /// Enables traces for local debugging + /// + internal static void EnableTracesForDebugging() + { + Type defaultTrace = Type.GetType("Microsoft.Azure.Cosmos.Core.Trace.DefaultTrace,Microsoft.Azure.Cosmos.Direct"); + TraceSource traceSource = (TraceSource)defaultTrace.GetProperty("TraceSource").GetValue(null); + traceSource.Switch.Level = SourceLevels.All; + traceSource.Listeners.Clear(); + traceSource.Listeners.Add(new DirectToConsoleTraceListener()); + } + + public class DirectToConsoleTraceListener : TextWriterTraceListener + { + public DirectToConsoleTraceListener() : base(new DirectToConsoleTextWriter()) + { + } + + public override void Close() + { + } + } + + public class DirectToConsoleTextWriter : TextWriter + { + public override Encoding Encoding => Console.Out.Encoding; + + public override void Write(string value) + { + Logger.LogLine(value); + } + + public override void WriteLine(string value) + { + Logger.LogLine(value); + } + } } } From 623ccea9fb6613bbc527f74efd8151ef4c8fbb0b Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 07:58:34 -0700 Subject: [PATCH 11/16] Adding test with client telemetry enabled --- .../SynchronizationContextTests.cs | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index f9375de607..b7c81521d8 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -5,25 +5,24 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests { using System; - using System.Diagnostics; using System.Linq; using System.Threading; using Microsoft.Azure.Cosmos.Linq; - using Microsoft.Azure.Cosmos.Services.Management.Tests; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class SynchronizationContextTests { - [TestMethod] + [DataTestMethod] + [DataRow(false, DisplayName = "Client Telemetry disabled")] + [DataRow(true, DisplayName = "Client Telemetry enabled")] [Timeout(30000)] - public void VerifySynchronizationContextDoesNotLock() + public void VerifySynchronizationContextDoesNotLock(bool withClientTelemetry) { - Type defaultTrace = Type.GetType("Microsoft.Azure.Cosmos.Core.Trace.DefaultTrace,Microsoft.Azure.Cosmos.Direct"); - TraceSource traceSource = (TraceSource)defaultTrace.GetProperty("TraceSource").GetValue(null); - traceSource.Switch.Level = SourceLevels.All; - traceSource.Listeners.Clear(); - traceSource.Listeners.Add(new ConsoleTraceListener()); + if (withClientTelemetry) + { + Util.EnableClientTelemetryEnvironmentVariables(); + } string databaseId = Guid.NewGuid().ToString(); SynchronizationContext prevContext = SynchronizationContext.Current; @@ -35,31 +34,27 @@ public void VerifySynchronizationContextDoesNotLock() { using (CosmosClient client = TestCommon.CreateCosmosClient()) { - Logger.LogLine("1"); Cosmos.Database database = client.CreateDatabaseAsync(databaseId).GetAwaiter().GetResult(); - Logger.LogLine("a"); database = client.CreateDatabaseIfNotExistsAsync(databaseId).GetAwaiter().GetResult(); - Logger.LogLine("b"); database.ReadStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - Logger.LogLine("c"); database.ReadAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - Logger.LogLine("2"); + QueryDefinition databaseQuery = new QueryDefinition("select * from T where T.id = @id").WithParameter("@id", databaseId); FeedIterator databaseIterator = client.GetDatabaseQueryIterator(databaseQuery); while (databaseIterator.HasMoreResults) { databaseIterator.ReadNextAsync().GetAwaiter().GetResult(); } - Logger.LogLine("3"); + Container container = database.CreateContainerAsync(Guid.NewGuid().ToString(), "/pk").GetAwaiter().GetResult(); container = database.CreateContainerIfNotExistsAsync(container.Id, "/pk").GetAwaiter().GetResult(); - Logger.LogLine("4"); + ToDoActivity testItem = ToDoActivity.CreateRandomToDoActivity(); ItemResponse response = container.CreateItemAsync(item: testItem).ConfigureAwait(false).GetAwaiter().GetResult(); Assert.IsNotNull(response); string diagnostics = response.Diagnostics.ToString(); Assert.IsTrue(diagnostics.Contains("Synchronization Context")); - Logger.LogLine("5"); + using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); try @@ -76,7 +71,7 @@ public void VerifySynchronizationContextDoesNotLock() string exception = oe.ToString(); Assert.IsTrue(exception.Contains("Synchronization Context")); } - Logger.LogLine("6"); + // Test read feed container.GetItemLinqQueryable( allowSynchronousQueryExecution: true, @@ -92,7 +87,7 @@ public void VerifySynchronizationContextDoesNotLock() { feedIterator.ReadNextAsync().GetAwaiter().GetResult(); } - Logger.LogLine("7"); + FeedIterator feedIteratorTyped = container.GetItemLinqQueryable() .ToFeedIterator(); @@ -100,7 +95,7 @@ public void VerifySynchronizationContextDoesNotLock() { feedIteratorTyped.ReadNextAsync().GetAwaiter().GetResult(); } - Logger.LogLine("8"); + // Test query container.GetItemLinqQueryable( allowSynchronousQueryExecution: true, @@ -116,8 +111,6 @@ public void VerifySynchronizationContextDoesNotLock() queryIterator.ReadNextAsync().GetAwaiter().GetResult(); } - Logger.LogLine("9"); - FeedIterator queryIteratorTyped = container.GetItemLinqQueryable() .Where(item => item.id != "").ToFeedIterator(); @@ -126,30 +119,35 @@ public void VerifySynchronizationContextDoesNotLock() queryIteratorTyped.ReadNextAsync().GetAwaiter().GetResult(); } - Logger.LogLine("10"); - double costAsync = container.GetItemLinqQueryable() .Select(x => x.cost).SumAsync().GetAwaiter().GetResult(); double cost = container.GetItemLinqQueryable( allowSynchronousQueryExecution: true).Select(x => x.cost).Sum(); - Logger.LogLine("11"); + ItemResponse deleteResponse = container.DeleteItemAsync(partitionKey: new Cosmos.PartitionKey(testItem.pk), id: testItem.id).ConfigureAwait(false).GetAwaiter().GetResult(); Assert.IsNotNull(deleteResponse); - Logger.LogLine("12"); } }, state: null); } finally { SynchronizationContext.SetSynchronizationContext(prevContext); + using (CosmosClient client = TestCommon.CreateCosmosClient()) { client.GetDatabase(databaseId).DeleteAsync().GetAwaiter().GetResult(); } + + if (withClientTelemetry) + { + Util.DisableClientTelemetryEnvironmentVariables(); + } } } + + public class TestSynchronizationContext : SynchronizationContext { private object locker = new object(); From 11bcada70690a946cfc78a96b85062525c584836 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 07:58:55 -0700 Subject: [PATCH 12/16] Fixing leak in Client Telemetry Tests --- .../ClientTelemetryTests.cs | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs index 93e0cd8837..db215e01f3 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs @@ -30,7 +30,6 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests [TestClass] public class ClientTelemetryTests : BaseCosmosClientHelper { - private const string telemetryEndpointUrl = "http://dummy.telemetry.endpoint/"; private const int scheduledInSeconds = 1; private static readonly object jsonObject = JsonConvert.DeserializeObject("{\"compute\":{\"azEnvironment\":\"AzurePublicCloud\",\"customData\":\"\",\"isHostCompatibilityLayerVm\":\"false\",\"licenseType\":\"\",\"location\":\"eastus\",\"name\":\"sourabh-testing\",\"offer\":\"UbuntuServer\",\"osProfile\":{\"adminUsername\":\"azureuser\",\"computerName\":\"sourabh-testing\"},\"osType\":\"Linux\",\"placementGroupId\":\"\",\"plan\":{\"name\":\"\",\"product\":\"\",\"publisher\":\"\"},\"platformFaultDomain\":\"0\",\"platformUpdateDomain\":\"0\",\"provider\":\"Microsoft.Compute\",\"publicKeys\":[{\"keyData\":\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5uCeOAm3ehmhI+2PbMoMl17Eo\r\nqfHKCycSaBJsv9qxlmBOuFheSJc1XknJleXUSsuTO016/d1PyWpevnqOZNRksWoa\r\nJvQ23sDTxcK+X2OP3QlCUeX4cMjPXqlL8z1UYzU4Bx3fFvf8fs67G3N72sxWBw5P\r\nZyuXyhBm0NCe/2NYMKgEDT4ma8XszO0ikbhoPKbMbgHAQk/ktWQHNcqYOPQKEWqp\r\nEK1R0rjS2nmtovfScP/ZGXcvOpJ1/NDBo4dh1K+OxOGM/4PSH/F448J5Zy4eAyEk\r\nscys+IpeIOTOlRUy/703SNIX0LEWlnYqbyL9c1ypcYLQqF76fKkDfzzFI/OWVlGw\r\nhj/S9uP8iMsR+fhGIbn6MAa7O4DWPWLuedSp7KDYyjY09gqNJsfuaAJN4LiC6bPy\r\nhknm0PVLK3ux7EUOt+cZrHCdIFWbdOtxiPNIl1tkv9kV5aE5Aj2gJm4MeB9uXYhS\r\nOuksboBc0wyUGrl9+XZJ1+NlZOf7IjVi86CieK8= generated-by-azure\r\n\",\"path\":\"/home/azureuser/.ssh/authorized_keys\"}],\"publisher\":\"Canonical\",\"resourceGroupName\":\"sourabh-telemetry-sdk\",\"resourceId\":\"/subscriptions/8fba6d4f-7c37-4d13-9063-fd58ad2b86e2/resourceGroups/sourabh-telemetry-sdk/providers/Microsoft.Compute/virtualMachines/sourabh-testing\",\"securityProfile\":{\"secureBootEnabled\":\"false\",\"virtualTpmEnabled\":\"false\"},\"sku\":\"18.04-LTS\",\"storageProfile\":{\"dataDisks\":[],\"imageReference\":{\"id\":\"\",\"offer\":\"UbuntuServer\",\"publisher\":\"Canonical\",\"sku\":\"18.04-LTS\",\"version\":\"latest\"},\"osDisk\":{\"caching\":\"ReadWrite\",\"createOption\":\"FromImage\",\"diffDiskSettings\":{\"option\":\"\"},\"diskSizeGB\":\"30\",\"encryptionSettings\":{\"enabled\":\"false\"},\"image\":{\"uri\":\"\"},\"managedDisk\":{\"id\":\"/subscriptions/8fba6d4f-7c37-4d13-9063-fd58ad2b86e2/resourceGroups/sourabh-telemetry-sdk/providers/Microsoft.Compute/disks/sourabh-testing_OsDisk_1_9a54abfc5ba149c6a106bd9e5b558c2a\",\"storageAccountType\":\"Premium_LRS\"},\"name\":\"sourabh-testing_OsDisk_1_9a54abfc5ba149c6a106bd9e5b558c2a\",\"osType\":\"Linux\",\"vhd\":{\"uri\":\"\"},\"writeAcceleratorEnabled\":\"false\"}},\"subscriptionId\":\"8fba6d4f-7c37-4d13-9063-fd58ad2b86e2\",\"tags\":\"azsecpack:nonprod;platformsettings.host_environment.service.platform_optedin_for_rootcerts:true\",\"tagsList\":[{\"name\":\"azsecpack\",\"value\":\"nonprod\"},{\"name\":\"platformsettings.host_environment.service.platform_optedin_for_rootcerts\",\"value\":\"true\"}],\"version\":\"18.04.202103250\",\"vmId\":\"d0cb93eb-214b-4c2b-bd3d-cc93e90d9efd\",\"vmScaleSetName\":\"\",\"vmSize\":\"Standard_D2s_v3\",\"zone\":\"1\"},\"network\":{\"interface\":[{\"ipv4\":{\"ipAddress\":[{\"privateIpAddress\":\"10.0.7.5\",\"publicIpAddress\":\"\"}],\"subnet\":[{\"address\":\"10.0.7.0\",\"prefix\":\"24\"}]},\"ipv6\":{\"ipAddress\":[]},\"macAddress\":\"000D3A8F8BA0\"}]}}"); @@ -45,23 +44,17 @@ public class ClientTelemetryTests : BaseCosmosClientHelper private HttpClientHandlerHelper httpHandler; private HttpClientHandlerHelper httpHandlerForNonAzureInstance; - [ClassInitialize] - public static void ClassInitialize(TestContext context) + [TestInitialize] + public void TestInitialize() { - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEnabled, "true"); - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, "1"); - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint, telemetryEndpointUrl); - + Util.EnableClientTelemetryEnvironmentVariables(); + SystemUsageMonitor oldSystemUsageMonitor = (SystemUsageMonitor)typeof(DiagnosticsHandlerHelper) .GetField("systemUsageMonitor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(DiagnosticsHandlerHelper.Instance); oldSystemUsageMonitor.Stop(); ClientTelemetryTests.ResetSystemUsageMonitor(true); - } - [TestInitialize] - public void TestInitialize() - { this.actualInfo = new List(); this.httpHandler = new HttpClientHandlerHelper @@ -134,16 +127,6 @@ public void TestInitialize() .WithApplicationPreferredRegions(this.preferredRegionList); } - [ClassCleanup] - public static void FinalCleanup() - { - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEnabled, null); - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, null); - Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint, null); - - ClientTelemetryTests.ResetSystemUsageMonitor(false); - } - private static void ResetSystemUsageMonitor(bool isTelemetryEnabled) { ClientTelemetryTests.systemUsageMonitor?.Stop(); @@ -186,6 +169,10 @@ public async Task Cleanup() azMetadataField.SetValue(null, null); await base.TestCleanup(); + + Util.DisableClientTelemetryEnvironmentVariables(); + + ClientTelemetryTests.ResetSystemUsageMonitor(false); } [TestMethod] From 103be565d36c1c2bfd44eb749751d53947968bd7 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 08:06:20 -0700 Subject: [PATCH 13/16] Reenabling test --- .../SummaryDiagnosticsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs index 6615b48fec..9f200af263 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs @@ -9,7 +9,7 @@ using Microsoft.Azure.Cosmos.Tracing.TraceData; using Microsoft.VisualStudio.TestTools.UnitTesting; - //[TestClass] + [TestClass] public class SummaryDiagnosticsTest { private Container Container = null; From 42e8ff72027127e3e476c88c4def8fd6abcd65e9 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 08:36:28 -0700 Subject: [PATCH 14/16] cpu monitor initialization --- .../ClientTelemetryTests.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs index db215e01f3..961c5d25d1 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs @@ -44,17 +44,21 @@ public class ClientTelemetryTests : BaseCosmosClientHelper private HttpClientHandlerHelper httpHandler; private HttpClientHandlerHelper httpHandlerForNonAzureInstance; - [TestInitialize] - public void TestInitialize() + [ClassInitialize] + public static void ClassInitialize(TestContext _) { - Util.EnableClientTelemetryEnvironmentVariables(); - SystemUsageMonitor oldSystemUsageMonitor = (SystemUsageMonitor)typeof(DiagnosticsHandlerHelper) .GetField("systemUsageMonitor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(DiagnosticsHandlerHelper.Instance); oldSystemUsageMonitor.Stop(); ClientTelemetryTests.ResetSystemUsageMonitor(true); + } + [TestInitialize] + public void TestInitialize() + { + Util.EnableClientTelemetryEnvironmentVariables(); + this.actualInfo = new List(); this.httpHandler = new HttpClientHandlerHelper @@ -171,7 +175,11 @@ public async Task Cleanup() await base.TestCleanup(); Util.DisableClientTelemetryEnvironmentVariables(); + } + [ClassCleanup] + public static void FinalCleanup() + { ClientTelemetryTests.ResetSystemUsageMonitor(false); } From e93b33c87721530bfbebd2670f2d1dffb3317e47 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 09:21:52 -0700 Subject: [PATCH 15/16] Adding name details --- .../SynchronizationContextTests.cs | 4 +- templates/build-test.yml | 170 +++++++++++++++++- 2 files changed, 170 insertions(+), 4 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs index b7c81521d8..a8ae6ce1a4 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SynchronizationContextTests.cs @@ -14,8 +14,8 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests public class SynchronizationContextTests { [DataTestMethod] - [DataRow(false, DisplayName = "Client Telemetry disabled")] - [DataRow(true, DisplayName = "Client Telemetry enabled")] + [DataRow(false, DisplayName = "SynchronizationContextTests - Client Telemetry disabled")] + [DataRow(true, DisplayName = "SynchronizationContextTests - Client Telemetry enabled")] [Timeout(30000)] public void VerifySynchronizationContextDoesNotLock(bool withClientTelemetry) { diff --git a/templates/build-test.yml b/templates/build-test.yml index 005f35f8a4..3a016080e1 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,10 +5,83 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' -l "console;verbosity=detailed" --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" ' - EmulatorPipeline1CategoryListName: ' Others ' + EmulatorPipeline1Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & (TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal ' + EmulatorPipeline2Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed" --verbosity normal ' + EmulatorPipeline1CategoryListName: ' Query, ChangeFeed, ReadFeed, Batch ' # Divided in 2 categories to run them in parallel and reduce the PR feedback time + EmulatorPipeline2CategoryListName: ' Others ' jobs: +- job: + displayName: Tests Debug + pool: + vmImage: ${{ parameters.VmImage }} + + steps: + - checkout: self # self represents the repo where the initial Pipelines YAML file was found + clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching + + # Add this Command to Include the .NET 6 SDK + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'sdk' + version: '6.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Tests + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' + arguments: ${{ parameters.Arguments }} --configuration Debug /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CopyLocalLockFileAssemblies=true /p:OS=${{ parameters.OS }} + publishTestResults: true + nugetConfigPath: NuGet.config + testRunTitle: Microsoft.Azure.Cosmos.Tests + - script: | + dotnet tool install -g dotnet-reportgenerator-globaltool + reportgenerator -reports:$(Build.SourcesDirectory)/Microsoft.Azure.Cosmos/tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines;Cobertura + displayName: Create Code coverage report + - task: PublishCodeCoverageResults@1 + displayName: 'Publish code coverage' + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml' + reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage' + +- job: + displayName: PerformanceTests ${{ parameters.BuildConfiguration }} + pool: + vmImage: ${{ parameters.VmImage }} + + steps: + - checkout: self # self represents the repo where the initial Pipelines YAML file was found + clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching + + # Add this Command to Include the .NET 6 SDK + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'sdk' + version: '6.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.PerformanceTests - Build + condition: succeeded() + inputs: + command: build + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/*.csproj' + arguments: -c Release + nugetConfigPath: NuGet.config + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.PerformanceTests - Run + condition: succeeded() + inputs: + command: run + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/*.csproj' + arguments: --configuration ${{ parameters.BuildConfiguration }} --no-restore --framework net6.0 --allCategories=GateBenchmark -- -j Short -m --BaselineValidation + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.PerformanceTests + - job: displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline1CategoryListName }} timeoutInMinutes: 120 @@ -39,3 +112,96 @@ jobs: nugetConfigPath: NuGet.config publishTestResults: true testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + +- job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline2CategoryListName }} + timeoutInMinutes: 120 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + vmImage: ${{ parameters.VmImage }} + + steps: + - checkout: self # self represents the repo where the initial Pipelines YAML file was found + clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching + + # Add this Command to Include the .NET 6 SDK + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'sdk' + version: '6.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' + arguments: ${{ parameters.EmulatorPipeline2Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + +- job: + displayName: Encryption EmulatorTests ${{ parameters.BuildConfiguration }} + timeoutInMinutes: 90 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + vmImage: ${{ parameters.VmImage }} + + steps: + - checkout: self # self represents the repo where the initial Pipelines YAML file was found + clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching + + # Add this Command to Include the .NET 6 SDK + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'sdk' + version: '6.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Encryption.EmulatorTests + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos.Encryption/tests/EmulatorTests/*.csproj' + arguments: ${{ parameters.Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.Encryption.EmulatorTests + +- job: + displayName: Encryption.Custom EmulatorTests ${{ parameters.BuildConfiguration }} + timeoutInMinutes: 90 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + vmImage: ${{ parameters.VmImage }} + + steps: + - checkout: self # self represents the repo where the initial Pipelines YAML file was found + clean: true # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching + + # Add this Command to Include the .NET 6 SDK + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'sdk' + version: '6.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos.Encryption.Custom/tests/EmulatorTests/*.csproj' + arguments: ${{ parameters.Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests From de12438375e8d08630e008616e0221fce98bef4d Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Thu, 27 Oct 2022 09:31:16 -0700 Subject: [PATCH 16/16] Undo another file --- azure-pipelines.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9a8ad067d0..98490f0a62 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,8 +21,51 @@ variables: jobs: +- template: templates/static-tools.yml + parameters: + BuildConfiguration: Release + VmImage: $(VmImage) + +- template: templates/nuget-pack.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage) + ReleasePackage: false + OutputPath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/Release/Microsoft.Azure.Cosmos' + +- template: templates/build-ctl.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage) + +- template: templates/build-samples.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage) + - template: templates/build-test.yml parameters: BuildConfiguration: Release Arguments: $(ReleaseArguments) - VmImage: $(VmImage) \ No newline at end of file + VmImage: $(VmImage) + +- template: templates/build-internal.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage) + +- template: templates/build-preview.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage) + +- template: templates/build-benchmark.yml + parameters: + BuildConfiguration: Release + Arguments: $(ReleaseArguments) + VmImage: $(VmImage)