gtristan commented on code in PR #1890:
URL: https://github.com/apache/buildstream/pull/1890#discussion_r1512571456
##########
tests/frontend/mirror.py:
##########
@@ -807,3 +807,93 @@ def test_mirror_expand_project_and_toplevel_root(cli,
tmpdir):
# Success if the expanded %{project-root} is found
assert foo_str in contents
assert bar_str in contents
+
+
+# Test a simple SourceMirror implementation which reads
+# plugin configuration and behaves in the same way as default
+# mirrors but using data in the plugin configuration instead.
+#
[email protected](DATA_DIR)
[email protected]("datafiles")
+def test_source_mirror_plugin(cli, tmpdir):
+ output_file = os.path.join(str(tmpdir), "output.txt")
+ project_dir = str(tmpdir)
+ element_dir = os.path.join(project_dir, "elements")
+ os.makedirs(element_dir, exist_ok=True)
+ element_name = "test.bst"
+ element_path = os.path.join(element_dir, element_name)
+ element = generate_element(output_file)
+ _yaml.roundtrip_dump(element, element_path)
+
+ project_file = os.path.join(project_dir, "project.conf")
+ project = {
+ "name": "test",
+ "min-version": "2.0",
+ "element-path": "elements",
+ "aliases": {
+ "foo": "FOO/",
+ "bar": "BAR/",
+ },
+ "mirrors": [
+ {
+ "name": "middle-earth",
+ "kind": "mirror",
+ "aliases": {
+ "foo": ["<invalid>"],
Review Comment:
Additional comment about _"needing to set mirror values for aliases"_ in
general.
As I already mentioned, yes I am in favor of expanding this later in order
to support more generic application of `SourceMirror`, perhaps allowing a
project to just declare a single `SourceMirror` object once and allow that to
handle all of the url translations.
That said, there is a lot to work out for that, e.g. we have priorities and
lists etc in the API to consider.
Finally to answer _that_ question about needing to specify the aliases with
at least some _values_ for the aliases in a given mirror, no it will not
possibly work without specifying aliases in the patch's current state.
The reason for this is that the current, existing workflow, taking all
mirrors and priorities etc into account, needs to run through
`Project.get_alias_uris()`, this is where the URI fetch/track policies are
considered and this is the code section which controls the priority order of
_"each URI which shall be consulted for a given alias"_.
In order to extend `SourceMirror` to apply more generically, this whole
concept of _iterating over URIs for a given alias_ needs to be rethought.
Note also, that the _same `SourceMirror`_ may be consulted _multiple times_
should it be given more than a single URL value for a given alias that it
declares (which was of course, already the case before introducing this plugin).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]