From eabdbad0db011a8a826dc208630d9ded5a7ccda2 Mon Sep 17 00:00:00 2001 From: Cyril Galibern Date: Thu, 16 Nov 2023 11:35:50 +0100 Subject: [PATCH] [test] fix test_ensure_delay_when_tilde_in_custom_schedule This commit relax constrains on possible test failure @staticmethod def test_ensure_delay_when_tilde_in_custom_schedule(mocker, capsys): svcname = "pytest" mocker.patch.dict(os.environ, {"OSVC_DETACHED": "1"}) with capsys.disabled(): assert Mgr()(argv=["-s", svcname, "create", "--kw", "status_schedule=~08:01-09:59"]) == 0 assert Mgr()(argv=["-s", svcname, "print", "schedule"]) == 0 next_runs = set() for i in range(4): assert Mgr()(argv=["-s", svcname, "print", "schedule", "--local", "--format", "json"]) == 0 action = get_action(json.loads(capsys.readouterr().out), "status") next_runs.add(action["next_run"]) > assert len(next_runs) > 3 E assert 3 > 3 E + where 3 = len({1700042310.0, 1700042326.0, 1700042331.0}) --- opensvc/tests/commands/svc/test_schedule.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensvc/tests/commands/svc/test_schedule.py b/opensvc/tests/commands/svc/test_schedule.py index 830ce55d3..e7fb23f36 100644 --- a/opensvc/tests/commands/svc/test_schedule.py +++ b/opensvc/tests/commands/svc/test_schedule.py @@ -66,11 +66,11 @@ def test_ensure_delay_when_tilde_in_custom_schedule(mocker, capsys): assert Mgr()(argv=["-s", svcname, "create", "--kw", "status_schedule=~08:01-09:59"]) == 0 assert Mgr()(argv=["-s", svcname, "print", "schedule"]) == 0 next_runs = set() - for i in range(4): + for i in range(6): assert Mgr()(argv=["-s", svcname, "print", "schedule", "--local", "--format", "json"]) == 0 action = get_action(json.loads(capsys.readouterr().out), "status") next_runs.add(action["next_run"]) - assert len(next_runs) > 3 + assert len(next_runs) > 2, "'print schedule --local' called 6 times should propose at leat 2 != next_run" @staticmethod def test_ensure_next_run_is_fixed_when_no_tilde_in_custom_schedule(mocker, capsys):