summaryrefslogtreecommitdiff
path: root/tests/frontend
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-01-22 07:51:51 +0100
committerJürg Billeter <j@bitron.ch>2019-01-24 14:38:50 +0100
commit99b5c0af611f1eaa2eff710c3e9ee4ff5325d301 (patch)
tree46274ce7bc8f4f442006a463146fd296c6fb0032 /tests/frontend
parentce1c10ec2925b3f1c30a166dee23088a64b2d473 (diff)
downloadbuildstream-99b5c0af611f1eaa2eff710c3e9ee4ff5325d301.tar.gz
tests/frontend/pull.py: Add default target test for bst push/pull
Diffstat (limited to 'tests/frontend')
-rw-r--r--tests/frontend/pull.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index f0d6fbf4e..20b740948 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -80,6 +80,56 @@ def test_push_pull_all(cli, tmpdir, datafiles):
# Tests that:
#
+# * `bst push` (default targets) pushes all built elements to configured 'push' cache
+# * `bst pull` (default targets) downloads everything from cache after local deletion
+#
+@pytest.mark.datafiles(DATA_DIR + '_world')
+def test_push_pull_default_targets(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 target elements
+ cli.configure({
+ 'artifacts': {'url': share.repo}
+ })
+ result = cli.run(project=project, args=['build'])
+ result.assert_success()
+ assert cli.get_element_state(project, 'target.bst') == 'cached'
+
+ # Push all elements
+ cli.configure({
+ 'artifacts': {'url': share.repo, 'push': True}
+ })
+ result = cli.run(project=project, args=['artifact', 'push'])
+ result.assert_success()
+
+ # Assert that everything is now cached in the remote.
+ all_elements = ['target.bst', 'import-bin.bst', 'import-dev.bst', 'compose-all.bst']
+ for element_name in all_elements:
+ assert_shared(cli, share, project, element_name)
+
+ # Now we've pushed, delete the user's local artifact cache
+ # directory and try to redownload it from the share
+ #
+ artifacts = os.path.join(cli.directory, 'artifacts')
+ shutil.rmtree(artifacts)
+
+ # Assert that nothing is cached locally anymore
+ states = cli.get_element_states(project, all_elements)
+ assert not any(states[e] == 'cached' for e in all_elements)
+
+ # Now try bst pull
+ result = cli.run(project=project, args=['artifact', 'pull'])
+ result.assert_success()
+
+ # And assert that it's again in the local cache, without having built
+ states = cli.get_element_states(project, all_elements)
+ assert not any(states[e] != 'cached' for e in all_elements)
+
+
+# Tests that:
+#
# * `bst build` pushes all build elements ONLY to configured 'push' cache
# * `bst pull` finds artifacts that are available only in the secondary cache
#