Should RLB testing API block on the dispatcher?
Categories
(Data Platform and Tools :: Glean: SDK, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: Dexter, Assigned: janerik)
Details
Attachments
(1 file)
The current RLB testing APIs block on the dispatcher being outside of test mode. This makes the behaviour slightly different than the other bindings. Consider this test case:
- create a metric;
- check that it contains nothing (blocks);
- init glean.
In Kotlin, the above test is possible:
- the dispatcher is in test mode, so executes things on the main thread;
- (2) will simply return that no value is stored.
Comment 1•5 years ago
|
||
I'm open to design changes here. FOG's test story is three boxes, each half-full of sharp corners, at the moment.
| Reporter | ||
Comment 2•5 years ago
|
||
(In reply to Chris H-C :chutten from comment #1)
I'm open to design changes here. FOG's test story is three boxes, each half-full of sharp corners, at the moment.
Sure! But note that this is really an SDK-decision more than a FOG-decision ;-)
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 3•5 years ago
|
||
Note: on e.g. Swift the task still runs off-the-main thread, but the main thread blocks while it waits for the task to finish. The observable behavior is the same, but it might matter where stuff runs.
The current RLB testing APIs block on the dispatcher being outside of test mode.
I don't fully understand this phrasing, so here's my try at summarizing the current behavior:
RLB test methods block on the queue emptying (= finishing all potential recording tasks) to ensure it sees those recorded values in the database.
This is conceptually similar to the other bindings, which ensure serliazation barriers on each task, instead of only on the test methods. That in turn guarantees the above test won't block.
However this slight modification is also at least "surprising":
- create a metric
- record value
ato the metric - check what it contains -> nothing
- init glean.
- check what it contains ->
a
(I think that's what it does, right? The dispatcher is not unblocked until init)
I actually did implement a "test mode -> serialize" mode initially for the dispatcher in FOG, we took it out to simplify the implementation, as we didn't require it back then.
So the question becomes: what are we trying to solve? Consistency across bindings? Behavior? Avoiding blocking code?
The testing strategy for individual users of the RLB is not great anyway (they need to ensure that Glean is initialized for anything to be happening).
Testing in Firefox is better, as FOG takes care of initialization (still some things to figure out though for external users)
In the short term we could put a check of was_initialize_called into block_on_queue and at least panic if it wasn't, thus giving users (really: us) a better chance to avoid that test pattern than blocking would give us (blocking is time consuming and harder to detect).
| Assignee | ||
Comment 4•5 years ago
|
||
Reasoning in today's SDK meeting was to go for the panicky solution.
| Assignee | ||
Updated•5 years ago
|
Comment 5•5 years ago
|
||
| Assignee | ||
Updated•5 years ago
|
Description
•