Uh oh!
There was an error while loading. Please reload this page.
I have a python function that runs on firestore document changes. How do I emulate and test integration with storage locally? |
Replies: 7 comments
Install Install the firestore emulator: Write a basic "background" function: defhello(data, context):
print(data, context)Install the Functions Framework: In one terminal, start the Functions Framework (by default this will be on In a second terminal, start the emulator (on a different port, Register a trigger with the firestore emulator: Install the Firestore client library (using Python here but it can be any client library): Write a script to trigger a write: fromgoogle.cloudimportfirestoreclient=firestore.Client(project="my-project")
client.collection("my-collection").add(document_data={"foo": "bar"})In a third terminal, trigger a write: Observe the function being triggered by the emulator in the first terminal: |
This is such a detailed reply. Thank you very much @di ! :) |
I have 2 more questions.
|
Happy to help!
If you mean Cloud Storage for Firebase, correct. From https://firebase.google.com/docs/emulator-suite#feature-matrix:
There's a feature request for this here: firebase/firebase-tools#1738
I'm not very familiar with the firebase emulator, but it seems like it's not possible to start the emulator via This might be a good question for the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @di I followed your step-by-step instructions, but it is not working. When I checked the firebase-debug.log I find these logs: [debug] [2021-03-08T23:18:40.086Z] Accepted request POST /functions/projects/{project Id}/triggers/Test --> Test {"metadata":{"emulator":{"name":"functions"},"message":"Accepted request POST /functions/projects/{project id}/triggers/Test --> Test"}} I think I am missing something about registering the trigger "Test" somewhere, the one is referring to in the PUT endpoint: Is there any configuration missing? Thanks in advance! |
@lfpazmino Sorry, I can't really help with the Firebase emulator here. This might be a good issue for the https://github.com/firebase/firebase-tools/ repo or a question for the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In case someone needs firestore emulator as docker container to use for testing: |
Install
firebase-tools:Install the firestore emulator:
Write a basic "background" function:
Install the Functions Framework:
In one terminal, start the Functions Framework (by default this will be on
localhost:8080):In a second terminal, start the emulator (on a different port,
localhost:8081) and tell it which host/port to use for the functions emulator: