Skip to content

Firestore: add emulator support - #5924

Merged
BenWhitehead merged 8 commits into
googleapis:masterfrom
thebrianchen:bc/emulator
Aug 2, 2019
Merged

Firestore: add emulator support#5924
BenWhitehead merged 8 commits into
googleapis:masterfrom
thebrianchen:bc/emulator

Conversation

@thebrianchen

Copy link
Copy Markdown

Context b/134525351

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 30, 2019
@codecov

codecovBot commented Jul 30, 2019

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@c16d98f). Click here to learn what that means.
The diff coverage is 4.16%.

Impacted file tree graph

@@ Coverage Diff @@## master #5924 +/- ##
=========================================
Coverage ? 46.12% Complexity ? 24189 =========================================
Files ? 2456 Lines ? 262273 Branches ? 29603 =========================================
Hits ? 120965 Misses ? 132196 Partials ? 9112
Impacted FilesCoverage ΔComplexity Δ
...a/com/google/cloud/firestore/FirestoreOptions.java36.13% <4.16%> (ø)7 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c16d98f...53f522d. Read the comment docs.

@chingor13chingor13 changed the title Add emulator support for google-cloud-javaFirestore: add emulator supportJul 30, 2019
@schmidt-sebastianschmidt-sebastian self-assigned this Jul 30, 2019

@schmidt-sebastianschmidt-sebastian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically looks good, but I think it is missing the port assignment (if the port is provided).

@BenWhiteheadBenWhitehead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the bug linked, admin operations should succeed but I'm seeing a number of tests from com.google.cloud.firestore.it.ITSystemTest fail with com.google.cloud.firestore.FirestoreException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Metadata operations require admin authentication

@BenWhiteheadBenWhitehead removed their assignment Jul 30, 2019
@thebrianchenthebrianchen removed their assignment Jul 30, 2019

@thebrianchenthebrianchen left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved comments. Are we standardizing all SDKs to use FIRESTORE_EMULATOR_HOST, or is it ok for individual SDKs to come up with their own names?
@schmidt-sebastian

+ FIRESTORE_EMULATOR_SYSTEM_PROPERTY
+ " is not a valid host",
e);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract this into a helper method validateUrl?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using this anywhere else, and the error code is pretty specific in that it's checking for the host.

@BenWhitehead
BenWhitehead merged commit 73fbc45 into googleapis:masterAug 2, 2019
@SylvainAssemat

SylvainAssemat commented Sep 7, 2019

Copy link
Copy Markdown

Hi all
I dont know if i could post my trouble here about the PERMISSION_DENIED: Metadata operations require admin authentication when i try to use the firestore emulator

[firestore] export FIRESTORE_EMULATOR_HOST=127.0.0.1:8772
[firestore]
[firestore] Dev App Server is now running.

I can not find a working solution for my project GAE / spring boot
I can not find on the web any clue or snippet.

Can you help me ?

Firestore db = FirestoreOptions.newBuilder()
.setHost("localhost:8772")
.setProjectId("xxxxx")
//.setCredentials(GoogleCredentials.getApplicationDefault())
//.setHeaderProvider(FixedHeaderProvider.create("Authorization", "Bearer owner"))
.setCredentials(credentials)
//.setDatabaseId("(default)")
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build().getService();

The CURL is OK (http 200)

curl -X POST \
http://localhost:8772/v1/projects/xxxxx/databases/(default)/documents:listCollectionIds \
-H 'Authorization: Bearer owner' \

google-cloud-core-grpc-1.90.0
google-cloud-firestore-1.20.0
google-cloud-bom 0.108.0-alpha

@schmidt-sebastian

Copy link
Copy Markdown
Contributor

You need to provide the Authorization: Bearer owner header for ListDocuments and ListCollectionIDs (which you have commented out). Your best bet is to just use the emulator environment variable, which the SDK uses to configure itself. In you case this seems to be FIRESTORE_EMULATOR_HOST=localhost:8772.

It's usually best to open a GitHub issue for questions like these since it is pretty easy to miss a comment on a merged GitHub PR :)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@thebrianchen@SylvainAssemat@schmidt-sebastian@ryanpbrewster@BenWhitehead@googlebot