mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-10 14:15:43 +00:00
"auto" compressor tests: don't assume a specific size, fixes #7363
The tests assumed a specific compressed results size, which is bad, because it might vary depending on the zlib implementation. Now the "auto" compressor tests just check if it is the same size as when unconditionally using the zlib compressor.
This commit is contained in:
parent
6e8c58c125
commit
8fe980c94e
1 changed files with 17 additions and 10 deletions
|
@ -2521,21 +2521,11 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
def test_compression_zlib_compressible(self):
|
def test_compression_zlib_compressible(self):
|
||||||
size, csize = self._get_sizes('zlib', compressible=True)
|
size, csize = self._get_sizes('zlib', compressible=True)
|
||||||
assert csize < size * 0.1
|
assert csize < size * 0.1
|
||||||
assert csize == 35
|
|
||||||
|
|
||||||
def test_compression_zlib_uncompressible(self):
|
def test_compression_zlib_uncompressible(self):
|
||||||
size, csize = self._get_sizes('zlib', compressible=False)
|
size, csize = self._get_sizes('zlib', compressible=False)
|
||||||
assert csize >= size
|
assert csize >= size
|
||||||
|
|
||||||
def test_compression_auto_compressible(self):
|
|
||||||
size, csize = self._get_sizes('auto,zlib', compressible=True)
|
|
||||||
assert csize < size * 0.1
|
|
||||||
assert csize == 35 # same as compression 'zlib'
|
|
||||||
|
|
||||||
def test_compression_auto_uncompressible(self):
|
|
||||||
size, csize = self._get_sizes('auto,zlib', compressible=False)
|
|
||||||
assert csize == size + 3 # same as compression 'none'
|
|
||||||
|
|
||||||
def test_compression_lz4_compressible(self):
|
def test_compression_lz4_compressible(self):
|
||||||
size, csize = self._get_sizes('lz4', compressible=True)
|
size, csize = self._get_sizes('lz4', compressible=True)
|
||||||
assert csize < size * 0.1
|
assert csize < size * 0.1
|
||||||
|
@ -2560,6 +2550,23 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
size, csize = self._get_sizes('zstd', compressible=False)
|
size, csize = self._get_sizes('zstd', compressible=False)
|
||||||
assert csize == size + 3 # same as compression 'none'
|
assert csize == size + 3 # same as compression 'none'
|
||||||
|
|
||||||
|
def test_compression_auto_compressible(self):
|
||||||
|
# this is testing whether the "auto" meta-compressor chooses the "expensive" zlib compression
|
||||||
|
# if it detects that the data is very compressible (and not "lz4" nor "none" compression).
|
||||||
|
auto_size, auto_csize = self._get_sizes('auto,zlib', compressible=True)
|
||||||
|
self.cmd('delete', self.repository_location)
|
||||||
|
zlib_size, zlib_csize = self._get_sizes('zlib', compressible=True)
|
||||||
|
assert auto_size == zlib_size
|
||||||
|
assert auto_csize < auto_size * 0.1 # it did compress!
|
||||||
|
assert auto_csize == zlib_csize # looking at the result size, it seems to be zlib compressed
|
||||||
|
|
||||||
|
def test_compression_auto_uncompressible(self):
|
||||||
|
# this is testing whether the "auto" meta-compressor chooses the "none" compression (storing the
|
||||||
|
# data "as is" with just the 3 bytes header) if all else would result in something bigger.
|
||||||
|
size, csize = self._get_sizes('auto,zlib', compressible=False)
|
||||||
|
assert csize >= size
|
||||||
|
assert csize == size + 3 # same as compression 'none'
|
||||||
|
|
||||||
def test_change_passphrase(self):
|
def test_change_passphrase(self):
|
||||||
self.cmd('init', '--encryption=repokey', self.repository_location)
|
self.cmd('init', '--encryption=repokey', self.repository_location)
|
||||||
os.environ['BORG_NEW_PASSPHRASE'] = 'newpassphrase'
|
os.environ['BORG_NEW_PASSPHRASE'] = 'newpassphrase'
|
||||||
|
|
Loading…
Add table
Reference in a new issue