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 randomly failing tests #4064

Merged
merged 5 commits into from
Jan 24, 2024
Merged

Fix randomly failing tests #4064

merged 5 commits into from
Jan 24, 2024

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Jan 23, 2024

Changes

When testing that some function was not called when mocked, other tests
from the same test suite might interfere, if the call a function with
the same arguments. Fix by making each function use different from-to
arguments.

Improve the Sanbase.FailedTestFormatter to handle this error:

anbaseWeb.Graphql.ApiCallDataApiTest [test/sanbase_web/graphql/clickhouse/api_call_data_api_test.exs]
  * test export get_metric api calls with the metric and slug as arguments [L#16]�[33mwarning:�[0m Unexpected failed test format.
  (sanbase 0.0.1) lib/mix/failure_test_formatter.ex:32: Sanbase.FailedTestFormatter.handle_cast/2
  (stdlib 5.2) gen_server.erl:1121: :gen_server.try_handle_cast/3
  (stdlib 5.2) gen_server.erl:1183: :gen_server.handle_msg/6
  (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

�[31m
  * test export get_metric api calls with the metric and slug as arguments (6638.4ms) [L#16]�[0m

  1) test export get_metric api calls with the metric and slug as arguments (SanbaseWeb.Graphql.ApiCallDataApiTest)
     �[1m�[30mtest/sanbase_web/graphql/clickhouse/api_call_data_api_test.exs:16�[0m
     �[31m** (exit) exited in: GenServer.call(:api_call_exporter, :flush, 5000)
         ** (EXIT) time out�[0m
     �[36mcode: �[0m|> Sanbase.Mock.run_with_mocks(fn ->
     �[36mstacktrace:�[0m
       (elixir 1.16.0) lib/gen_server.ex:1114: GenServer.call/3
       test/sanbase_web/graphql/clickhouse/api_call_data_api_test.exs:37: anonymous fn/3 in SanbaseWeb.Graphql.ApiCallDataApiTest."test export get_metric api calls with the metric and slug as arguments"/1
       (sanbase 0.0.1) test/support/mock.ex:97: Sanbase.Mock.run_with_mocks/2
       test/sanbase_web/graphql/clickhouse/api_call_data_api_test.exs:24: (test)

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

When testing that some function was not called when mocked, other tests
from the same test suite might interfere, if the call a function with
the same arguments. Fix by making each function use different from-to
arguments.
@IvanIvanoff IvanIvanoff force-pushed the fix-randomly-failing-tests branch from 488b618 to 983126d Compare January 24, 2024 08:27
@IvanIvanoff IvanIvanoff merged commit b6004d0 into master Jan 24, 2024
1 of 2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix-randomly-failing-tests branch January 24, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants