From fafc7c6b1c52d5aa40c9130b8d6a2661a8e717b0 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Thu, 20 Dec 2018 17:48:27 -0800 Subject: [PATCH] tests: re-open store after datapack truncation Summary: When I replace lz4 to rust.lz4, the test failed. The change fixes it. That also means datapack corruption detection is not that reliable. However, usually those files are not changed when they are loaded into an in-memory store, so it's probaby fine. Also note the python-lz4 used in production has strange behavior when compressing an empty string: In [6]: lz4.compressHC('') Out[6]: '\x00\x00\x00\x00\xa0#\xd9\x040\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00' In [7]: lz4.compress('') Out[7]: '\x00\x00\x00\x00\xa0#\xd9\x040\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00' In [9]: rustlz4.compress('') Out[9]: bytearray(b'\x00\x00\x00\x00') In [10]: rustlz4.compresshc('') Out[10]: bytearray(b'\x00\x00\x00\x00') In [13]: lz4.compress('1') Out[13]: '\x01\x00\x00\x00\x101' In [14]: rustlz4.compress('1') Out[14]: bytearray(b'\x01\x00\x00\x00\x101') Reviewed By: DurhamG Differential Revision: D13528199 fbshipit-source-id: 9b3e8674f989062928900766156a97d28262c8cb --- tests/test-fb-hgext-remotefilelog-datapack.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test-fb-hgext-remotefilelog-datapack.py b/tests/test-fb-hgext-remotefilelog-datapack.py index 4b474aacdf..cafad86e6c 100755 --- a/tests/test-fb-hgext-remotefilelog-datapack.py +++ b/tests/test-fb-hgext-remotefilelog-datapack.py @@ -369,6 +369,11 @@ class datapacktestsbase(object): f.truncate(1) f.close() + # Re-create the store. Otherwise the behavior is kind of "undefined" + # because the size of mmap-ed memory isn't truncated automatically, + # and is filled by 0. + store = datapackstore(ui, packdir, self.iscdatapack, deletecorruptpacks=True) + # Look for key again try: ui.pushbuffer(error=True)