summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-06-30 14:22:52 +0200
committerWilliam Salmon <will.salmon@codethink.co.uk>2020-07-02 08:49:00 +0100
commitf70df97189d5f46270c940ea9d05750d8c6ce535 (patch)
tree8db3e9ebdfccf8cc74629c67d31d97fe9b17aa2e
parent0dbdd83e111ad805f73202edbc992411e8e0a296 (diff)
downloadbuildstream-willsalmon/test-push-update.tar.gz
tests/frontend/push.py: Add test_push_update_after_rebuildwillsalmon/test-push-update
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"]