From 8f4132903263bcfd5ee5089cfe2ab424fe0f5923 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 21 Dec 2020 12:25:01 -0800 Subject: [PATCH 1/2] Install Azurite for Azure Blob Storage tests. This should increase coverage. --- .github/workflows/python-package.yml | 10 +++++++--- zarr/tests/test_storage.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a9a1ff5c28..04d70073bc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -47,7 +47,9 @@ jobs: - name: Create Conda environment with the rights deps shell: "bash -l {0}" run: | - conda create -n zarr-env python==${{matrix.python-version}} bsddb3 numcodecs==0.6.4 lmdb pip + conda create -n zarr-env python==${{matrix.python-version}} bsddb3 numcodecs==0.6.4 lmdb pip nodejs + conda activate zarr-env + npm install -g azurite - name: Install dependencies shell: "bash -l {0}" run: | @@ -61,12 +63,14 @@ jobs: shell: "bash -l {0}" env: COVERAGE_FILE: .coverage.${{matrix.python-version}}.${{matrix.numpy_version}} - ZARR_TEST_ABS: 0 + ZARR_TEST_ABS: 1 ZARR_TEST_MONGO: 1 ZARR_TEST_REDIS: 1 run: | conda activate zarr-env - pytest --cov=zarr --cov-config=.coveragerc --doctest-plus --cov-report xml --cov=./ + mkdir ~/blob_emulator + azurite -l ~/blob_emulator --debug debug.log 2>&1 > stdouterr.log & + pytest --cov=zarr --cov-config=.coveragerc --doctest-plus --cov-report xml --cov=./ - uses: codecov/codecov-action@v1 with: #token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index db9e04e067..76a01fe0a6 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -1801,11 +1801,16 @@ class TestABSStore(StoreTests, unittest.TestCase): def create_store(self, prefix=None): asb = pytest.importorskip("azure.storage.blob") - blob_client = asb.BlockBlobService(is_emulated=True) - blob_client.delete_container('test') - blob_client.create_container('test') - store = ABSStore(container='test', prefix=prefix, account_name='foo', - account_key='bar', blob_service_kwargs={'is_emulated': True}) + blob_client = asb.BlockBlobService(is_emulated=True, socket_timeout=10) + blob_client.delete_container("test") + blob_client.create_container("test") + store = ABSStore( + container="test", + prefix=prefix, + account_name="foo", + account_key="bar", + blob_service_kwargs={"is_emulated": True, "socket_timeout": 10}, + ) store.rmdir() return store From c3892085245224f7577c08b56297189f063786cf Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 21 Dec 2020 18:04:48 -0800 Subject: [PATCH 2/2] Mark some tests as xfail temporarily. This is due to azurite not allowing blob keys to be the empty string while azure seem to allow it. --- zarr/tests/test_core.py | 4 ++++ zarr/tests/test_storage.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/zarr/tests/test_core.py b/zarr/tests/test_core.py index bbc745accf..eb11e4a097 100644 --- a/zarr/tests/test_core.py +++ b/zarr/tests/test_core.py @@ -1576,6 +1576,10 @@ def create_array(self, read_only=False, **kwargs): return Array(store, read_only=read_only, cache_metadata=cache_metadata, cache_attrs=cache_attrs) + @pytest.mark.xfail + def test_nbytes_stored(self): + return super().test_nbytes_stored() + class TestArrayWithNestedDirectoryStore(TestArrayWithDirectoryStore): diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index 76a01fe0a6..6408f6081b 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -1839,6 +1839,13 @@ def test_iterators_with_prefix(self): assert ({('a', b'aaa'), ('b', b'bbb'), ('c/d', b'ddd'), ('c/e/f', b'fff')} == set(store.items())) + @pytest.mark.xfail + def test_getsize(self): + return super().test_getsize() + + @pytest.mark.xfail + def test_hierarchy(self): + return super().test_hierarchy() class TestConsolidatedMetadataStore(unittest.TestCase):