This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch juerg/build-with-source-push in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 5af98292f3f975a02a28de4ebfdaf6783955cc93 Author: Jürg Billeter <[email protected]> AuthorDate: Thu Mar 18 08:22:33 2021 +0100 tests/sourcecache/push.py: Add test_build_push_source_twice This is a regression test for #1456. --- tests/sourcecache/push.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py index 47e845b..7814a7b 100644 --- a/tests/sourcecache/push.py +++ b/tests/sourcecache/push.py @@ -287,3 +287,35 @@ def test_push_missing_source_after_build(cli, tmpdir, datafiles): res.assert_success() assert "fetch:{}".format(element_name) in res.stderr assert "Pushed source" in res.stderr + + +# Regression test for https://github.com/apache/buildstream/issues/1456 +# Test that a build pipeline with source push enabled doesn't fail if an +# element is already cached. [email protected](DATA_DIR) +def test_build_push_source_twice(cli, tmpdir, datafiles): + cache_dir = os.path.join(str(tmpdir), "cache") + project_dir = str(datafiles) + element_name = "import-bin.bst" + + with create_artifact_share(os.path.join(str(tmpdir), "sourceshare")) as share: + user_config_file = str(tmpdir.join("buildstream.conf")) + user_config = { + "scheduler": {"pushers": 1}, + "source-caches": {"servers": [{"url": share.repo, "push": True,}]}, + "cachedir": cache_dir, + } + _yaml.roundtrip_dump(user_config, file=user_config_file) + cli.configure(user_config) + + res = cli.run(project=project_dir, args=["build", element_name]) + res.assert_success() + assert "fetch:{}".format(element_name) in res.stderr + assert "Pushed source" in res.stderr + + # The second build pipeline is a no-op as everything is already cached. + # However, this verifies that the pipeline behaves as expected. + res = cli.run(project=project_dir, args=["build", element_name]) + res.assert_success() + assert "fetch:{}".format(element_name) not in res.stderr + assert "Pushed source" not in res.stderr
