Provide mechanism to avoid posting duplicates of TestListInstances via API

Issue #516 open
Vincent Leduc created an issue

Hi Randle,

In the qa_testlistinstance table, there is currently only a unique constraint on the primary key. So there is nothing preventing an API client from pushing the same results multiple times needlessly.

I have been working around that by checking for an existing TestListInstance by filtering by UTC and work_started, and not posting if a TestListInstance is found. It’s not ideal, since work_started is an editable column, someone could change it and there is still potential for collisions.

Thoughts: Do you think it would be a good idea to add a unique column, say uid, that the client app could populate to uniquely identify test results once? Or create a unique index of utc_id and work_started since, in theory, no one can perform the same testlist on the same unit at the same time?

Thanks

Comments (4)

  1. Randle Taylor

    Hi Vincent,

    I actually ran up against this recently too.

    Do you think it would be a good idea to add a unique column, say uid, that the client app could populate to uniquely identify test results once?

    One solution that worked ok was pretty similar to this idea, but I just added a test to the test list that stored a unique identifier and then before posting to the API, I used the API to check if there was a TestInstance with that identifier already present. Worked ok, but maybe not ideal since it requires an extra API call.

    I think a unique index on utc_id and work_started might be a good solution. The only potential issue is that we’d need a migration to check all existing records in the DB before adding the unique constraint.

  2. Vincent Leduc reporter

    Hmm, good thinking about using a Test as an identifier. Is it possible to make it so it’s hidden in the testlist?

    Of course, I’ll leave it up to you to decide if another column (or index) and the accompanying migration are justified!

  3. Randle Taylor

    Yes, it would be nice if it could be hidden but right now only composite/string composite tests can be hidden.

  4. Log in to comment