Skip testing most compression methods by default
The test suite is now reaching the C.I. timeout. In order to reduce the overall runtime, we now skip testing most compression methods (bzip2, zlib, lzma) in cloud objstorages by default. Testing all compression methods can still be done by specifying `--all-compression-methods` on pytest command-line. diff --git a/swh/objstorage/tests/conftest.py b/swh/objstorage/tests/conftest.py index 377778e..664aade 100644 --- a/swh/objstorage/tests/conftest.py +++ b/swh/objstorage/tests/conftest.py @@ -1,5 +1,7 @@ import sys +import pytest + def pytest_configure(config): config.addinivalue_line("markers", "shard_max_size: winery backend") @@ -14,6 +16,13 @@ def pytest_configure(config): config.addinivalue_line( "markers", "use_benchmark_flags: use the --winery-bench-* CLI flags" ) + config.addinivalue_line( + "markers", + ( + "all_compression_methods: " + "test all compression methods instead of only the most common ones" + ), + ) def pytest_addoption(parser): @@ -106,3 +115,15 @@ def pytest_addoption(parser): help="Maximum number of bytes per second write", default=100 * 1024 * 1024, ) + parser.addoption( + "--all-compression-methods", + action="store_true", + default=False, + help="Test all compression methods", + ) + + +def pytest_runtest_setup(item): + if item.get_closest_marker("all_compression_methods"): + if not item.config.getoption("--all-compression-methods"): + pytest.skip("`--all-compression-methods` has not been specified") diff --git a/swh/objstorage/tests/test_objstorage_azure.py b/swh/objstorage/tests/test_objstorage_azure.py index b78e3d4..3679258 100644 --- a/swh/objstorage/tests/test_objstorage_azure.py +++ b/swh/objstorage/tests/test_objstorage_azure.py @@ -269,14 +269,17 @@ class TestMockedAzureCloudObjStorageGzip(TestMockedAzureCloudObjStorage): compression = "gzip" +@pytest.mark.all_compression_methods class TestMockedAzureCloudObjStorageZlib(TestMockedAzureCloudObjStorage): compression = "zlib" +@pytest.mark.all_compression_methods class TestMockedAzureCloudObjStorageLzma(TestMockedAzureCloudObjStorage): compression = "lzma" +@pytest.mark.all_compression_methods class TestMockedAzureCloudObjStorageBz2(TestMockedAzureCloudObjStorage): compression = "bz2" diff --git a/swh/objstorage/tests/test_objstorage_cloud.py b/swh/objstorage/tests/test_objstorage_cloud.py index 49cbd62..1c50850 100644 --- a/swh/objstorage/tests/test_objstorage_cloud.py +++ b/swh/objstorage/tests/test_objstorage_cloud.py @@ -148,6 +148,7 @@ class TestCloudObjStorage(ObjStorageTestFixture, unittest.TestCase): pass +@pytest.mark.all_compression_methods class TestCloudObjStorageBz2(TestCloudObjStorage): compression = "bz2" @@ -156,10 +157,12 @@ class TestCloudObjStorageGzip(TestCloudObjStorage): compression = "gzip" +@pytest.mark.all_compression_methods class TestCloudObjStorageLzma(TestCloudObjStorage): compression = "lzma" +@pytest.mark.all_compression_methods class TestCloudObjStorageZlib(TestCloudObjStorage): compression = "zlib" diff --git a/swh/objstorage/tests/test_objstorage_pathslicing.py b/swh/objstorage/tests/test_objstorage_pathslicing.py index d1f5568..72c3305 100644 --- a/swh/objstorage/tests/test_objstorage_pathslicing.py +++ b/swh/objstorage/tests/test_objstorage_pathslicing.py @@ -8,6 +8,8 @@ import tempfile import unittest from unittest.mock import DEFAULT, patch +import pytest + from swh.model import hashutil from swh.objstorage import exc from swh.objstorage.constants import ID_DIGEST_LENGTH @@ -144,13 +146,16 @@ class TestPathSlicingObjStorageGzip(TestPathSlicingObjStorage): compression = "gzip" +@pytest.mark.all_compression_methods class TestPathSlicingObjStorageZlib(TestPathSlicingObjStorage): compression = "zlib" +@pytest.mark.all_compression_methods class TestPathSlicingObjStorageBz2(TestPathSlicingObjStorage): compression = "bz2" +@pytest.mark.all_compression_methods class TestPathSlicingObjStorageLzma(TestPathSlicingObjStorage): compression = "lzma"
Showing
- swh/objstorage/tests/conftest.py 21 additions, 0 deletionsswh/objstorage/tests/conftest.py
- swh/objstorage/tests/test_objstorage_azure.py 3 additions, 0 deletionsswh/objstorage/tests/test_objstorage_azure.py
- swh/objstorage/tests/test_objstorage_cloud.py 3 additions, 0 deletionsswh/objstorage/tests/test_objstorage_cloud.py
- swh/objstorage/tests/test_objstorage_pathslicing.py 5 additions, 0 deletionsswh/objstorage/tests/test_objstorage_pathslicing.py
Loading
Please register or sign in to comment