GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — improve LocalDatastoreHelper docs. · Issue #2800 · googleapis/google-cloud-java

improve LocalDatastoreHelper docs. #2800

New issue
Copy link
New issue
Copy link
Closed
Closed
improve LocalDatastoreHelper docs.#2800
Copy link
Assignees
pongad
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@ensonic
ensonic
opened on Jan 22, 2018
Issue body actions

It would be nice to improve the javadocs for
http://googlecloudplatform.github.io/google-cloud-java/0.9.2/apidocs/com/google/cloud/datastore/testing/LocalDatastoreHelper.html

Especially the docs for reset look like generated docs string :). Please tell when one would call reset.

E.g. Does this setup for junit make sense? What bout including the code snippet into the docs?

  private static final LocalDatastoreHelper datastoreHelper = ...

  @BeforeClass
  public static void setUpOnce() throws Exception {
    datastoreHelper.start();
  }

  @AfterClass
  public static void tearDownOnce() throws Exception {
    datastoreHelper.stop(Duration.ofSeconds(5));
  }

  @Before
  public void setUp() throws Exception {
    datastoreHelper.reset();
  }

For start()/stop() it would be interesting to be explicit and tell if there is going to be any state (e.g. should I call reset() before calling stop()).

Activity

  1. pongad
    assigned
    pongad
    and
    jabubake
    and unassigned
    pongad
    on Jan 24, 2018
  2. pongad commented on Jan 24, 2018

    @pongad
    pongad
    on Jan 24, 2018
    Contributor
    More actions

    @ensonic I believe LocalDatastoreHelper has been deprecated. My reasoning (others might have different opinions) was that it's difficult to managed the emulator process, especially dealing with its I/O.

    That said, the emulator isn't very well documented. @jabubake Do you happen to know who owns the emulator's documentations? If nothing else, we should probably document the reset and shutdown endpoints. I think it can be done in a cross-language way.

  3. ensonic commented on Jan 24, 2018

    @ensonic
    ensonic
    on Jan 24, 2018
    Author
    More actions

    Is there a replacement for LocalDatastoreHelper? I found this quite useful (together with the LocalStorageHelper) to run unit tests not against real instances.
    You say the 'emulator process is difficult to manage', what are the issues. If you deprecate this helper, people will attempt to replicate the code and run into the same issues, right? At some point one needs to setup the emu.

    An alternative would be to have a LocalDatastoreHelper that works more like the LocalStorageHelper, where one would load test data from e.g. json files.

  4. pongad commented on Jan 25, 2018

    @pongad
    pongad
    on Jan 25, 2018
    Contributor
    More actions

    @garrettjonesgoogle for visibility.

    It's possible to start the emulator process yourself with gcloud beta emulators datastore start.

    I'll explain my reasoning a little more.

    In the current implementation, the helper tries to find the emulator installed on your machine. Failing that, it downloads the emulator itself and runs it. I humbly opine it reaches uncomfortably far behind the user's back. This is a reason to change the helper though, and not necessarily one for deprecating it altogether.

    About process control; this argument is a little long, but I promise it's not a rant :). Emulators could print diagnostic messages to stdout/stderr. (I'm not 100% sure about datastore, but pubsub does.) IIUC, there's currently no way for users to see these, as the helper swallows all of them. Of course, we could provide an InputStream that user code can read from. But then if you don't read from the stream, the emulator gets stuck. We could provide a way to optionally read. By that point though, we would have re-implemented (or at least re-exposed) most of the Java's Process API. Shutting down the emulator was also a frequent cause of deadlocks in the past, though I believe I fixed the most frequent causes: races between the emulator process and the thread reading the stdout. Essentially, the helper tries to hide the fact that there's an emulator process running, but it's not doing a very good job.

    However, the shell already works well (or, at least, better). It's trivial to store logs (gcloud beta emulators datastore start &> /tmp/emulog.txt) and initiate shutdown (curl -XPOST $DATASTORE_EMULATOR_HOST/shutdown). I think the client libraries can help by making connecting to already-running emulators easier, etc. However, I think we should avoid creating a "thick abstraction". IMHO, it doesn't provide enough value over other tools programmers have at their disposal.

    Am I making any sense?

    The Datastore does allow you to load test data from disk. It doesn't document any specific format though. It's possible for you to get the emulator to a state you want once, then copy the data files for subsequent testing.

  5. pongad
    added
    documentation
    on Jan 25, 2018
  6. jabubake commented on Jan 25, 2018

    @jabubake
    jabubake
    on Jan 25, 2018
    Contributor
    More actions

    @pongad : I agree, it would be good if the Datastore library could be dependent on an environment variable consistent w/ the Pub/Sub emulator support in google-cloud-java.
    I'll look into updating the emulator docs. Un-assigning myself from this ticket.

  7. jabubake
    removed their assignment
    on Jan 25, 2018
  8. ensonic commented on Jan 26, 2018

    @ensonic
    ensonic
    on Jan 26, 2018
    Author
    More actions

    Thanks for all the explanations. I agree that there is no easy solutions. From the users perspective I am looking for an 'easy' way to run tests on a developer machine and on CI. On CI it is realative easy to bring up the emulators, since one usually runs the CI actions as a script. For developers right now it is bazel test /... and so far the LocalDatastoreHelper served us well.

  9. pongad
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    and removed
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Jan 30, 2018
  10. pongad commented on Jan 30, 2018

    @pongad
    pongad
    on Jan 30, 2018
    Contributor
    More actions

    An update. Here's is my current thinking, it's not an official plan yet. cc @igorbernstein2

    I'll treat this is documentation bug. We'll fix the docs, but won't stabilize the surface of the emulator helper yet.

    BigTable also needs an emulator. Igor, let's iterate on the emulator design. I hope we can decide on one that works for both APIs.

  11. pongad
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Jan 30, 2018
  12. igorbernstein2 commented on Jan 30, 2018

    @igorbernstein2
    igorbernstein2
    on Jan 30, 2018
    Contributor
    More actions

    I'll send over a design doc by early next week

  13. ensonic commented on Jan 31, 2018

    @ensonic
    ensonic
    on Jan 31, 2018
    Author
    More actions

    Thanks. Better docs are always a good step. I'd welcome, discussing the future testing support in a ticket to give others a chance to comment too.

  14. pongad
    closed this as completedin #2828on Feb 5, 2018
  15. pongad
    added a commit that references this issue on Feb 5, 2018

    datastore: better document emulator functions (#2828)

    This issue will close once commit b5fb39c is merged into the 'main' branch.
    b5fb39c
  16. JustinBeckwith
    assigned
    pongad
    on Feb 1, 2021
  17. chingor13
    added a commit that references this issue on Feb 20, 2026

    chore(main): release 3.11.1-SNAPSHOT (#2800)

    6ec8bf5
  18. suztomo
    added a commit that references this issue on Mar 9, 2026

    chore(main): release 2.30.2-SNAPSHOT (#2800)

    c0b01e9
  19. chingor13
    added 5 commits that reference this issue on Mar 24, 2026

    deps: update dependency watchdog to v4.0.1 (#2800)

    fa53f78

    chore(main): release 2.41.0 (#2820)

    86b29e1

    feat: add FLOAT32 enum to TypeCode (#2800)

    ccab146

    chore(main): release 6.57.0 (#2782)

    a64b9d2

    chore: Use Protobuf Message instead of GeneratedMessageV3 (#2800)

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

Metadata

Metadata

Assignees

  • @pongad
    pongad

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.