-
Notifications
You must be signed in to change notification settings - Fork 292
fix: honour Spanner emulator detection in outbox/inbox connections (#4162) #4225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iancooper
wants to merge
2
commits into
master
Choose a base branch
from
fix/4162-spanner-emulator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0003-pump-span-leak-exception-paths | ||
| 0004-spanner-emulator-detection |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 4162 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...a_spanner_connection_provider_opens_a_connection_it_should_honour_the_spanner_emulator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System.Data; | ||
| using System.Threading.Tasks; | ||
| using Google.Cloud.Spanner.Data; | ||
| using Paramore.Brighter.Gcp.Tests.Helper; | ||
| using Paramore.Brighter.Spanner; | ||
| using Xunit; | ||
|
|
||
| namespace Paramore.Brighter.Gcp.Tests.Spanner.Connection; | ||
|
|
||
| [Trait("Category", "Spanner")] | ||
| public class SpannerConnectionProviderEmulatorTests | ||
| { | ||
| // A bare connection string with no EmulatorDetection keyword — the shape production code | ||
| // receives via RelationalDatabaseConfiguration. Built inline (not via Const) so this test | ||
| // stays scoped to the provider's own emulator handling even after Const is patched. | ||
| private readonly string _bareConnectionString = | ||
| $"Data Source=projects/{GatewayFactory.GetProjectId()}/instances/brighter-spanner/databases/brightertests"; | ||
|
|
||
| [Fact] | ||
| public async Task When_a_spanner_connection_provider_opens_a_connection_it_should_honour_the_spanner_emulator() | ||
| { | ||
| // Arrange | ||
| var configuration = new RelationalDatabaseConfiguration(_bareConnectionString); | ||
| var provider = new SpannerConnectionProvider(configuration); | ||
|
|
||
| // Act | ||
| await using var connection = await provider.GetConnectionAsync(); | ||
|
|
||
| using var command = ((SpannerConnection)connection).CreateSelectCommand("SELECT 1"); | ||
| var result = (long)(await command.ExecuteScalarAsync())!; | ||
|
|
||
| // Assert | ||
| Assert.Equal(ConnectionState.Open, connection.State); | ||
| Assert.Equal(1L, result); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| using Paramore.Brighter.Gcp.Tests.Helper; | ||
| using Google.Api.Gax; | ||
| using Google.Cloud.Spanner.Data; | ||
| using Paramore.Brighter.Gcp.Tests.Helper; | ||
|
|
||
| namespace Paramore.Brighter.Gcp.Tests.Spanner; | ||
|
|
||
| public static class Const | ||
| { | ||
| public static string ConnectionString => $"Data Source=projects/{GatewayFactory.GetProjectId()}/instances/brighter-spanner/databases/brightertests"; | ||
| // Embed EmulatorDetection into the connection string so it round-trips through | ||
| // RelationalDatabaseConfiguration into the tests' own DDL connections and the outbox/inbox's | ||
| // internal connections, routing to SPANNER_EMULATOR_HOST when set instead of demanding ADC. | ||
| public static string ConnectionString => new SpannerConnectionStringBuilder( | ||
| $"Data Source=projects/{GatewayFactory.GetProjectId()}/instances/brighter-spanner/databases/brightertests") | ||
| { | ||
| EmulatorDetection = EmulatorDetection.EmulatorOrProduction | ||
| }.ConnectionString; | ||
|
|
||
| public const string TablePrefix = "test_"; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be done in the
IAmARelationalDatabaseConfiguration?Like