diff options
author | Jürg Billeter <j@bitron.ch> | 2019-03-13 10:40:14 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-03-25 10:24:41 +0100 |
commit | 190c272d8e31aac5ef83da7ab4f40ac543a163f6 (patch) | |
tree | fd3d41660a0bd839f724aebb55af11cb7d23df7c /tests | |
parent | 36f032ce1c7bd67865751d0323837b7276377b62 (diff) | |
download | buildstream-190c272d8e31aac5ef83da7ab4f40ac543a163f6.tar.gz |
tests/frontend/pull.py: Add test for pull completing partial artifacts
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/pull.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index 950fd90fc..a2cbffa04 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -5,6 +5,7 @@ import os import shutil import stat import pytest +from buildstream import utils from buildstream.plugintestutils import cli # pylint: disable=unused-import from tests.testutils import create_artifact_share, generate_junction @@ -394,6 +395,36 @@ def test_pull_missing_blob(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) +def test_pull_missing_local_blob(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + + with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share: + + # First build the import-bin element and push to the remote. + cli.configure({ + 'artifacts': {'url': share.repo, 'push': True} + }) + result = cli.run(project=project, args=['build', 'import-bin.bst']) + result.assert_success() + assert cli.get_element_state(project, 'import-bin.bst') == 'cached' + + # Delete a file blob from the local cache. + # This is a placeholder to test partial CAS handling until we support + # partial artifact pulling (or blob-based CAS expiry). + # + digest = utils.sha256sum(os.path.join(project, 'files', 'bin-files', 'usr', 'bin', 'hello')) + objpath = os.path.join(cli.directory, 'cas', 'objects', digest[:2], digest[2:]) + os.unlink(objpath) + + # Now try bst build + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_success() + + # Assert that the import-bin artifact was pulled (completing the partial artifact) + assert result.get_pulled_elements() == ['import-bin.bst'] + + +@pytest.mark.datafiles(DATA_DIR) def test_pull_missing_notifies_user(caplog, cli, tmpdir, datafiles): project = str(datafiles) caplog.set_level(1) |