Skip to content
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

Add basic emulator support with updated google-cloud-spanner #58

Merged
merged 2 commits into from Mar 16, 2021

Conversation

aeroastro
Copy link
Contributor

@jiren

This is not fully-functional support for Spanner Emulator, but the first step.

I have updated the google-cloud-spanner to 2.4 to include googleapis/google-cloud-ruby#8416,
and pass the emulator_host to Google::Cloud::Spanner.new.

This makes the following code working.

ActiveRecord::Base.establish_connection(
  adapter: :spanner,
  project: 'test-project',
  instance: 'test-instance',
  database: 'test-database',
  emulator_host: 'localhost:9010'
)

ActiveRecord::Base.tap(&:connection).connected?
# => true

The reasons why I omit the test codes are:

  • This part is not something to be fully tested.
  • Actually, I did not find existing test on checking the arguments passed to Google::Cloud::Spanner
  • In the future, I would like to run acceptance test with Spanner Emulator on CI, which is appropriate for testing the functionality

Although I confirmed that Spanner Emulator has an issue on ALTER TABLE, this introduced support will helps us a lot.

GoogleCloudPlatform/cloud-spanner-emulator#16

c.f. #48

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 9, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. label Mar 9, 2021
@skuruppu
Copy link
Collaborator

skuruppu commented Mar 9, 2021

@aeroastro, you can try putting a config similar to that of https://github.com/googleapis/google-cloud-ruby/blob/master/.github/workflows/spanner-integration-tests-against-emulator.yaml to get the acceptance tests running on this repo against the emulator. Let me know if you'd like help with it.

@aeroastro
Copy link
Contributor Author

@skuruppu
Yes, I am willing to do that.
There are several things I would like you to consider:

  • I am going to be busy this March, so implementing the emulator in CI would be scheduled later.
  • I confirmed there is a need to change some code in acceptance Rake Task, in addition to skipping table ALTER TABLE. So, I would like to implement it with another Pull Request.

@skuruppu
Copy link
Collaborator

@jiren if you could please review this PR, that would be awesome.

@jiren
Copy link
Member

jiren commented Mar 14, 2021

@aeroastro Thanks

@skuruppu skuruppu merged commit ebd9b7b into googleapis:master Mar 16, 2021
@aeroastro aeroastro deleted the feature/update-spanner-version branch March 17, 2021 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants