Skip to content

Commit

Permalink
[Internal] Pipelines: Fixes Multi-Region CI pipeline to include env v…
Browse files Browse the repository at this point in the history
…ariable (Azure#4363)

* Fixes Multi-Region CI pipeline to include env variable

* fixed space

* added validation test

* string conversion

* temp

* temp2

* Update Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTests.cs

Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>

* Update Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTests.cs

Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>

* changed env location

* temp

* test

* space

* remove env

* possible fix

* test fix

* clean up

* changed enviroment variable get

* test

* test fix

* ensure multiregion tests do not run with regular emulator tests

---------

Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
  • Loading branch information
NaluTripician and ealsur authored Mar 25, 2024
1 parent dbdf806 commit 75a2e5f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,18 @@ public void PooledConnectionLifetimeTest()
Type clientMessageHandlerType = cosmosClient.ClientContext.DocumentClient.httpClient.HttpMessageHandler.GetType();
Assert.AreEqual(socketHandlerType, clientMessageHandlerType);
}

[TestMethod]
[TestCategory("MultiRegion")]
public async Task MultiRegionAccountTest()
{
string connectionString = TestCommon.GetMultiRegionConnectionString();
Assert.IsFalse(string.IsNullOrEmpty(connectionString), "Connection String Not Set");
using CosmosClient cosmosClient = new CosmosClient(connectionString);
Assert.IsNotNull(cosmosClient);
AccountProperties properties = await cosmosClient.ReadAccountAsync();
Assert.IsNotNull(properties);
}

public static IReadOnlyList<string> GetActiveConnections()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ internal static (string endpoint, string authKey) GetAccountInfo()
return (endpoint, authKey);
}

internal static string GetMultiRegionConnectionString()
{
return Cosmos.ConfigurationManager.GetEnvironmentVariable<string>("COSMOSDB_MULTI_REGION", string.Empty);
}

internal static CosmosClientBuilder GetDefaultConfiguration(
bool useCustomSeralizer = true,
bool validatePartitionKeyRangeCalls = false,
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
BuildConfiguration: Release
Arguments: $(ReleaseArguments)
VmImage: $(VmImage)
MultiRegionConnectionString: $(COSMOSDB_MULTI_REGION)

- template: templates/build-internal.yml
parameters:
Expand Down
7 changes: 5 additions & 2 deletions templates/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ 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!=ClientTelemetryRelease & TestCategory!=LongRunning & (TestCategory=ClientTelemetryEmulator|TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal '
EmulatorPipeline2Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=ClientTelemetryEmulator & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed & TestCategory!=LongRunning" --verbosity normal '
EmulatorPipeline1Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=LongRunning & TestCategory!=MultiRegion & (TestCategory=ClientTelemetryEmulator|TestCategory=Query|TestCategory=ReadFeed|TestCategory=Batch|TestCategory=ChangeFeed)" --verbosity normal '
EmulatorPipeline2Arguments: ' --filter "TestCategory!=Quarantine & TestCategory!=Functional & TestCategory!=ClientTelemetryRelease & TestCategory!=ClientTelemetryEmulator & TestCategory!=Query & TestCategory!=ReadFeed & TestCategory!=Batch & TestCategory!=ChangeFeed & TestCategory!=LongRunning & TestCategory!=MultiRegion" --verbosity normal '
EmulatorPipeline3Arguments: ' --filter "TestCategory=MultiRegion" --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 '
MultiRegionConnectionString : ''

jobs:
- job:
Expand Down Expand Up @@ -236,3 +237,5 @@ jobs:
nugetConfigPath: NuGet.config
publishTestResults: true
testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests
env:
COSMOSDB_MULTI_REGION: ${{ parameters.MultiRegionConnectionString }}

0 comments on commit 75a2e5f

Please sign in to comment.