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

Address flakiness in Activity Log tests #2836

Merged
merged 1 commit into from
Jul 30, 2024
Merged

Address flakiness in Activity Log tests #2836

merged 1 commit into from
Jul 30, 2024

Conversation

balanza
Copy link
Member

@balanza balanza commented Jul 29, 2024

I experienced some flakiness in some of our activity log tests we've recently introduced.

It seems there is some inconsistency in how we slice data in pages. For example here the test fails because it was expecting two identical lists of entries in next_logs_alt and next_logs, but they where different. By re-running the job, the error disappeared.

The problem may be in how we sort entries by date. As per the Elixir docs:

[...] avoid using the default sorting function to sort
structs, as by default it performs structural comparison instead of
a semantic one. In such cases, you shall pass a sorting function as
third element or any module that implements a compare/2 function.
For example, to sort users by their birthday in both ascending and
descending order respectively:

 iex> users = [
 ...>   %{name: "Ellis", birthday: ~D[1943-05-11]},
 ...>   %{name: "Lovelace", birthday: ~D[1815-12-10]},
 ...>   %{name: "Turing", birthday: ~D[1912-06-23]}
 ...> ]
 iex> Enum.sort_by(users, &(&1.birthday), Date)

The fix improves how we sort data. We should keep an eye on the overall test, to see if it's enough do remove the flakiness.

@balanza balanza enabled auto-merge (squash) July 29, 2024 17:42
@balanza balanza disabled auto-merge July 29, 2024 17:46
@balanza balanza changed the title Address flakiness on Activity Log tests Address flakiness in Activity Log tests Jul 29, 2024
@balanza balanza enabled auto-merge (squash) July 29, 2024 17:47
@balanza balanza merged commit 8cec7b0 into main Jul 30, 2024
26 checks passed
@balanza balanza deleted the fix-flaky-tests branch July 30, 2024 06:43
@nelsonkopliku nelsonkopliku added tech debt elixir Pull requests that update Elixir code test labels Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code tech debt test
Development

Successfully merging this pull request may close these issues.

2 participants