Skip to content
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

Fix #21: connect and disconnect on the background executor #22

Merged
merged 3 commits into from
Mar 23, 2017

Conversation

jhansche
Copy link
Contributor

TubeSock already uses a background thread for open(), but it keeps the
close() call on the calling thread. So open() is safe on the main thread,
but close() is not.

…utor

TubeSock already uses a background thread for `open()`, but it keeps the
`close()` call on the calling thread. So `open()` is safe on the main thread,
but `close()` is not.
Copy link
Contributor

@rogerhu rogerhu left a comment

Choose a reason for hiding this comment

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

lgtm -thanks.

@rogerhu
Copy link
Contributor

rogerhu commented Mar 23, 2017

@jhansche
Copy link
Contributor Author

I'll look into that. I'm not sure what can be tested other than ensuring it doesn't run on the UI thread -- but I'm pretty sure the tests are intentionally swapping the executor with a blocking, same-thread executor, so it might be a little difficult to test that unless we make a different mock that uses a different thread.

@jhansche
Copy link
Contributor Author

I wrote a quick PauseableExecutor that I can swap in during a test, and it looks to be working 👍 See 312c1b8

}, executor);

reconnect();
executor.pause();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is basically https://github.com/ParsePlatform/Parse-SDK-Android/blob/master/Parse/src/test/java/com/parse/TaskQueueTestHelper.java#L24-L59 right?

Can you just queue/dequeue instead of needing to have pause logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent of pause/unpause (including their names) is inspired by the Robolectric scheduler mocks, which allow pausing (must manually advance), unpausing (runs everything blocking), and advancing a paused scheduler one task at a time.

In this case, the TaskQueueTestHelper would not work for us here, because the LiveQuery client expects an Executor, not a TaskQueue.

And the TaskQueueTestHelper actually is pausing and unpausing the TaskQueue (the javadoc even explicitly says "pauses the TaskQueue") -- so I'm not sure that I agree with the naming of that class's methods. "enqueue" and "dequeue" does not imply in any way that it will block or pause the TaskQueue: "Enqueue" means that it is adding a task to the queue, nothing else.

If the ParseLiveQueryClientImpl were actually using a TaskQueue, then we could make use of that class; but it doesn't use TaskQueue at all.

I think for the purposes of a text fixture, it really doesn't matter what it's called. My vote would be for pause and unpause… but I'm happy to rename the method if you think that would be a point of confusion?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah just wondering...anyways thanks for looking at it.

The end result will be the same for all the other tests, since it will only
queue up tasks while it is paused, and it is unpaused by default.

To control when the tasks run, the test should first pause the executor
before the tasks get enqueued.
@rogerhu rogerhu merged commit 3b0041d into parse-community:master Mar 23, 2017
@jhansche
Copy link
Contributor Author

@rogerhu quick question: I see that the Travis job is configured to run scripts/publish_snapshot.sh, but I haven't been able to find the actual snapshot(s). I didn't see them on oss: https://oss.sonatype.org/content/repositories/snapshots/com/parse/

@jhansche
Copy link
Contributor Author

Ahh, I see now: it's failing with 401 Unauthorized:
https://s3.amazonaws.com/archive.travis-ci.org/jobs/214437296/log.txt

For some reason the Travis console log doesn't show that failure, but the "raw log" does: https://travis-ci.org/ParsePlatform/ParseLiveQuery-Android/builds/214437295

@rogerhu
Copy link
Contributor

rogerhu commented Mar 23, 2017

Yeah we need to add our credentials to Travis (NEXUS_USERNAME/NEXUS_PASSWORD).

http://stackoverflow.com/questions/12343452/how-to-publish-artifacts-in-travis-ci

I opened a ticket with Sonatype to get push access, can add it I believe...unless someone else wants to beat me to it.

@jhansche
Copy link
Contributor Author

Got it. I opened #26 to track this. I don't know anything about how Travis is setup or configured, so I can't help.
Thanks

@jhansche jhansche deleted the pr/fix-21 branch March 23, 2017 22:20
@mmimeault
Copy link
Contributor

mmimeault commented Mar 23, 2017 via email

@mmimeault
Copy link
Contributor

I relaunched one of the master merged and the snapshot seem to be released:
https://oss.sonatype.org/content/repositories/snapshots/com/parse/parse-livequery-android/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants