From 84d79e1479c6f8ed802ba4bc723deb4aecbcf48e Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 00:04:30 +0000 Subject: [PATCH 1/7] Do not use IDLE in test_mdn_asymmetric Fixes test flakyness. --- python/tests/test_1_online.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 405374351..981a2f08a 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -683,23 +683,24 @@ def test_mdn_asymmetric(acfactory, lp): assert len(msg.chat.get_messages()) == 1 - ac1.direct_imap.select_config_folder("mvbox") - with ac1.direct_imap.idle() as idle1: - lp.sec("ac2: mark incoming message as seen") - ac2.mark_seen_messages([msg]) + lp.sec("ac2: mark incoming message as seen") + ac2.mark_seen_messages([msg]) - lp.sec("ac1: waiting for incoming activity") - # MDN should be moved even though MDNs are already disabled - ac1._evtracker.get_matching("DC_EVENT_IMAP_MESSAGE_MOVED") + lp.sec("ac1: waiting for incoming activity") + # MDN should be moved even though MDNs are already disabled + ac1._evtracker.get_matching("DC_EVENT_IMAP_MESSAGE_MOVED") - assert len(chat.get_messages()) == 1 + assert len(chat.get_messages()) == 1 - # Wait for the message to be marked as seen on IMAP. - assert idle1.wait_for_seen() + # Wait for the message to be marked as seen on IMAP. + ac1._evtracker.get_info_contains("Marked messages 1 in folder DeltaChat as seen.") # MDN is received even though MDNs are already disabled assert msg_out.is_out_mdn_received() + ac1.direct_imap.select_config_folder("mvbox") + assert len(list(ac1.direct_imap.conn.fetch(AND(seen=True)))) == 1 + def test_send_and_receive_will_encrypt_decrypt(acfactory, lp): ac1, ac2 = acfactory.get_online_accounts(2) From c9ec087cd81b31064afb5165fda55a4cdfcbd1f0 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 09:45:11 +0000 Subject: [PATCH 2/7] python: do not use IDLE in test_markseen_message_and_mdn test Make the test less flaky in case Dovecot notifies only about EXISTS but not flag updates. --- python/tests/test_1_online.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 981a2f08a..4a60df423 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -618,18 +618,25 @@ def test_markseen_message_and_mdn(acfactory, mvbox_move): # Do not send BCC to self, we only want to test MDN on ac1. ac1.set_config("bcc_self", "0") + acfactory.get_accepted_chat(ac1, ac2).send_text("hi") + msg = ac2._evtracker.wait_next_incoming_message() + + ac2.mark_seen_messages([msg]) + folder = "mvbox" if mvbox_move else "inbox" + if mvbox_move: + ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") + ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") + else: + ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") + ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") ac1.direct_imap.select_config_folder(folder) ac2.direct_imap.select_config_folder(folder) - with ac1.direct_imap.idle() as idle1: - with ac2.direct_imap.idle() as idle2: - acfactory.get_accepted_chat(ac1, ac2).send_text("hi") - msg = ac2._evtracker.wait_next_incoming_message() - ac2.mark_seen_messages([msg]) - - idle2.wait_for_seen() # Check original message is marked as seen - idle1.wait_for_seen() # Check that the mdn is marked as seen + # Check that the mdn is marked as seen + assert len(list(ac1.direct_imap.conn.fetch(AND(seen=True)))) == 1 + # Check original message is marked as seen + assert len(list(ac2.direct_imap.conn.fetch(AND(seen=True)))) == 1 def test_reply_privately(acfactory): From 40d32f2d0c7347e8bc6e71ed0d79a5c585c9f8fd Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 12:08:10 +0000 Subject: [PATCH 3/7] Do not use IDLE in test_fetch_existing_msgs_group_and_single Makes the test less flaky, as Dovecot sometimes sends only the EXISTS response, but not the FETCH response for flags. --- python/tests/test_0_complex_or_slow.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index e3decc7d6..970ee32f5 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -271,12 +271,12 @@ def test_fetch_existing_msgs_group_and_single(acfactory, lp): ac1._evtracker.wait_next_incoming_message() lp.sec("send out message with bcc to ourselves") - with ac1.direct_imap.idle() as idle1: - ac1.set_config("bcc_self", "1") - ac1_ac2_chat = ac1.create_chat(ac2) - ac1_ac2_chat.send_text("outgoing, encrypted direct message, creating a chat") - # wait until the bcc_self message arrives - assert idle1.wait_for_seen() + ac1.set_config("bcc_self", "1") + ac1_ac2_chat = ac1.create_chat(ac2) + ac1_ac2_chat.send_text("outgoing, encrypted direct message, creating a chat") + + # wait until the bcc_self message arrives + ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") lp.sec("Clone online account and let it fetch the existing messages") ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) From 1e135b649cc66340b5571e5cfd49fd2cc6290bd6 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 16:06:22 +0000 Subject: [PATCH 4/7] Do not use IDLE in test_send_and_receive_message_markseen Fix flakyness in case Dovecot sends only EXISTS but not FETCH unsolicited response. --- python/tests/test_1_online.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 4a60df423..b2d82dd60 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -518,22 +518,22 @@ def test_send_and_receive_message_markseen(acfactory, lp): msg4 = ac2._evtracker.wait_next_incoming_message() lp.sec("mark messages as seen on ac2, wait for changes on ac1") - with ac1.direct_imap.idle() as idle1: - with ac2.direct_imap.idle() as idle2: - ac2.mark_seen_messages([msg2, msg4]) - ev = ac2._evtracker.get_matching("DC_EVENT_MSGS_NOTICED") - assert msg2.chat.id == msg4.chat.id - assert ev.data1 == msg2.chat.id - assert ev.data2 == 0 - idle2.wait_for_seen() + ac2.mark_seen_messages([msg2, msg4]) + ev = ac2._evtracker.get_matching("DC_EVENT_MSGS_NOTICED") + assert msg2.chat.id == msg4.chat.id + assert ev.data1 == msg2.chat.id + assert ev.data2 == 0 + ac2._evtracker.get_info_contains("Marked messages .* in folder INBOX as seen.") - lp.step("1") - for _i in range(2): - ev = ac1._evtracker.get_matching("DC_EVENT_MSG_READ") - assert ev.data1 > const.DC_CHAT_ID_LAST_SPECIAL - assert ev.data2 > const.DC_MSG_ID_LAST_SPECIAL - lp.step("2") - idle1.wait_for_seen() # Check that ac1 marks the read receipt as read + lp.step("1") + for _i in range(2): + ev = ac1._evtracker.get_matching("DC_EVENT_MSG_READ") + assert ev.data1 > const.DC_CHAT_ID_LAST_SPECIAL + assert ev.data2 > const.DC_MSG_ID_LAST_SPECIAL + lp.step("2") + + # Check that ac1 marks the read receipt as read. + ac1._evtracker.get_info_contains("Marked messages .* in folder INBOX as seen.") assert msg1.is_out_mdn_received() assert msg3.is_out_mdn_received() From 4b468a25fe51dbee177ebcf3b703d0c9b4ecc3c6 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 16:13:33 +0000 Subject: [PATCH 5/7] Remove pytest-rerunfailures It is not compatible with pytest-timeout anyway: --- python/tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/tox.ini b/python/tox.ini index a89b2c618..994f9c4c7 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -8,7 +8,7 @@ envlist = [testenv] commands = - pytest -n6 --extra-info --reruns 2 --reruns-delay 5 -v -rsXx --ignored --strict-tls {posargs: tests examples} + pytest -n6 --extra-info -v -rsXx --ignored --strict-tls {posargs: tests examples} pip wheel . -w {toxworkdir}/wheelhouse --no-deps setenv = # Avoid stack overflow when Rust core is built without optimizations. @@ -21,7 +21,6 @@ passenv = RUSTC_WRAPPER deps = pytest - pytest-rerunfailures pytest-timeout pytest-xdist pdbpp From a8059c6bffc73443434b5fbd465a1c623e7815d8 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 18:08:08 +0000 Subject: [PATCH 6/7] python: remove flaky .wait_for_seen() from test_fetch_existing() --- python/tests/test_0_complex_or_slow.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index 970ee32f5..736c0d1dd 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -220,16 +220,16 @@ def test_fetch_existing(acfactory, lp, mvbox_move): acfactory.bring_accounts_online() assert_folders_configured(ac1) - assert ac1.direct_imap.select_config_folder("mvbox" if mvbox_move else "inbox") - with ac1.direct_imap.idle() as idle1: - lp.sec("send out message with bcc to ourselves") - ac1.set_config("bcc_self", "1") - chat = acfactory.get_accepted_chat(ac1, ac2) - chat.send_text("message text") - assert_folders_configured(ac1) + lp.sec("send out message with bcc to ourselves") + ac1.set_config("bcc_self", "1") + chat = acfactory.get_accepted_chat(ac1, ac2) + chat.send_text("message text") - lp.sec("wait until the bcc_self message arrives in correct folder and is marked seen") - assert idle1.wait_for_seen() + lp.sec("wait until the bcc_self message arrives in correct folder and is marked seen") + if mvbox_move: + ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") + else: + ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") assert_folders_configured(ac1) lp.sec("create a cloned ac1 and fetch contact history during configure") From 92ad843ff2095c8f2a0af2efdb844d9603262185 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 24 Mar 2023 20:59:31 +0000 Subject: [PATCH 7/7] Reduce test code duplication --- python/tests/test_1_online.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index b2d82dd60..96b5fb3d9 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -624,12 +624,11 @@ def test_markseen_message_and_mdn(acfactory, mvbox_move): ac2.mark_seen_messages([msg]) folder = "mvbox" if mvbox_move else "inbox" - if mvbox_move: - ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") - ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") - else: - ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") - ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") + for ac in [ac1, ac2]: + if mvbox_move: + ac._evtracker.get_info_contains("Marked messages [0-9]+ in folder DeltaChat as seen.") + else: + ac._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.") ac1.direct_imap.select_config_folder(folder) ac2.direct_imap.select_config_folder(folder)