Skip to content

cli_send_* tests in zellij_server fail when running on too many threads #1929

@har7an

Description

@har7an

I noticed that the tests in zellij_server, when run from cargo make, started failing on my machine with one of the recent changes in main. I haven't yet bothered to track down the exact change that introduced this.

The symptom for me is that the following 16 tests inside zellij_server fail:

screen::screen_tests::send_cli_close_pane_action
screen::screen_tests::send_cli_close_tab_action
screen::screen_tests::send_cli_edit_action_with_default_parameters
screen::screen_tests::send_cli_edit_action_with_line_number
screen::screen_tests::send_cli_edit_action_with_split_direction
screen::screen_tests::send_cli_edit_scrollback_action
screen::screen_tests::send_cli_focus_next_pane_action
screen::screen_tests::send_cli_focus_previous_pane_action
screen::screen_tests::send_cli_goto_tab_action
screen::screen_tests::send_cli_half_page_scroll_down_action
screen::screen_tests::send_cli_half_page_scroll_up_action
screen::screen_tests::send_cli_move_focus_or_tab_pane_action
screen::screen_tests::send_cli_move_focus_pane_action
screen::screen_tests::send_cli_move_pane_action
screen::screen_tests::send_cli_new_pane_action_with_command_and_cwd
screen::screen_tests::send_cli_new_pane_action_with_default_parameters

When limiting the number of CPU threads to use with e.g. taskset, less tests will fail. When giving 6 threads to cargo make, all tests pass on my machine. This also explains why the CI doesn't fail, because IIRC that only has 3 threads available for x86 Ubuntu workers. The command I have to use is:

taskset -c 0-5 cargo make ...

As far as I could determine, this doesn't seem to be an error from shared global state. However, all these tests use insta to compare snapshots, and I don't know how insta works, so it may well be caused by races in global states of some sort. I tried the following to alleviate race conditions:

  • Use rusty_fork to fork out the tests into a more isolated environment
  • Add a global Mutex to the tests so simulating the sending from CLI doesn't happen in parallel any longer

None of these made the problems go away. One solution would be to limit the number of test threads in cargo make, but I'm wondering whether I'm the only person experiencing this? I also tried cargo clean repeatedly in case it was caused by some old artifacts messing with the tests, but that hasn't changed the situation for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions