Skip to content

Commit 1c83cc4

Browse files
committed
chore: Add extra condition for emulator tests with concurrent txn
chore: Add extra condition for emulator tests with concurrent txn in ManagedSession chore: add a lock on test fixture table creation chore: Emulator changes chore: Skip paritioned tests on emulator chore: Will undo this commit
1 parent 02054e8 commit 1c83cc4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.CommonTesting/SpannerTableFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2018 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -29,11 +29,13 @@ public abstract class SpannerTableFixture : SpannerFixtureBase
2929
public SpannerTableFixture(string tableName)
3030
{
3131
TableName = tableName;
32+
3233
if (Database.Fresh)
3334
{
3435
Logger.DefaultLogger.Debug($"Creating table {TableName}");
3536
CreateTable();
3637
}
38+
3739
RetryHelpers.ResetStats();
3840
Logger.DefaultLogger.Debug($"Populating table {TableName}");
3941
PopulateTable(Database.Fresh);

apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.IntegrationTests/PartitionedReadTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using Google.Cloud.Spanner.Data.CommonTesting;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Linq;
@@ -30,6 +31,7 @@ public PartitionedReadTests(PartitionedReadTableFixture fixture) =>
3031
_fixture = fixture;
3132

3233
[SkippableTheory, CombinatorialData]
34+
[Trait(Constants.SupportedOnEmulator, Constants.No)]
3335
public async Task DistributedReadAsync(bool dataBoostEnabled)
3436
{
3537
// TODO: xUnit 3 will allow to set traits to individual data rows, and we should use that instead for consistency.
@@ -53,6 +55,7 @@ public async Task DistributedReadAsync(bool dataBoostEnabled)
5355
}
5456

5557
[SkippableTheory, CombinatorialData]
58+
[Trait(Constants.SupportedOnEmulator, Constants.No)]
5659
public async Task DistributedQueryAsync(bool dataBoostEnabled)
5760
{
5861
// TODO: xUnit 3 will allow to set traits to individual data rows, and we should use that instead for consistency.

apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/ManagedSession.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,15 @@ internal bool SessionHasExpired(double intervalInDays = SoftRefreshIntervalInDay
154154
{
155155
DateTime currentTime = _clock.GetCurrentDateTimeUtc();
156156
DateTime? sessionCreateTime = _session?.CreateTime.ToDateTime(); // Inherent conversion into UTC DateTime
157-
if (_session == null || _session.Expired || currentTime - sessionCreateTime >= TimeSpan.FromDays(intervalInDays))
157+
if (_session == null
158+
|| _session.Expired
159+
|| !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SPANNER_EMULATOR_HOST"))
160+
|| currentTime - sessionCreateTime >= TimeSpan.FromDays(intervalInDays))
158161
{
159162
return true;
160163
}
161164

162-
return false;
165+
return true;
163166
}
164167

165168
private async Task CreateOrRefreshSessionsAsync(CancellationToken cancellationToken)

0 commit comments

Comments
 (0)