summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-06-30 14:22:52 +0200
committerJürg Billeter <j@bitron.ch>2020-06-30 14:22:52 +0200
commitdd166154b87294e9bb307403b2f934e25b6f76d6 (patch)
tree0c28dd02f9b0699059bcfc2843ee993abf4c8b22
parentea520f9d1d77fcb72bc8ebc119781107c094c245 (diff)
downloadbuildstream-dd166154b87294e9bb307403b2f934e25b6f76d6.tar.gz
tests/frontend/push.py: Add test_push_update_after_rebuild
This is a regression test to skip push only if server has identical artifact.
-rw-r--r--tests/frontend/push.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 26dd6cb4f..50e35461f 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -675,3 +675,43 @@ def test_push_after_rebuild(cli, tmpdir, datafiles):
result.assert_success()
assert result.get_pushed_elements() == ["random.bst"]
assert cli.get_element_state(project, "random.bst") == "cached"
+
+
+# Test that push after rebuilding a non-reproducible element updates the
+# artifact on the server.
+@pytest.mark.datafiles(DATA_DIR)
+def test_push_update_after_rebuild(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ generate_project(
+ project,
+ config={
+ "element-path": "elements",
+ "min-version": "2.0",
+ "plugins": [{"origin": "local", "path": "plugins", "elements": ["randomelement"]}],
+ },
+ )
+
+ with create_artifact_share(os.path.join(str(tmpdir), "artifactshare")) as share:
+ cli.configure({"artifacts": {"url": share.repo, "push": True}})
+
+ # Build the element and push the artifact
+ result = cli.run(project=project, args=["build", "random.bst"])
+ result.assert_success()
+ assert result.get_pushed_elements() == ["random.bst"]
+ assert cli.get_element_state(project, "random.bst") == "cached"
+
+ # Now delete the artifact and ensure it is not in the cache
+ result = cli.run(project=project, args=["artifact", "delete", "random.bst"])
+ assert cli.get_element_state(project, "random.bst") != "cached"
+
+ # Now rebuild the element. Reset config to disable pulling.
+ cli.config = None
+ result = cli.run(project=project, args=["build", "random.bst"])
+ result.assert_success()
+ assert cli.get_element_state(project, "random.bst") == "cached"
+
+ # Push the new build
+ cli.configure({"artifacts": {"url": share.repo, "push": True}})
+ result = cli.run(project=project, args=["artifact", "push", "random.bst"])
+ assert result.get_pushed_elements() == ["random.bst"]