diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-04-15 11:21:27 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-04-15 11:21:27 +0000 |
commit | 599485fc7633ec22c2645b97648fd4454d5f8636 (patch) | |
tree | 7547737f7b995de139130ca2038888478b32a1e6 | |
parent | 4aafa38e0d3c73b2fb2663984ce170e7d7ed8e95 (diff) | |
parent | b0a193b20fe18cbc4530629150eeedb745aabf6f (diff) | |
download | buildstream-599485fc7633ec22c2645b97648fd4454d5f8636.tar.gz |
Merge branch 'tristan/fix-non-strict-push-1.2' into 'bst-1.2'
Fix non strict push 1.2
See merge request BuildStream/buildstream!1289
-rw-r--r-- | buildstream/_stream.py | 14 | ||||
-rw-r--r-- | tests/frontend/push.py | 46 |
2 files changed, 60 insertions, 0 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py index 310bfbde0..19c73b85e 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -344,6 +344,20 @@ class Stream(): if not self._artifacts.has_push_remotes(): raise StreamError("No artifact caches available for pushing artifacts") + # Mark all dependencies of all selected elements as "pulled" before + # trying to push. + # + # In non-strict mode, elements which are cached by their weak keys + # will attempt to pull a remote artifact by it's strict key and prefer + # a strict key artifact, however pull does not occur when running + # a `bst push` session. + # + # Marking the elements as pulled is a workaround which ensures that + # the cache keys are resolved before pushing. + # + for element in elements: + element._pull_done() + self._pipeline.assert_consistent(elements) self._add_queue(PushQueue(self._scheduler)) self._enqueue_plan(elements) diff --git a/tests/frontend/push.py b/tests/frontend/push.py index 33730d9e2..0839507d7 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -389,3 +389,49 @@ def test_push_already_cached(caplog, cli, tmpdir, datafiles): assert not result.get_pushed_elements(), "No elements should have been pushed since the cache was populated" assert "INFO Remote ({}) already has ".format(share.repo) in result.stderr assert "SKIPPED Push" in result.stderr + + +# This test ensures that we are able to run `bst push` in non strict mode +# and that we do not crash when trying to push elements even though they +# have not yet been pulled. +# +# This is a regression test for issue #990 +# +@pytest.mark.datafiles(DATA_DIR) +def test_push_no_strict(caplog, cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + caplog.set_level(1) + + with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share: + cli.configure({ + 'artifacts': { + 'url': share.repo, + 'push': True + }, + 'projects': { + 'test': { + 'strict': False + } + } + }) + + # First get us a build + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_success() + + # Now cause one of the dependenies to change their cache key + # + # Here we just add a file, causing the strong cache key of the + # import-bin.bst element to change due to the local files it + # imports changing. + path = os.path.join(project, 'files', 'bin-files', 'newfile') + with open(path, 'w') as f: + f.write("PONY !") + + # Now build again after having changed the dependencies + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_success() + + # Now run `bst push`. + result = cli.run(project=project, args=['push', '--deps', 'all', 'target.bst']) + result.assert_success() |