diff options
author | Benjamin Schubert <bschubert15@bloomberg.net> | 2019-11-12 10:24:36 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-11-12 13:02:30 +0000 |
commit | 7c470b46b33257bb81d70a00cb6b2114d68b9097 (patch) | |
tree | 343fbc043c692b4036b7e4b56e9a7a9493b44bbf /tests/artifactcache | |
parent | d51a51002b2b04f20bfa3376b6fef26add26a88d (diff) | |
download | buildstream-7c470b46b33257bb81d70a00cb6b2114d68b9097.tar.gz |
_remote: Ensure checks done in the subclasses are propagated
Currently, the `BaseRemote` would call `_check()` on the children, which
states that errors should be sent back as a string. However,
`BaseRemote` doesn't check the return of `_check()`.
This changes the contract so that subclasses throw `RemoteError`
themselves.
This also fixes the `ArtifactShare` and add a test.
Diffstat (limited to 'tests/artifactcache')
-rw-r--r-- | tests/artifactcache/capabilities.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/artifactcache/capabilities.py b/tests/artifactcache/capabilities.py new file mode 100644 index 000000000..a28516aea --- /dev/null +++ b/tests/artifactcache/capabilities.py @@ -0,0 +1,55 @@ +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os + +import pytest +from buildstream._project import Project + +from buildstream import _yaml +from buildstream.testing.runcli import cli # pylint: disable=unused-import +from tests.testutils import dummy_context + +from tests.testutils.artifactshare import create_dummy_artifact_share + + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project", +) + + +@pytest.mark.datafiles(DATA_DIR) +def test_artifact_cache_with_missing_capabilities_is_skipped(cli, tmpdir, datafiles): + project_dir = str(datafiles) + + # Set up an artifact cache. + with create_dummy_artifact_share() as share: + # Configure artifact share + cache_dir = os.path.join(str(tmpdir), 'cache') + user_config_file = str(tmpdir.join('buildstream.conf')) + user_config = { + 'scheduler': { + 'pushers': 1 + }, + 'artifacts': { + 'url': share.repo, + 'push': True, + }, + 'cachedir': cache_dir + } + _yaml.roundtrip_dump(user_config, file=user_config_file) + + with dummy_context(config=user_config_file) as context: + # Load the project + project = Project(project_dir, context) + project.ensure_fully_loaded() + + # Create a local artifact cache handle + artifactcache = context.artifactcache + + # Manually setup the CAS remote + artifactcache.setup_remotes(use_config=True) + + assert not artifactcache.has_fetch_remotes(), \ + "System didn't realize the artifact cache didn't support BuildStream" |