You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:24:40 UTC

[buildstream] 02/02: tests/frontend/push.py: Add test_push_update_after_rebuild

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch willsalmon/test-push-update
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f70df97189d5f46270c940ea9d05750d8c6ce535
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Tue Jun 30 14:22:52 2020 +0200

    tests/frontend/push.py: Add test_push_update_after_rebuild
    
    This is a regression test to skip push only if server has identical
    artifact.
---
 tests/frontend/push.py | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 26dd6cb..50e3546 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"]