ooni / probe

OONI Probe network measurement tool for detecting internet censorship
https://ooni.org/install
BSD 3-Clause "New" or "Revised" License
749 stars 142 forks source link

probe-mobile: improve how in progress tests are displayed #2658

Open hellais opened 5 months ago

hellais commented 5 months ago

At the moment if a test is still starting, when you navigate to the test results screen you can either see an error or you see a partial summary of the result.

We should instead have a specific view that tells the user that the test is in progress and allows them to open it only if it has passed the bootstrap phase.

aanorbel commented 4 months ago

Something similar was added in https://github.com/ooni/probe-android/pull/614. Please let me know if more is to be done to resolve this issue.

hellais commented 4 months ago

Following up what I shared in PM with @aanorbel:

I think what has been implemented in https://github.com/ooni/probe-android/pull/614 could do with some improvements.

It seems quite brittle to use the start_time < 5 minutes ago as an indication that a test is in progress.

Rather we should be using the is_done and is_failed columns to be able to say if a result and measurement are in progress in a way that's more deterministic and robust.

@aanorbel claimed that there is some issue where we set is_failed also while a test is in progress, however I think that the semantics of the is_failed field should be that we only mark something as failed when a measurement and result has reached it's final state (it's not running anymore) AND the outcome of it was an unrecoverable failure.

Ideally the state of a measurement would not be uncertain while it's running

Basically the state of a test is:

I suppose one challenging thing is that we have the 1-many relationship between the result and measurement rows.

But it should be possible without too much effort to compute the aggregate state of a Result row by doing a JOIN on the relevant measurement rows.

Potentially tricky edge case is that, depending on the lifecycle of the result and measurement rows, what happens if you are starting a result set, but haven't written a single measurement row yet. However that should be solvable with some SQL.

Technically all the data should be there to be able to compute the state of the result set deterministically.

hellais commented 4 months ago

Following up to share more about:

However that should be solvable with some SQL.

I don't know how the ORM works, but the SQL should look something like this:

SELECT
    r.PrimaryKey,
    CASE 
        -- -1 is used to indicate there are no matching rows
        WHEN COUNT(m.ForeignKey) = 0 THEN -1
        ELSE SUM(CASE WHEN m.is_done = FALSE THEN 1 ELSE 0 END) as in_progress_count
    END AS in_progress_status
FROM
    Results r
LEFT JOIN
    Measurements m ON r.PrimaryKey = m.ForeignKey
GROUP BY
    r.PrimaryKey;