Skip to content

Commit fb04039

Browse files
authored
Fix CosmosTransactionalBatchTest on non-emulator (#37040)
1 parent e7fc2d0 commit fb04039

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

test/EFCore.Cosmos.FunctionalTests/CosmosTransactionalBatchTest.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ public virtual async Task SaveChanges_transaction_behaviour_always_single_entity
477477
await context.SaveChangesAsync();
478478

479479
// Total document size will be: 2_097_510. Total request size will be: 2_098_548
480-
// Normally 2MiB is 2_097_152, but cosmos appears to allow ~1Kib (1396 bytes) extra
481-
var str = new string('x', 2_095_235);
480+
// Normally, the limit is 2MiB (2_097_152), but Cosmos appears to allow ~1Kib (1396 bytes) extra
481+
var str = new string('x', 2_095_234);
482482
customer.Name = str;
483483

484484
if (oneByteOver)
@@ -498,7 +498,6 @@ public virtual async Task SaveChanges_transaction_behaviour_always_single_entity
498498
}
499499

500500
[ConditionalTheory, InlineData(true), InlineData(false)]
501-
[CosmosCondition(CosmosCondition.IsNotEmulator)]
502501
public virtual async Task SaveChanges_transaction_behaviour_always_update_entities_payload_can_be_exactly_cosmos_limit_and_throws_when_1byte_over(bool oneByteOver)
503502
{
504503
var contextFactory = await InitializeAsync<TransactionalBatchContext>();
@@ -514,8 +513,8 @@ public virtual async Task SaveChanges_transaction_behaviour_always_update_entiti
514513

515514
await context.SaveChangesAsync();
516515

517-
customer1.Name = new string('x', 1097589);
518-
customer2.Name = new string('x', 1097590);
516+
customer1.Name = new string('x', 1097582);
517+
customer2.Name = new string('x', 1097583);
519518

520519
if (oneByteOver)
521520
{
@@ -530,7 +529,6 @@ public virtual async Task SaveChanges_transaction_behaviour_always_update_entiti
530529
}
531530

532531
[ConditionalTheory, InlineData(true), InlineData(false)]
533-
[CosmosCondition(CosmosCondition.IsNotEmulator)]
534532
public virtual async Task SaveChanges_id_counts_double_toward_request_size_on_update(bool oneByteOver)
535533
{
536534
var contextFactory = await InitializeAsync<TransactionalBatchContext>();
@@ -546,8 +544,8 @@ public virtual async Task SaveChanges_id_counts_double_toward_request_size_on_up
546544

547545
await context.SaveChangesAsync();
548546

549-
customer1.Name = new string('x', 1097590 + 1_022 * 2);
550-
customer2.Name = new string('x', 1097590);
547+
customer1.Name = new string('x', 1097581 + (1_024 - customer1.Id.Length) * 2);
548+
customer2.Name = new string('x', 1097581 + (1_024 - customer2.Id.Length) * 2);
551549

552550
if (oneByteOver)
553551
{
@@ -562,16 +560,15 @@ public virtual async Task SaveChanges_id_counts_double_toward_request_size_on_up
562560
}
563561

564562
[ConditionalTheory, InlineData(true), InlineData(false)]
565-
[CosmosCondition(CosmosCondition.IsNotEmulator)]
566563
public virtual async Task SaveChanges_transaction_behaviour_always_create_entities_payload_can_be_exactly_cosmos_limit_and_throws_when_1byte_over(bool oneByteOver)
567564
{
568565
var contextFactory = await InitializeAsync<TransactionalBatchContext>();
569566

570567
using var context = contextFactory.CreateContext();
571568
context.Database.AutoTransactionBehavior = AutoTransactionBehavior.Always;
572569

573-
var customer1 = new Customer { Id = new string('x', 1_023), Name = new string('x', 1098848), PartitionKey = new string('x', 1_023) };
574-
var customer2 = new Customer { Id = new string('y', 1_023), Name = new string('x', 1098848), PartitionKey = new string('x', 1_023) };
570+
var customer1 = new Customer { Id = new string('x', 1_023), Name = new string('x', 1098841), PartitionKey = new string('x', 1_023) };
571+
var customer2 = new Customer { Id = new string('y', 1_023), Name = new string('x', 1098841), PartitionKey = new string('x', 1_023) };
575572
if (oneByteOver)
576573
{
577574
customer1.Name += 'x';
@@ -591,16 +588,15 @@ public virtual async Task SaveChanges_transaction_behaviour_always_create_entiti
591588
}
592589

593590
[ConditionalTheory, InlineData(true), InlineData(false)]
594-
[CosmosCondition(CosmosCondition.IsNotEmulator)]
595591
public virtual async Task SaveChanges_id_does_not_count_double_toward_request_size_on_create(bool oneByteOver)
596592
{
597593
var contextFactory = await InitializeAsync<TransactionalBatchContext>();
598594

599595
using var context = contextFactory.CreateContext();
600596
context.Database.AutoTransactionBehavior = AutoTransactionBehavior.Always;
601597

602-
var customer1 = new Customer { Id = new string('x', 1), Name = new string('x', 1098848 + 1_022), PartitionKey = new string('x', 1_023) };
603-
var customer2 = new Customer { Id = new string('y', 1_023), Name = new string('x', 1098848), PartitionKey = new string('x', 1_023) };
598+
var customer1 = new Customer { Id = new string('x', 1), Name = new string('x', 1098841 + 1_022), PartitionKey = new string('x', 1_023) };
599+
var customer2 = new Customer { Id = new string('y', 1_023), Name = new string('x', 1098841), PartitionKey = new string('x', 1_023) };
604600
if (oneByteOver)
605601
{
606602
customer1.Name += 'x';

0 commit comments

Comments
 (0)