Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions test/EFCore.Cosmos.FunctionalTests/CosmosSessionTokensTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Microsoft.EntityFrameworkCore;

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/291 (Session tokens not properly tracked)
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
public class CosmosSessionTokensTest(CosmosSessionTokensTest.CosmosFixture fixture) : IClassFixture<CosmosSessionTokensTest.CosmosFixture>
{
private const string DatabaseName = nameof(CosmosSessionTokensTest);
Expand Down Expand Up @@ -81,7 +79,7 @@ await Assert.ThrowsAsync<CosmosException>(() => context.OtherContainerCustomers.

foreach (var ex in exes)
{
Assert.Contains("The session token provided 'invalidtoken' is invalid", ex.ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ex.ResponseBody);
}
}

Expand All @@ -100,7 +98,7 @@ await Assert.ThrowsAsync<CosmosException>(() => context.OtherContainerCustomers.

foreach (var ex in exes)
{
Assert.Contains("The session token provided 'invalidtoken' is invalid", ex.ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ex.ResponseBody);
}
}

Expand All @@ -119,7 +117,7 @@ public virtual async Task Shaped_query_uses_session_token()

foreach (var ex in exes)
{
Assert.Contains("The session token provided 'invalidtoken' is invalid", ex.ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ex.ResponseBody);
}
}

Expand All @@ -138,7 +136,7 @@ await Assert.ThrowsAsync<CosmosException>(() => context.OtherContainerCustomers.

foreach (var ex in exes)
{
Assert.Contains("The session token provided 'invalidtoken' is invalid", ex.ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ex.ResponseBody);
}
}

Expand Down Expand Up @@ -479,7 +477,7 @@ public virtual async Task Add_uses_GetSessionToken(AutoTransactionBehavior autoT

var ex = await Assert.ThrowsAsync<DbUpdateException>(() => context.SaveChangesAsync());

Assert.Contains("The session token provided 'invalidtoken' is invalid.", ((CosmosException)ex.InnerException!).ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ((CosmosException)ex.InnerException!).ResponseBody);
}

[ConditionalTheory]
Expand Down Expand Up @@ -510,7 +508,7 @@ public virtual async Task Update_uses_session_token(AutoTransactionBehavior auto

var ex = await Assert.ThrowsAsync<DbUpdateException>(() => context.SaveChangesAsync());

Assert.Contains("The session token provided 'invalidtoken' is invalid.", ((CosmosException)ex.InnerException!).ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ((CosmosException)ex.InnerException!).ResponseBody);
}

[ConditionalTheory]
Expand Down Expand Up @@ -541,7 +539,7 @@ public virtual async Task Delete_uses_session_token(AutoTransactionBehavior auto

var ex = await Assert.ThrowsAsync<DbUpdateException>(() => context.SaveChangesAsync());

Assert.Contains("The session token provided 'invalidtoken' is invalid.", ((CosmosException)ex.InnerException!).ResponseBody);
Assert.Contains("The session token provided 'invalidtoken' is", ((CosmosException)ex.InnerException!).ResponseBody);
}

[ConditionalFact]
Expand Down Expand Up @@ -600,8 +598,6 @@ protected Test2Context()
}
}

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/291 (Session tokens not properly tracked)
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
public class CosmosNonSharedSessionTokenTests(NonSharedFixture fixture) : NonSharedModelTestBase(fixture), IClassFixture<NonSharedFixture>
{
protected override ITestStoreFactory NonSharedTestStoreFactory
Expand All @@ -611,7 +607,9 @@ protected override ITestStoreFactory NonSharedTestStoreFactory

protected override TestStore CreateTestStore() => CosmosTestStore.Create(NonSharedStoreName, (cfg) => cfg.SessionTokenManagementMode(Cosmos.Infrastructure.SessionTokenManagementMode.SemiAutomatic));

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/322
[ConditionalFact]
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
public virtual async Task UseSessionTokens_uses_session_tokens()
{
var contextFactory = await InitializeNonSharedTest<CosmosSessionTokenContext>();
Expand Down Expand Up @@ -655,7 +653,9 @@ public virtual async Task ReadItem_does_not_exist_returns_null()
Assert.Null(result);
}

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/322
[ConditionalFact]
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
public virtual async Task Read_item_session_not_found_throws_CosmosException()
{
var contextFactory = await InitializeNonSharedTest<CosmosSessionTokenContext>();
Expand Down Expand Up @@ -742,7 +742,9 @@ public virtual async Task Pooled_context_clears_SessionTokenStorage()
Assert.True(_sessionTokenStorage.ClearCalled);
}

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/319
[ConditionalTheory]
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
[InlineData(AutoTransactionBehavior.Never)]
[InlineData(AutoTransactionBehavior.Always)]
public virtual async Task Optimistic_concurrency_precondition_failure_updates_session_token(AutoTransactionBehavior autoTransactionBehavior)
Expand Down