summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2017-09-19 11:35:53 +0200
committerMathieu Bridon <bochecha@daitauha.fr>2017-09-19 12:00:51 +0200
commit7aba0bfc906409073c4d246ec009a8622551726a (patch)
tree6ea067428461afa23b044d365e1d338d82cbca3a
parent00e08459c4ac0ee7d150b282d1228df1d60aff12 (diff)
downloadbuildstream-7aba0bfc906409073c4d246ec009a8622551726a.tar.gz
Test the proper fallback of artifact configs
-rw-r--r--tests/frontend/pull.py36
-rw-r--r--tests/frontend/push.py38
2 files changed, 67 insertions, 7 deletions
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index 6a26a67fb..114cf9950 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -24,8 +24,15 @@ def assert_shared(cli, share, project, element_name):
.format(share.repo, element_name))
+@pytest.mark.parametrize(
+ 'user_url, project_url, override_url',
+ [
+ pytest.param('share.repo', '', '', id='user-config'),
+ pytest.param('/tmp/share/user', 'share.repo', '', id='project-config'),
+ pytest.param('/tmp/share/user', '/tmp/share/project', 'share.repo', id='project-override-in-user-config'),
+ ])
@pytest.mark.datafiles(DATA_DIR)
-def test_push_pull(cli, tmpdir, datafiles):
+def test_push_pull(cli, tmpdir, datafiles, user_url, project_url, override_url):
project = os.path.join(datafiles.dirname, datafiles.basename)
share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'))
@@ -37,14 +44,37 @@ def test_push_pull(cli, tmpdir, datafiles):
state = cli.get_element_state(project, 'import-bin.bst')
assert state == 'cached'
+ user_url = share.repo if user_url == 'share.repo' else user_url
+ project_url = share.repo if project_url == 'share.repo' else project_url
+ override_url = share.repo if override_url == 'share.repo' else override_url
+
# Configure artifact share
cli.configure({
'artifacts': {
- 'pull-url': share.repo,
- 'push-url': share.repo,
+ 'pull-url': user_url,
+ 'push-url': user_url,
+ },
+ 'projects': {
+ 'test': {
+ 'artifacts': {
+ 'pull-url': override_url,
+ 'push-url': override_url,
+ }
+ }
}
})
+ if project_url:
+ project_conf_file = str(datafiles.join('project.conf'))
+ project_config = _yaml.load(project_conf_file)
+ project_config.update({
+ 'artifacts': {
+ 'pull-url': project_url,
+ 'push-url': project_url,
+ }
+ })
+ _yaml.dump(_yaml.node_sanitize(project_config), filename=project_conf_file)
+
# Now try bst push
result = cli.run(project=project, args=['push', 'import-bin.bst'])
assert result.exit_code == 0
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index c7de02f54..c1131f901 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -23,9 +23,16 @@ def assert_shared(cli, share, project, element_name):
.format(share.repo, element_name))
+@pytest.mark.parametrize(
+ 'user_url, project_url, override_url',
+ [
+ pytest.param('share.repo', '', '', id='user-config'),
+ pytest.param('/tmp/share/user', 'share.repo', '', id='project-config'),
+ pytest.param('/tmp/share/user', '/tmp/share/project', 'share.repo', id='project-override-in-user-config'),
+ ])
@pytest.mark.datafiles(DATA_DIR)
-def test_push(cli, tmpdir, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+def test_push(cli, tmpdir, datafiles, user_url, project_url, override_url):
+ project = str(datafiles)
share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'))
# First build it without the artifact cache configured
@@ -36,14 +43,37 @@ def test_push(cli, tmpdir, datafiles):
state = cli.get_element_state(project, 'target.bst')
assert state == 'cached'
+ user_url = share.repo if user_url == 'share.repo' else user_url
+ project_url = share.repo if project_url == 'share.repo' else project_url
+ override_url = share.repo if override_url == 'share.repo' else override_url
+
# Configure artifact share
cli.configure({
'artifacts': {
- 'pull-url': share.repo,
- 'push-url': share.repo,
+ 'pull-url': user_url,
+ 'push-url': user_url,
+ },
+ 'projects': {
+ 'test': {
+ 'artifacts': {
+ 'pull-url': override_url,
+ 'push-url': override_url,
+ }
+ }
}
})
+ if project_url:
+ project_conf_file = str(datafiles.join('project.conf'))
+ project_config = _yaml.load(project_conf_file)
+ project_config.update({
+ 'artifacts': {
+ 'pull-url': project_url,
+ 'push-url': project_url,
+ }
+ })
+ _yaml.dump(_yaml.node_sanitize(project_config), filename=project_conf_file)
+
# Now try bst push
result = cli.run(project=project, args=['push', 'target.bst'])
assert result.exit_code == 0