diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemThinClientTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemThinClientTests.cs new file mode 100644 index 0000000000..67eeda5ab8 --- /dev/null +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemThinClientTests.cs @@ -0,0 +1,298 @@ +//------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +//------------------------------------------------------------ + +namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Text.Json; + using System.Text.Json.Serialization; + using System.Threading.Tasks; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using static Microsoft.Azure.Cosmos.SDK.EmulatorTests.MultiRegionSetupHelpers; + using TestObject = MultiRegionSetupHelpers.CosmosIntegrationTestObject; + + [TestClass] + public class CosmosItemThinClientTests + { + private string connectionString; + private CosmosClient client; + private Database database; + private Container container; + private CosmosSystemTextJsonSerializer cosmosSystemTextJsonSerializer; + + private const int ItemCount = 1000; + + [TestInitialize] + public async Task TestInitAsync() + { + this.connectionString = Environment.GetEnvironmentVariable("COSMOSDB_THINCLIENT"); + Environment.SetEnvironmentVariable(ConfigurationManager.ThinClientModeEnabled, "True"); + + if (string.IsNullOrEmpty(this.connectionString)) + { + Assert.Fail("Set environment variable COSMOSDB_THINCLIENT to run the tests"); + } + + JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions + { + PropertyNamingPolicy = null, + PropertyNameCaseInsensitive = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + }; + this.cosmosSystemTextJsonSerializer = new MultiRegionSetupHelpers.CosmosSystemTextJsonSerializer(jsonSerializerOptions); + + this.client = new CosmosClient( + this.connectionString, + new CosmosClientOptions() + { + ConnectionMode = ConnectionMode.Gateway, + Serializer = this.cosmosSystemTextJsonSerializer, + }); + + string uniqueDbName = "TestDb_" + Guid.NewGuid().ToString(); + this.database = await this.client.CreateDatabaseIfNotExistsAsync(uniqueDbName); + string uniqueContainerName = "TestContainer_" + Guid.NewGuid().ToString(); + this.container = await this.database.CreateContainerIfNotExistsAsync(uniqueContainerName, "/pk"); + } + + + [TestCleanup] + public async Task TestCleanupAsync() + { + Environment.SetEnvironmentVariable(ConfigurationManager.ThinClientModeEnabled, "False"); + + if (this.database != null) + { + await this.database.DeleteAsync(); + } + + this.client?.Dispose(); + } + + private IEnumerable GenerateItems(string partitionKey) + { + List items = new List(); + for (int i = 0; i < ItemCount; i++) + { + items.Add(new TestObject + { + Id = Guid.NewGuid().ToString(), + Pk = partitionKey, + Other = "Test Item " + i + }); + } + + return items; + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task CreateItemsTest() + { + string pk = "pk_create"; + IEnumerable items = this.GenerateItems(pk); + + foreach (TestObject item in items) + { + ItemResponse response = await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task ReadItemsTest() + { + string pk = "pk_read"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + ItemResponse response = await this.container.ReadItemAsync(item.Id, new PartitionKey(item.Pk)); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + Assert.AreEqual(item.Id, response.Resource.Id); + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task ReplaceItemsTest() + { + string pk = "pk_replace"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + TestObject updatedItem = new TestObject + { + Id = item.Id, + Pk = item.Pk, + Other = "Updated " + item.Other + }; + + ItemResponse response = await this.container.ReplaceItemAsync(updatedItem, updatedItem.Id, new PartitionKey(updatedItem.Pk)); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + Assert.AreEqual("Updated " + item.Other, response.Resource.Other); + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task UpsertItemsTest() + { + string pk = "pk_upsert"; + IEnumerable items = this.GenerateItems(pk); + + foreach (TestObject item in items) + { + ItemResponse response = await this.container.UpsertItemAsync(item, new PartitionKey(item.Pk)); + Assert.IsTrue(response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK); + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task DeleteItemsTest() + { + string pk = "pk_delete"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + ItemResponse response = await this.container.DeleteItemAsync(item.Id, new PartitionKey(item.Pk)); + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task CreateItemStreamTest() + { + string pk = "pk_create_stream"; + IEnumerable items = this.GenerateItems(pk); + + foreach (TestObject item in items) + { + using (Stream stream = this.cosmosSystemTextJsonSerializer.ToStream(item)) + { + using (ResponseMessage response = await this.container.CreateItemStreamAsync(stream, new PartitionKey(item.Pk))) + { + Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); + } + } + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task ReadItemStreamTest() + { + string pk = "pk_read_stream"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + using (ResponseMessage response = await this.container.ReadItemStreamAsync(item.Id, new PartitionKey(item.Pk))) + { + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + } + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task ReplaceItemStreamTest() + { + string pk = "pk_replace_stream"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + TestObject updatedItem = new TestObject + { + Id = item.Id, + Pk = item.Pk, + Other = "Updated " + item.Other + }; + + using (Stream stream = this.cosmosSystemTextJsonSerializer.ToStream(updatedItem)) + { + using (ResponseMessage response = await this.container.ReplaceItemStreamAsync(stream, updatedItem.Id, new PartitionKey(updatedItem.Pk))) + { + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + } + } + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task UpsertItemStreamTest() + { + string pk = "pk_upsert_stream"; + IEnumerable items = this.GenerateItems(pk); + + foreach (TestObject item in items) + { + using (Stream stream = this.cosmosSystemTextJsonSerializer.ToStream(item)) + { + using (ResponseMessage response = await this.container.UpsertItemStreamAsync(stream, new PartitionKey(item.Pk))) + { + Assert.IsTrue(response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK); + } + } + } + } + + [TestMethod] + [TestCategory("ThinClient")] + public async Task DeleteItemStreamTest() + { + string pk = "pk_delete_stream"; + List items = this.GenerateItems(pk).ToList(); + + foreach (TestObject item in items) + { + await this.container.CreateItemAsync(item, new PartitionKey(item.Pk)); + } + + foreach (TestObject item in items) + { + using (ResponseMessage response = await this.container.DeleteItemStreamAsync(item.Id, new PartitionKey(item.Pk))) + { + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + } + } + } +} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 127335d335..7f912dd033 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -52,6 +52,7 @@ jobs: VmImage: $(VmImage) MultiRegionConnectionString: $(COSMOSDB_MULTI_REGION) MultiRegionMultiMasterConnectionString: $(COSMOSDB_MULTIMASTER) + ThinClientConnectionString: $(COSMOSDB_THINCLIENT) IncludePerformance: true IncludeCoverage: true diff --git a/templates/build-test.yml b/templates/build-test.yml index f4ab5339f2..7558523927 100644 --- a/templates/build-test.yml +++ b/templates/build-test.yml @@ -5,450 +5,492 @@ parameters: Arguments: '' VmImage: '' # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops OS: 'Windows' - EmulatorPipeline1Arguments: ' --filter "TestCategory!=Flaky & TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=LongRunning & TestCategory!=MultiRegion & TestCategory!=MultiMaster & (TestCategory=ClientTelemetryEmulator|TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal ' - EmulatorPipeline2Arguments: ' --filter "TestCategory!=Flaky & TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=ClientTelemetryEmulator & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed & TestCategory!=LongRunning & TestCategory!=MultiRegion & TestCategory!=MultiMaster" --verbosity normal ' + EmulatorPipeline1Arguments: ' --filter "TestCategory!=Flaky & TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=LongRunning & TestCategory!=MultiRegion & TestCategory!=MultiMaster & TestCategory !=ThinClient & (TestCategory=ClientTelemetryEmulator|TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal ' + EmulatorPipeline2Arguments: ' --filter "TestCategory!=Flaky & TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=ClientTelemetryEmulator & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed & TestCategory!=LongRunning & TestCategory!=MultiRegion & TestCategory!=MultiMaster & TestCategory !=ThinClient" --verbosity normal ' EmulatorPipeline3Arguments: ' --filter "TestCategory=MultiRegion" --verbosity normal ' EmulatorPipeline4Arguments: ' --filter "TestCategory=MultiMaster" --verbosity normal ' + EmulatorPipeline5Arguments: ' --filter "TestCategory=ThinClient" --verbosity normal ' EmulatorPipeline1CategoryListName: ' Client Telemetry, Query, ChangeFeed, ReadFeed, Batch ' # Divided in 2 categories to run them in parallel and reduce the PR feedback time EmulatorPipeline2CategoryListName: ' Others ' EmulatorPipeline3CategoryListName: ' MultiRegion ' EmulatorPipeline4CategoryListName: ' MultiMaster ' - MultiRegionConnectionString : '' - MultiRegionMultiMasterConnectionString : '' + EmulatorPipeline5CategoryListName: ' ThinClient ' + MultiRegionConnectionString: '' + MultiRegionMultiMasterConnectionString: '' + ThinClientConnectionString: '' IncludeEncryption: true IncludePerformance: true IncludeCoverage: true jobs: -- job: - displayName: Microsoft.Azure.Cosmos.Tests - pool: - name: 'OneES' - - 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 SDK and runtimes - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - task: DotNetCoreCLI@2 + - job: displayName: Microsoft.Azure.Cosmos.Tests - condition: succeeded() - retryCountOnTaskFailure: 2 - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' - arguments: ${{ parameters.Arguments }} /p:OS=${{ parameters.OS }} - publishTestResults: true - nugetConfigPath: NuGet.config - testRunTitle: Microsoft.Azure.Cosmos.Tests - -- job: - displayName: Microsoft.Azure.Cosmos.Tests Flaky - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Tests - condition: succeeded() - retryCountOnTaskFailure: 4 - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' - arguments: --filter "TestCategory=Flaky" --verbosity normal /p:OS=${{ parameters.OS }} - publishTestResults: true - nugetConfigPath: NuGet.config - testRunTitle: Microsoft.Azure.Cosmos.Tests - - -- job: - displayName: Microsoft.Azure.Cosmos.Tests Coverage - condition: and(succeeded(), eq(${{ parameters.IncludeCoverage }}, true)) - pool: - name: 'OneES' - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.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@2 - displayName: 'Publish code coverage' - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml' - reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage' - -- job: - displayName: PerformanceTests ${{ parameters.BuildConfiguration }} - condition: and(succeeded(), eq(${{ parameters.IncludePerformance }}, true)) - pool: - name: 'OneES' - timeoutInMinutes: 120 - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.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: 60 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - condition: succeeded() - retryCountOnTaskFailure: 2 - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' - arguments: ${{ parameters.EmulatorPipeline1Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - env: - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - -- job: - displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline2CategoryListName }} - timeoutInMinutes: 60 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - condition: succeeded() - retryCountOnTaskFailure: 2 - 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 - env: - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - - -- job: - displayName: EmulatorTests ${{ parameters.BuildConfiguration }} Flaky - timeoutInMinutes: 60 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - retryCountOnTaskFailure: 4 - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' - arguments: --filter "TestCategory=Flaky" --verbosity normal --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - env: - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - -- job: - displayName: Encryption EmulatorTests ${{ parameters.BuildConfiguration }} - timeoutInMinutes: 60 - condition: and(eq(${{ parameters.IncludeEncryption }}, true), and(succeeded(), eq('${{ parameters.OS }}', 'Windows'))) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Encryption.EmulatorTests - condition: succeeded() - retryCountOnTaskFailure: 2 - 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 - env: - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - -- job: - displayName: Encryption.Custom EmulatorTests ${{ parameters.BuildConfiguration }} - timeoutInMinutes: 60 - condition: and(eq(${{ parameters.IncludeEncryption }}, true), and(succeeded(), eq('${{ parameters.OS }}', 'Windows'))) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - template: emulator-setup.yml - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests - condition: succeeded() - retryCountOnTaskFailure: 2 - 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 - env: - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - -- job: - displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline3CategoryListName }} - timeoutInMinutes: 60 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - retryCountOnTaskFailure: 2 - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' - arguments: ${{ parameters.EmulatorPipeline3Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - env: - COSMOSDB_MULTI_REGION: ${{ parameters.MultiRegionConnectionString }} - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true - -- job: - displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline4CategoryListName }} - timeoutInMinutes: 60 - condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) - pool: - name: 'OneES' - - 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: 'runtime' - version: '6.x' - - - task: UseDotNet@2 - displayName: Use .NET 8.0 - inputs: - packageType: 'sdk' - version: '8.x' - - - task: DotNetCoreCLI@2 - displayName: Microsoft.Azure.Cosmos.EmulatorTests - retryCountOnTaskFailure: 2 - condition: succeeded() - inputs: - command: test - projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' - arguments: ${{ parameters.EmulatorPipeline4Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} - nugetConfigPath: NuGet.config - publishTestResults: true - testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - env: - COSMOSDB_MULTI_REGION: ${{ parameters.MultiRegionMultiMasterConnectionString }} - AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true \ No newline at end of file + pool: + name: 'OneES' + + 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 SDK and runtimes + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Tests + condition: succeeded() + retryCountOnTaskFailure: 2 + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' + arguments: ${{ parameters.Arguments }} /p:OS=${{ parameters.OS }} + publishTestResults: true + nugetConfigPath: NuGet.config + testRunTitle: Microsoft.Azure.Cosmos.Tests + + - job: + displayName: Microsoft.Azure.Cosmos.Tests Flaky + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Tests + condition: succeeded() + retryCountOnTaskFailure: 4 + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/*.csproj' + arguments: --filter "TestCategory=Flaky" --verbosity normal /p:OS=${{ parameters.OS }} + publishTestResults: true + nugetConfigPath: NuGet.config + testRunTitle: Microsoft.Azure.Cosmos.Tests + + + - job: + displayName: Microsoft.Azure.Cosmos.Tests Coverage + condition: and(succeeded(), eq(${{ parameters.IncludeCoverage }}, true)) + pool: + name: 'OneES' + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.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@2 + displayName: 'Publish code coverage' + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml' + reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage' + + - job: + displayName: PerformanceTests ${{ parameters.BuildConfiguration }} + condition: and(succeeded(), eq(${{ parameters.IncludePerformance }}, true)) + pool: + name: 'OneES' + timeoutInMinutes: 120 + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.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: 60 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + condition: succeeded() + retryCountOnTaskFailure: 2 + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' + arguments: ${{ parameters.EmulatorPipeline1Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + env: + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline2CategoryListName }} + timeoutInMinutes: 60 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + condition: succeeded() + retryCountOnTaskFailure: 2 + 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 + env: + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + + - job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} Flaky + timeoutInMinutes: 60 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + retryCountOnTaskFailure: 4 + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' + arguments: --filter "TestCategory=Flaky" --verbosity normal --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + env: + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: Encryption EmulatorTests ${{ parameters.BuildConfiguration }} + timeoutInMinutes: 60 + condition: and(eq(${{ parameters.IncludeEncryption }}, true), and(succeeded(), eq('${{ parameters.OS }}', 'Windows'))) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Encryption.EmulatorTests + condition: succeeded() + retryCountOnTaskFailure: 2 + 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 + env: + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: Encryption.Custom EmulatorTests ${{ parameters.BuildConfiguration }} + timeoutInMinutes: 60 + condition: and(eq(${{ parameters.IncludeEncryption }}, true), and(succeeded(), eq('${{ parameters.OS }}', 'Windows'))) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - template: emulator-setup.yml + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.Encryption.Custom.EmulatorTests + condition: succeeded() + retryCountOnTaskFailure: 2 + 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 + env: + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline3CategoryListName }} + timeoutInMinutes: 60 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + retryCountOnTaskFailure: 2 + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' + arguments: ${{ parameters.EmulatorPipeline3Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + env: + COSMOSDB_MULTI_REGION: ${{ parameters.MultiRegionConnectionString }} + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline4CategoryListName }} + timeoutInMinutes: 60 + condition: and(succeeded(), eq('${{ parameters.OS }}', 'Windows')) + pool: + name: 'OneES' + + 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: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + retryCountOnTaskFailure: 2 + condition: succeeded() + inputs: + command: test + projects: 'Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj' + arguments: ${{ parameters.EmulatorPipeline4Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests + env: + COSMOSDB_MULTI_REGION: ${{ parameters.MultiRegionMultiMasterConnectionString }} + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true + + - job: + displayName: EmulatorTests ${{ parameters.BuildConfiguration }} - ${{ parameters.EmulatorPipeline5CategoryListName }} + timeoutInMinutes: 120 + condition: and(always(), eq('${{ parameters.OS }}', 'Windows')) + pool: { name: 'OneES' } + + steps: + - checkout: self + clean: true + + - task: UseDotNet@2 + displayName: Use .NET 6.0 + inputs: + packageType: 'runtime' + version: '6.x' + + - task: UseDotNet@2 + displayName: Use .NET 8.0 + inputs: + packageType: 'sdk' + version: '8.x' + + - task: DotNetCoreCLI@2 + displayName: Microsoft.Azure.Cosmos.EmulatorTests + condition: always() + continueOnError: true + retryCountOnTaskFailure: 2 + inputs: + command: test + projects: Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/*.csproj + arguments: ${{ parameters.EmulatorPipeline5Arguments }} --configuration ${{ parameters.BuildConfiguration }} /p:OS=${{ parameters.OS }} + nugetConfigPath: NuGet.config + publishTestResults: true + testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests - ${{ parameters.EmulatorPipeline5CategoryListName }} + env: + COSMOSDB_THINCLIENT: ${{ parameters.ThinClientConnectionString }} + AZURE_COSMOS_THIN_CLIENT_ENABLED: "True" + AZURE_COSMOS_NON_STREAMING_ORDER_BY_FLAG_DISABLED: true