googleapis / google-cloud-go

Google Cloud Client Libraries for Go.
https://cloud.google.com/go/docs/reference
Apache License 2.0
3.78k stars 1.3k forks source link

spannertest: rollback of transactions in spannertest #2824

Open jrmeinride opened 4 years ago

jrmeinride commented 4 years ago

Is your feature request related to a problem? Please describe. We have a solution that uses three separate tables. Any update to the data should update rows in all, or none of the tables.

We have written code that return the corresponding mutations, and now we want to ensure that CRUD works as intended. On a first glance it seemed like there was transaction support in spannertest: https://github.com/googleapis/google-cloud-go/blob/master/spanner/spannertest/inmem.go#L663-L725

However the rollback does not do anything yet: https://github.com/googleapis/google-cloud-go/blob/92af398bdb5e7536f15945485980dc8736597227/spanner/spannertest/db.go#L143-L148

Describe the solution you'd like We would love for spannertest to roll back transactions when there is an error. That way we can keep relying on spannertest for our unit tests in our CI/CD environment.

Describe alternatives you've considered We have considered running the Cloud Spanner Emulator in our tests, however that will not play nice with our CI/CD setup. It does work when testing locally, which gives us some confidence in our solution, however having the proper support in spannertest would be better.

Additional context

dsymonds commented 4 years ago

Yes, the transaction support in spannertest is very skint, and unfortunately unlikely to improve a lot in the near future. There's multiple TODOs in the code.