summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-09-01 16:09:51 +0200
committerJürg Billeter <j@bitron.ch>2020-09-01 16:12:31 +0200
commitf9a43962f5fa39c168a521995f557b3f4e97dd08 (patch)
treeff268572125932d2fc8d735a8b0eaf8582279cc5
parentbda29b0b0549fa032983fe7d982f9b20bcbe94e6 (diff)
downloadbuildstream-f9a43962f5fa39c168a521995f557b3f4e97dd08.tar.gz
tests/sourcecache/push.py: Add test_push_missing_source_after_build()
Test that source push succeeds if the source needs to be fetched even if the artifact of the corresponding element is already cached.
-rw-r--r--tests/sourcecache/push.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py
index 9f8663a4a..902ae943d 100644
--- a/tests/sourcecache/push.py
+++ b/tests/sourcecache/push.py
@@ -252,3 +252,33 @@ def test_source_push_build_fail(cli, tmpdir, datafiles):
# Sources are not pushed as the build queue is before the source push
# queue.
assert "Pushed source " not in res.stderr
+
+
+# Test that source push succeeds if the source needs to be fetched
+# even if the artifact of the corresponding element is already cached.
+@pytest.mark.datafiles(DATA_DIR)
+def test_push_missing_source_after_build(cli, tmpdir, datafiles):
+ cache_dir = os.path.join(str(tmpdir), "cache")
+ project_dir = str(datafiles)
+ element_name = "import-bin.bst"
+
+ res = cli.run(project=project_dir, args=["build", element_name])
+ res.assert_success()
+
+ # Delete source but keep artifact in cache
+ shutil.rmtree(os.path.join(cache_dir, "source_protos"))
+
+ 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": {"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=["source", "push", element_name])
+ res.assert_success()
+ assert "fetch:{}".format(element_name) in res.stderr
+ assert "Pushed source" in res.stderr