summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2018-11-28 16:01:14 +0000
committerJürg Billeter <j@bitron.ch>2018-11-30 13:30:35 +0000
commit1123b9a12ee00b8a4c42fc96b1f4d98894c22172 (patch)
treec0b1f983b12178a9fe774a2d6c2c9b7c55059186 /tests
parent033a5ad99cb82386ee928ece5a0fe8fbd5ac5c67 (diff)
downloadbuildstream-1123b9a12ee00b8a4c42fc96b1f4d98894c22172.tar.gz
_stream.py: Ability to pull missing buildtrees outside of pull/build
Adds helper function _buildtree_pull_required() to determine if a pullqueue should be constructed, for commands outside of bst pull and build where it is determined that an element's buildtree artifact is to be required given the respective semantics and config. Utilised in push() to attempt to mitigate skipping the push of partial elements without the user having to have preceded it with an explicit pull. cli.py: Add new behaviour to push command description element.py: Move _cached_buildtree() to be non local private method, use _KeyStrength types to reduce duplication. tests/integration/pullbuildtrees.py also updated to cover this use-case.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/pullbuildtrees.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/integration/pullbuildtrees.py b/tests/integration/pullbuildtrees.py
index 0f9397251..f6fc71226 100644
--- a/tests/integration/pullbuildtrees.py
+++ b/tests/integration/pullbuildtrees.py
@@ -38,7 +38,8 @@ def test_pullbuildtrees(cli, tmpdir, datafiles, integration_cache):
# Create artifact shares for pull & push testing
with create_artifact_share(os.path.join(str(tmpdir), 'share1')) as share1,\
- create_artifact_share(os.path.join(str(tmpdir), 'share2')) as share2:
+ create_artifact_share(os.path.join(str(tmpdir), 'share2')) as share2,\
+ create_artifact_share(os.path.join(str(tmpdir), 'share3')) as share3:
cli.configure({
'artifacts': {'url': share1.repo, 'push': True},
'artifactdir': os.path.join(str(tmpdir), 'artifacts')
@@ -123,6 +124,32 @@ def test_pullbuildtrees(cli, tmpdir, datafiles, integration_cache):
assert share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))
default_state(cli, tmpdir, share1)
+ # Assert that bst push will automatically attempt to pull a missing buildtree
+ # if pull-buildtrees is set, however as share3 is the only defined remote and is empty,
+ # assert that no element artifact buildtrees are pulled (no available remote buildtree) and thus the
+ # artifact cannot be pushed.
+ result = cli.run(project=project, args=['pull', element_name])
+ assert element_name in result.get_pulled_elements()
+ cli.configure({'artifacts': {'url': share3.repo, 'push': True}})
+ result = cli.run(project=project, args=['--pull-buildtrees', 'push', element_name])
+ assert "Attempting to fetch missing artifact buildtrees" in result.stderr
+ assert element_name not in result.get_pulled_elements()
+ assert not os.path.isdir(buildtreedir)
+ assert element_name not in result.get_pushed_elements()
+ assert not share3.has_artifact('test', element_name, cli.get_element_key(project, element_name))
+
+ # Assert that if we add an extra remote that has the buildtree artfact cached, bst push will
+ # automatically attempt to pull it and will be successful, leading to the full artifact being pushed
+ # to the empty share3. This gives the ability to attempt push currently partial artifacts to a remote,
+ # without exlipictly requiring a bst pull.
+ cli.configure({'artifacts': [{'url': share1.repo, 'push': False}, {'url': share3.repo, 'push': True}]})
+ result = cli.run(project=project, args=['--pull-buildtrees', 'push', element_name])
+ assert "Attempting to fetch missing artifact buildtrees" in result.stderr
+ assert element_name in result.get_pulled_elements()
+ assert os.path.isdir(buildtreedir)
+ assert element_name in result.get_pushed_elements()
+ assert share3.has_artifact('test', element_name, cli.get_element_key(project, element_name))
+
# Ensure that only valid pull-buildtrees boolean options make it through the loading
# process.