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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ protected final void startProcess(String blockUntilOutput)
}

/**
* Stops the local service's subprocess and any possible thread listening for its output.
* Waits for the local service's subprocess to terminate,
* and stop any possible thread listening for its output.
*/
protected final void stopProcess() throws IOException, InterruptedException {
protected final void waitForProcess() throws IOException, InterruptedException {
if (blockingProcessReader != null) {
blockingProcessReader.terminate();
blockingProcessReader = null;
}
if (activeRunner != null) {
activeRunner.stop();
activeRunner.waitFor();
activeRunner = null;
}
}
Expand Down Expand Up @@ -195,9 +196,9 @@ protected interface EmulatorRunner {
void start() throws IOException;

/**
* Stops the emulator associated to this runner.
* Wait for the emulator associated to this runner to terminate.
*/
void stop() throws InterruptedException;
void waitFor() throws InterruptedException;

/**
* Returns the process associated to the emulator, if any.
Expand Down Expand Up @@ -239,9 +240,8 @@ public void start() throws IOException {
}

@Override
public void stop() throws InterruptedException {
public void waitFor() throws InterruptedException {
if (process != null) {
process.destroy();
process.waitFor();
}
}
Expand Down Expand Up @@ -337,9 +337,8 @@ public void start() throws IOException {
}

@Override
public void stop() throws InterruptedException {
public void waitFor() throws InterruptedException {
if (process != null) {
process.destroy();
process.waitFor();

This comment was marked as spam.

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void start() throws IOException, InterruptedException {

@Override
public void stop() throws IOException, InterruptedException {
stopProcess();
waitForProcess();
}

@Override
Expand All @@ -86,7 +86,7 @@ public void testEmulatorHelper() throws IOException, InterruptedException {
emulatorRunner.start();
EasyMock.expectLastCall();
EasyMock.expect(emulatorRunner.getProcess()).andReturn(process);
emulatorRunner.stop();
emulatorRunner.waitFor();
EasyMock.expectLastCall();
EasyMock.replay(process, emulatorRunner);
TestEmulatorHelper helper =
Expand All @@ -108,7 +108,7 @@ public void testEmulatorHelperMultipleRunners() throws IOException, InterruptedE
secondRunner.start();
EasyMock.expectLastCall();
EasyMock.expect(secondRunner.getProcess()).andReturn(process);
secondRunner.stop();
secondRunner.waitFor();
EasyMock.expectLastCall();
EasyMock.replay(process, secondRunner);
TestEmulatorHelper helper =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void reset() throws IOException {
*/
public void stop() throws IOException, InterruptedException {
sendPostRequest("/shutdown");
stopProcess();
waitForProcess();
deleteRecursively(gcdPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ public void reset() throws IOException {
@Override
public void stop() throws IOException, InterruptedException {
sendPostRequest("/shutdown");
stopProcess();
waitForProcess();
}
}