Skip to content

pubsub: fix testStartStopReset #1453

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

Merged
merged 2 commits into from
Dec 8, 2016
Merged

pubsub: fix testStartStopReset #1453

merged 2 commits into from
Dec 8, 2016

Conversation

pongad
Copy link
Contributor

@pongad pongad commented Dec 7, 2016

The test verifies that calling stop() actually stops the emulator.
The previous implementation stops the emulator by

  • sending HTTP POST to /shutdown
  • terminating the emulator process
    The second step follows directly after the first.
    It then queries the server it just shut down to make sure it does not
    respond.

This behavior is incorrect for two reasons.

  • The server might continue serving request after responding to
    /shutdown.
  • The "emulator process" might not be the emulator at all.
    It might be a script that in-turn runs the emulator.
    On UNIX systems, killing a parent process does not kill any of its
    children; the actual emulator might run indefinitely after
    we kill the process we spawned.

This commit changes this behavior.
After POSTing to /shutdown, we simply wait for the spawned process
to terminate on its own.

Technically, there is still a race:
Another emulator could have been started on the same port.
When we send a request to verify that the old emulator has terminated,
we might get a response from the new one.
Since we execute tests sequentially though,
I believe this should not be a problem in practice.

Updates #1429.

The test verifies that calling stop() actually stops the emulator.
The previous implementation stops the emulator by
- sending HTTP POST to /shutdown
- terminating the emulator process
The second step follows directly after the first.
It then queries the server it just shut down to make sure it does not
respond.

This behavior is incorrect for two reasons.
- The server might continue serving request after responding to
  /shutdown.
- The "emulator process" might not be the emulator at all.
  It might be a script that in-turn runs the emulator.
  On UNIX systems, killing a parent process does not kill any of its
  children; the actual emulator might run indefinitely after
  we kill the process we spawned.

This commit changes this behavior.
After POSTing to /shutdown, we simply wait for the spawned process
to terminate on its own.

Technically, there is still a race:
Another emulator could have been started on the same port.
When we send a request to verify that the old emulator has terminated,
we might get a response from the new one.
Since we execute tests sequentially though,
I believe this should not be a problem in practice.

Updates #1429.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 7, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 83.52% when pulling 55a7d1a on pongad:pubsub-test into b24ec1a on GoogleCloudPlatform:master.

if (process != null) {
process.destroy();
process.waitFor();

This comment was marked as spam.

@pongad
Copy link
Contributor Author

pongad commented Dec 8, 2016

@garrettjonesgoogle PTAL, we now raises an exception if process has not finished in specified time.

raises exception if we cannot stop the emulator.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 83.534% when pulling 2927478 on pongad:pubsub-test into b24ec1a on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 84b12ba on pongad:pubsub-test into ** on GoogleCloudPlatform:master**.

@garrettjonesgoogle garrettjonesgoogle merged commit 4567c49 into googleapis:master Dec 8, 2016
@pongad pongad deleted the pubsub-test branch December 12, 2016 03:33
github-actions bot pushed a commit that referenced this pull request Aug 25, 2022
🤖 I have created a release *beep* *boop*
---


## [2.3.6](googleapis/java-bigquerydatatransfer@v2.3.5...v2.3.6) (2022-08-24)


### Dependencies

* update dependency com.google.cloud:google-cloud-pubsub to v1.120.13 ([#1452](googleapis/java-bigquerydatatransfer#1452)) ([29121bf](googleapis/java-bigquerydatatransfer@29121bf))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants