File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.CommonTesting
Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1 Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 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.
@@ -24,16 +24,22 @@ namespace Google.Cloud.Spanner.Data.CommonTesting
2424 /// </summary>
2525 public abstract class SpannerTableFixture : SpannerFixtureBase
2626 {
27+ private readonly object _lock = new object ( ) ;
28+
2729 public string TableName { get ; }
2830
2931 public SpannerTableFixture ( string tableName )
3032 {
3133 TableName = tableName ;
32- if ( Database . Fresh )
34+ lock ( _lock )
3335 {
34- Logger . DefaultLogger . Debug ( $ "Creating table { TableName } ") ;
35- CreateTable ( ) ;
36+ if ( Database . Fresh )
37+ {
38+ Logger . DefaultLogger . Debug ( $ "Creating table { TableName } ") ;
39+ CreateTable ( ) ;
40+ }
3641 }
42+
3743 RetryHelpers . ResetStats ( ) ;
3844 Logger . DefaultLogger . Debug ( $ "Populating table { TableName } ") ;
3945 PopulateTable ( Database . Fresh ) ;
Original file line number Diff line number Diff line change @@ -154,7 +154,10 @@ 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 }
You can’t perform that action at this time.
0 commit comments