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 flaky poll recount spec #4555

Merged
merged 2 commits into from
Jun 22, 2021
Merged

Fix flaky poll recount spec #4555

merged 2 commits into from
Jun 22, 2021

Conversation

javierm
Copy link
Member

@javierm javierm commented Jun 14, 2021

References

Objectives

  • Fix a test which failed when there was a record in the database with the same ID we were assigning

@javierm javierm self-assigned this Jun 14, 2021
@javierm javierm added this to Reviewing in Consul Democracy via automation Jun 14, 2021
The test "updates officer_assignment_id_log if amount changes" failed
when the ID we assigned when creating the records was the same as the ID
of the first officer assignment created during that test. It's recently
happened while running our test suite [1] with the following error:

```
1) Poll::Recount logging changes updates officer_assignment_id_log if
amount changes
  Failure/Error: poll_recount.officer_assignment =
                  create(:poll_officer_assignment, id: 101)

     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique
       constraint "poll_officer_assignments_pkey"
       DETAIL:  Key (id)=(101) already exists.
```

We're also removing the IDs in the "updates officer_assignment_id_log if
amount changes" test to avoid any possible issues, even if in this test
I think no other officer assignments are created and so there can't be
another record with the same ID.

[1] https://github.com/consul/consul/runs/2818889296
This test will fail if the ID of the created record is the same as the
ID of the first user we create in the test. The chance is very low due
to the `rand(9999999)` which causes the test to fail just once every ten
million times. However, why assigning the ID in the first place? Without
it, the test will never fail due to conflicting IDs.
@taitus taitus self-assigned this Jun 17, 2021
Consul Democracy automation moved this from Reviewing to Testing Jun 22, 2021
@javierm javierm merged commit 918276e into master Jun 22, 2021
@javierm javierm deleted the flaky_recount_spec branch June 22, 2021 16:30
Consul Democracy automation moved this from Testing to Release 1.4.0 Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants