Merge pull request #7364 from ThomasWaldmann/fix-compression-tests-1.1

"auto" compressor tests: don't assume a specific size, fixes #7363
This commit is contained in:
TW 2023-02-18 14:36:50 +01:00 committed by GitHub
commit 10208d880d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 14 deletions

View File

@ -94,7 +94,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.lock.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
@ -120,7 +120,7 @@ jobs:
- name: Install Python requirements
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.d/development.txt
pip install -r requirements.d/development.lock.txt
- name: Install borgbackup
run: |
# pip install -e .

View File

@ -2243,22 +2243,11 @@ class ArchiverTestCase(ArchiverTestCaseBase):
def test_compression_zlib_compressible(self):
size, csize = self._get_sizes('zlib', compressible=True)
assert csize < size * 0.1
assert csize == 35
def test_compression_zlib_uncompressible(self):
size, csize = self._get_sizes('zlib', compressible=False)
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
assert csize == size + 3 # same as compression 'none'
def test_compression_lz4_compressible(self):
size, csize = self._get_sizes('lz4', compressible=True)
assert csize < size * 0.1
@ -2275,6 +2264,23 @@ class ArchiverTestCase(ArchiverTestCaseBase):
size, csize = self._get_sizes('lzma', compressible=False)
assert csize >= size
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):
self.cmd('init', '--encryption=repokey', self.repository_location)
os.environ['BORG_NEW_PASSPHRASE'] = 'newpassphrase'

View File

@ -6,7 +6,7 @@ envlist = py{35,36,37,38,39,310}
[testenv]
deps =
-rrequirements.d/development.txt
-rrequirements.d/development.lock.txt
-rrequirements.d/fuse.txt
commands = py.test -n {env:XDISTN:4} -rs --cov=borg --cov-config=.coveragerc --benchmark-skip --pyargs {posargs:borg.testsuite}
# fakeroot -u needs some env vars: