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

Firestore: add emulator support #7500

Closed
lkollar opened this issue Mar 12, 2019 · 4 comments · Fixed by #8721
Closed

Firestore: add emulator support #7500

lkollar opened this issue Mar 12, 2019 · 4 comments · Fixed by #8721
Assignees
Labels
api: firestore Issues related to the Firestore API. status: duplicate Duplicate. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@lkollar
Copy link

lkollar commented Mar 12, 2019

Is your feature request related to a problem? Please describe.
The library does not respect the FIRESTORE_EMULATOR_HOST environment variable thus it cannot be used with the emulator.
Describe the solution you'd like
Respect the FIRESTORE_EMULATOR_HOST environment variable and connect to the emulator when set.
Describe alternatives you've considered
None. If there are other ways to use the emulator with the library they are not documented.

@tseaver tseaver added status: duplicate Duplicate. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: firestore Issues related to the Firestore API. labels Mar 12, 2019
@tseaver
Copy link
Contributor

tseaver commented Mar 12, 2019

See #4840.

@mnoseworthy
Copy link

mnoseworthy commented Mar 20, 2019

Preamble: I haven't looked at much of the source code for the project at all and have just been happily using it straight from pip. But now we're looking to handle a local test stack for our application, and want to use the beta Firestore Emulator from a Python runtime

As a hack, could we instantiate a transport object pointing to the local endpoint of the simulator and bind that to a Client object?

I'm assuming that if it was this easy the FIRESTORE_EMULATOR_HOST envar would already be supported. I'll give this a shot and update.

Edit: Forgot that we also need access from a .NET runtime, so I've sort of scrapped this idea as it's probably not worth the time.

@therefromhere
Copy link

therefromhere commented May 23, 2019

@mnoseworthy I think this works: https://gist.github.com/therefromhere/5acc827ec7a27db9edcb24fe2ece7d37

edit: it works for testing Firestore rules for an un-authenticated user - I haven't figured out how to authenticate as admin or as a uid yet.

@mf2199
Copy link
Contributor

mf2199 commented Jul 9, 2019

With live Firestore, all the system tests pass. With the emulator, out of the 24 tests in total, 17 pass and 7 fail. The reasons are yet to be determined, for the following error messages:

4 tests showing error "Few assertion failed with emulator, but works with real one."
test_update_document(client, cleanup),
test_query_stream(client, cleanup),
test_get_all(client, cleanup),
test_batch(client, cleanup):

2 tests failing with "PermissionDenied: 403 Metadata operations require admin authentication. which received in two test":
test_create_document_w_subcollection(client, cleanup)
test_collection_add(client, cleanup)

1 test showing "entity already exists: so DID NOT RAISE <class 'google.api_core.exceptions.InvalidArgument'>":
assert_timestamp_less(timestamp_pb1, timestamp_pb2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. status: duplicate Duplicate. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
6 participants