summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-09-24 15:18:55 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-10-02 17:39:23 +0100
commit9b0f0811a2c746bda69125d16ce26731e58f5c4d (patch)
tree14531cc93c1c18648989cd6fc81fcc5ce7d8a266
parent0458bc4e6173e499d6d3be4f46e5484331f411b6 (diff)
downloadbuildstream-jonathan/source-mirror-project-refs.tar.gz
tests: Add regression test for mirroring with project.refsjonathan/source-mirror-project-refs
-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')