Spanner Emulator, CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly
See original GitHub issueHi
I would like to use Spanner Emulator for integration tests but when I use it with C# I get CallInvoker is set error. The below is step by step to produce the error also I am attaching the simple code I have written in C#.
// for some reason C# doesn't find the environment variable so setting it manually
Environment.SetEnvironmentVariable("SPANNER_EMULATOR_HOST", "localhost:9010");
string projectId = "project-local-emulator";
string instanceId = "test-instance";
var builder = new SpannerConnectionStringBuilder
{
DataSource = $"projects/{projectId}/instances/{instanceId}",
EmulatorDetection = EmulatorDetection.EmulatorOnly,
};
await using var connection = new SpannerConnection(builder);
string createStatement = $"CREATE DATABASE `test-db`";
var cmdcreate = connection.CreateDdlCommand(createStatement);
await cmdcreate.ExecuteNonQueryAsync();
Environment details
- OS: Mac OSX
- .NET Core 3.1
Steps to reproduce
- Followed the instruction on this page: https://cloud.google.com/spanner/docs/emulator
- Created an instance and a database
- Trying to connect to the spanner emulator via C# and I am getting the following error
System.InvalidOperationException: CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly
System.InvalidOperationException
CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly
at Google.Api.Gax.GaxPreconditions.CheckState[T1,T2,T3](Boolean condition, String format, T1 arg0, T2 arg1, T3 arg2)
at Google.Api.Gax.Grpc.ClientBuilderBase1.GetEmulatorEnvironment(IEnumerable
1 requiredEmulatorEnvironmentVariables, IEnumerable1 allEmulatorEnvironmentVariables, Func
2 environmentVariableProvider)
at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.MaybeCreateEmulatorClientBuilder()
at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.InterceptBuild(DatabaseAdminClient& client)
at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.Build()
at Google.Cloud.Spanner.Data.SpannerCommand.ExecutableCommand.ExecuteDdlAsync(CancellationToken cancellationToken)
at Google.Cloud.Spanner.Data.SpannerCommand.ExecutableCommand.ExecuteDdlAsync(CancellationToken cancellationToken)
Would appreciate your help, as the error above doesn’t really tell much what is wrong!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
This has now been released as part of the 3.3.0 set of libraries.
Hmmm… that’s definitely not what I’d expect. Will try to look into it this afternoon, but it may be Monday before I can get to it.