From 125a63d323058ec76f05f1d5a62f01f484a7cfdd Mon Sep 17 00:00:00 2001 From: Abhijat Malviya Date: Tue, 16 Jul 2024 18:20:44 +0530 Subject: [PATCH] cst/ducktape: Change assertion for deleted chunks Because chunk readers keep open the handle to a chunk file even if the file itself is deleted, during the test_read_chunks it is possible that the sequential consumer is entirely served by these open file handles while all chunk files in the directory have been removed. This results in the assertion that some chunks must have been removed during sequential consumer to fail. As the count of chunks deleted is not important as an assertion and the purpose of deleting chunks randomly was to exercise failed materialization code path which should happen during the random consumer run, the assertion is changed to only test once for both seq and random consumers. Another alternative would be a more fine grained check, eg assert if some chunks are removed only if some files are written to the cache during a consumer run, but such checks do not buy extra value. (cherry picked from commit 866675e97a2ef0a7a2e7de07be41dbfdf3e33aae) --- tests/rptest/tests/cloud_storage_chunk_read_path_test.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/rptest/tests/cloud_storage_chunk_read_path_test.py b/tests/rptest/tests/cloud_storage_chunk_read_path_test.py index ae43ac4b49cd7..0d2c5c1bd84f7 100644 --- a/tests/rptest/tests/cloud_storage_chunk_read_path_test.py +++ b/tests/rptest/tests/cloud_storage_chunk_read_path_test.py @@ -229,12 +229,6 @@ def test_read_chunks(self): self._assert_not_in_cache( fr'.*kafka/{self.topic}/.*\.log\.[0-9]+$') - # We cannot assert that there are chunks in cache because the deleting thread - # could delete them all before we run the assertion, causing it to fail. - # We can check that the thread deleted some chunks. - assert rm_chunks.deleted_chunks > 0, "Expected to delete some chunk files during rand-cons, none deleted" - rm_chunks.deleted_chunks = 0 - consumer = KgoVerifierSeqConsumer(self.test_context, self.redpanda, self.topic, @@ -244,7 +238,7 @@ def test_read_chunks(self): consumer.wait(timeout_sec=120) rm_chunks.stop() rm_chunks.join(timeout=10) - assert rm_chunks.deleted_chunks > 0, "Expected to delete some chunk files during seq-cons, none deleted" + assert rm_chunks.deleted_chunks > 0, "Expected to delete some chunk files, none deleted" self._assert_not_in_cache( fr'.*kafka/{self.topic}/.*\.log\.[0-9]+$')