From 598bc98ba105e111af3b6a3b415f914fa64d88d4 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 2 Mar 2021 17:56:33 +0100 Subject: [PATCH] home-assistant: rerun tests failing with RuntimeError The flakyness in home-assistant stems from premature event loop closing, due to race conditions throughout the test suite. > RuntimeError: Event loop is closed They also happen during upstreams testsuite runs, but they silently ignore them, so I don't expect a fix for them in the near future. Alleviate our pains by rerunning tests that fail in this particular way. --- pkgs/servers/home-assistant/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 81c3fb9025e1..f7e0face11a2 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -136,6 +136,7 @@ in with py.pkgs; buildPythonApplication rec { # test infrastructure asynctest pytest-aiohttp + pytest-rerunfailures pytest-xdist pytestCheckHook requests-mock @@ -292,7 +293,10 @@ in with py.pkgs; buildPythonApplication rec { pytestFlagsArray = [ # limit amout of runners to reduce race conditions - "-n 2" + "-n auto" + # retry racy tests that end in "RuntimeError: Event loop is closed" + "--reruns 3" + "--only-rerun RuntimeError" # assign tests grouped by file to workers "--dist loadfile" # tests are located in tests/