summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-10-03 12:48:07 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-10-03 12:48:07 +0000
commite49698076529da604ecdadb91c10d9d4a2a2a736 (patch)
treeaae1ccb515c0947d61f3c8f0174bf6c6786bf322
parent9127196453154106d79f46194317382ed145cfa5 (diff)
parent3bf895d217e01a01d655c66da611722c6d3c115e (diff)
downloadbuildstream-e49698076529da604ecdadb91c10d9d4a2a2a736.tar.gz
Merge branch 'jonathan/source-mirror-project-refs' into 'master'
tests: Add regression test for mirroring with project.refs See merge request BuildStream/buildstream!823
-rw-r--r--tests/frontend/mirror.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py
index a5a80f0b9..91a874335 100644
--- a/tests/frontend/mirror.py
+++ b/tests/frontend/mirror.py
@@ -140,6 +140,82 @@ def test_mirror_fetch(cli, tmpdir, datafiles, kind):
@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")])
+@pytest.mark.parametrize("mirror", [("no-mirror"), ("mirror"), ("unrelated-mirror")])
+def test_mirror_fetch_ref_storage(cli, tmpdir, datafiles, ref_storage, mirror):
+ bin_files_path = os.path.join(str(datafiles), 'files', 'bin-files', 'usr')
+ dev_files_path = os.path.join(str(datafiles), 'files', 'dev-files', 'usr')
+ upstream_repodir = os.path.join(str(tmpdir), 'upstream')
+ mirror_repodir = os.path.join(str(tmpdir), 'mirror')
+ project_dir = os.path.join(str(tmpdir), 'project')
+ os.makedirs(project_dir)
+ element_dir = os.path.join(project_dir, 'elements')
+
+ # Create repo objects of the upstream and mirror
+ upstream_repo = create_repo('tar', upstream_repodir)
+ upstream_ref = upstream_repo.create(bin_files_path)
+ mirror_repo = upstream_repo.copy(mirror_repodir)
+ mirror_ref = upstream_ref
+ upstream_ref = upstream_repo.create(dev_files_path)
+
+ element = {
+ 'kind': 'import',
+ 'sources': [
+ upstream_repo.source_config(ref=upstream_ref if ref_storage == 'inline' else None)
+ ]
+ }
+ element_name = 'test.bst'
+ element_path = os.path.join(element_dir, element_name)
+ full_repo = element['sources'][0]['url']
+ upstream_map, repo_name = os.path.split(full_repo)
+ alias = 'foo'
+ aliased_repo = alias + ':' + repo_name
+ element['sources'][0]['url'] = aliased_repo
+ full_mirror = mirror_repo.source_config()['url']
+ mirror_map, _ = os.path.split(full_mirror)
+ os.makedirs(element_dir)
+ _yaml.dump(element, element_path)
+
+ if ref_storage == 'project.refs':
+ # Manually set project.refs to avoid caching the repo prematurely
+ project_refs = {'projects': {
+ 'test': {
+ element_name: [
+ {'ref': upstream_ref}
+ ]
+ }
+ }}
+ project_refs_path = os.path.join(project_dir, 'project.refs')
+ _yaml.dump(project_refs, project_refs_path)
+
+ project = {
+ 'name': 'test',
+ 'element-path': 'elements',
+ 'aliases': {
+ alias: upstream_map + "/"
+ },
+ 'ref-storage': ref_storage
+ }
+ if mirror != 'no-mirror':
+ mirror_data = [{
+ 'name': 'middle-earth',
+ 'aliases': {alias: [mirror_map + '/']}
+ }]
+ if mirror == 'unrelated-mirror':
+ mirror_data.insert(0, {
+ 'name': 'narnia',
+ 'aliases': {'frob': ['http://www.example.com/repo']}
+ })
+ project['mirrors'] = mirror_data
+
+ project_file = os.path.join(project_dir, 'project.conf')
+ _yaml.dump(project, project_file)
+
+ result = cli.run(project=project_dir, args=['fetch', element_name])
+ result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
def test_mirror_fetch_upstream_absent(cli, tmpdir, datafiles, kind):
bin_files_path = os.path.join(str(datafiles), 'files', 'bin-files', 'usr')