summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-03-08 14:28:49 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-25 11:46:44 +0000
commitd68fe0b070951df61f406d5da4a0f0ceba65c218 (patch)
treedadc7bf3f2ee3b017973e3d63b9220c9379e7b22 /tests
parent12cdc71db8b46dcc1d64250858fc1b0470871863 (diff)
downloadbuildstream-d68fe0b070951df61f406d5da4a0f0ceba65c218.tar.gz
tests: Add source cache push failure test
Part of #440
Diffstat (limited to 'tests')
-rw-r--r--tests/sourcecache/push.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py
index 149513c54..8fe06886b 100644
--- a/tests/sourcecache/push.py
+++ b/tests/sourcecache/push.py
@@ -139,3 +139,45 @@ def test_push_pull(cli, datafiles, tmpdir):
# check it's pulls from the share
res = cli.run(project=project_dir, args=['build', 'push.bst'])
res.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_push_fail(cli, tmpdir, datafiles):
+ project_dir = str(datafiles)
+ cache_dir = os.path.join(str(tmpdir), 'cache')
+
+ # set up config with remote that we'll take down
+ with create_artifact_share(os.path.join(str(tmpdir), 'sourceshare')) as share:
+ remote = share.repo
+ user_config_file = str(tmpdir.join('buildstream.conf'))
+ user_config = {
+ 'scheduler': {
+ 'pushers': 1
+ },
+ 'source-caches': {
+ 'url': share.repo,
+ 'push': True,
+ },
+ 'cachedir': cache_dir,
+ }
+ _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file)
+ cli.configure(user_config)
+
+ # create repo to pull from
+ repo = create_repo('git', str(tmpdir))
+ ref = repo.create(os.path.join(project_dir, 'files'))
+ element_path = os.path.join(project_dir, 'elements')
+ element_name = 'push.bst'
+ element = {
+ 'kind': 'import',
+ 'sources': [repo.source_config(ref=ref)]
+ }
+ _yaml.dump(element, os.path.join(element_path, element_name))
+
+ # build and check that it fails to set up the remote
+ res = cli.run(project=project_dir, args=['build', 'push.bst'])
+ res.assert_success()
+ assert ("Failed to initialize remote {}: Connect Failed"
+ .format(remote)) in res.stderr
+ assert "Pushing" not in res.stderr
+ assert "Pushed" not in res.stderr