-
Notifications
You must be signed in to change notification settings - Fork 4
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
Set up Firebase Emulators #74
Conversation
… app Co-authored-by: KK Lamberty <lamberty@morris.umn.edu>
This adds a small set of test data, "demo-session" and "demo-round" that matches what we have in production Firestore at the moment. It can be used with the `--import` parameter when running the Firebase emulators. This also creates a npm script `npm run firebase:emulator` that starts the emulator for just Firestore and imports the test data. Co-authored-by: KK Lamberty <lamberty@morris.umn.edu>
Co-authored-by: KK Lamberty <lamberty@morris.umn.edu>
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mn-pollinators/buzz-about/56n4znlbv |
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.
Oh, gosh, it looks like you've got a wonky compatibility issue here!
So, you know those those test-data binary files y'all made, right? It seems like, inside them, Firebase is storing some file paths—but those paths use backslashes as a path separator 😛
/home/joemoonan/Documents/Pollinators/buzz-about/firebase-test-data/firestore_export/all_namespaces\all_kinds\all_namespaces_all_kinds.export_metadata (No such file or directory)
What happens:
When you try to run npm firebase:emulate
on a Unix system, the script dies with the following output:
joemoonan buzz-about $ npm run firebase:emulator
> buzz-about@0.0.0 firebase:emulator /home/joemoonan/Documents/Pollinators/buzz-about
> firebase emulators:start --only firestore --import firebase-test-data
i emulators: Starting emulators: firestore
i firestore: Importing data from /home/joemoonan/Documents/Pollinators/buzz-about/firebase-test-data/firestore_export/firestore_export.overall_export_metadata
i firestore: Firestore Emulator logging to firestore-debug.log
Error: firestore: Firestore Emulator has exited with code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! buzz-about@0.0.0 firebase:emulator: `firebase emulators:start --only firestore --import firebase-test-data`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buzz-about@0.0.0 firebase:emulator script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/joemoonan/.npm/_logs/2020-07-08T05_02_28_016Z-debug.log
Funnily enough, the firebase emulator doesn't even exit cleanly; at the end of this command, it stays running in the background. (You can stop the background instance by running firebase emulators:start --only firestore
to start another instance of the emulator, and then pressing ^C
to stop all emulators.)
I've attached the two log files that were generated, firestore-debug.log
and 2020-07-08T05_02_28_016Z-debug.log
, below. The former is where I found the file path quoted above; the latter doesn't seem to have anything useful in it; it's just npm saying "Oh, the humanity!".
Other salient information:
When I try to make my own test-data binary files on Unix, I can import them just fine; because of this, I bet that the backslashes occur when you export the data on Windows. (Whether there's a way to get Windows to use forward-slashes, I have no idea 🤷🏻♂️)
Sorry to be the bearer of bad news :-(
Log files:
Very interesting @helloworld12321. Looks like when you export on Windows it uses The solution at the moment may be that we have to export on *nix (or maybe we can get away with manually changing the paths). As far as I know Windows actually handles both |
Ooh, nice find on that issue! I wonder, would it make sense to populate the database programmatically as part of the test suite? (That also would give us a degree of flexibility—for example, we'd be able to test the teacher-side with & without a previous session that they could resume.) If not, though, then only exporting from Unix seems like a reasonable stopgap until the upstream folks fix this issue. 🙂 |
Yeah for testing the plan indeed is to setup stuff in the database during the test. We just need this basic demo data for local development at the moment. Once we have session and round creation though we won't need to be seeding it. |
Co-authored-by: Joe Walbran <walbr037@morris.umn.edu>
So for the moment if you are using Windows and export new data, please don't commit the changed |
It was a string instead of a number
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.
All right, everything looks good, thanks!
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.
I didn't have any issues running the emulator
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.
Working for me.
The major change here is that when you are running the dev server through
ng serve
it will be set to use the Firebase emulators for Firestore rather than the live production database. This was configured in theenvironment.ts
andapp.module.ts
files. Authentication still happens against the live Firebase instance though.We have setup a NPM script to run the emulator with settings that are most applicable to us currently. It is
npm run firebase:emulator
. This currently runsfirebase emulators:start --only firestore --import firebase-test-data
.You should run the emulators at the same time as running
ng serve
. It provides a graphical web interface that is similar to the real Firebase dashboard. The command will tell you how to access it when you start the emulators.We have setup a set of test data consisting of the
demo-session
anddemo-round
we already had in production. This was exported to thefirebase-test-data
directory and will be imported with the command described above. If you want to update this test data, make the changes you want in the local Firestore and runfirebase emulators:export firebase-test-data
.