You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:11:48 UTC

[buildstream] branch willsalmon/test-push-update created (now f70df97)

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

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


      at f70df97  tests/frontend/push.py: Add test_push_update_after_rebuild

This branch includes the following new commits:

     new 0dbdd83  _artifactcache.py: Skip push only if server has identical artifact
     new f70df97  tests/frontend/push.py: Add test_push_update_after_rebuild

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/02: _artifactcache.py: Skip push only if server has identical artifact

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0dbdd83e111ad805f73202edbc992411e8e0a296
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Tue Jun 30 14:02:05 2020 +0200

    _artifactcache.py: Skip push only if server has identical artifact
    
    The existing artifact on a server may refer to a previous build and the
    referenced blobs may no longer exist. As we push blobs referenced by the
    local artifact proto, we can skip pushing the artifact proto only if the
    artifact proto on the server is identical.
    
    It would be more efficient to always push the artifact proto without
    checking what artifact proto is currently on the server. However, we
    need the extra information to mark push jobs as skipped. This is clearer
    to users and also required by some test cases.
---
 src/buildstream/_artifactcache.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py
index c1e87b6..46fc5fb 100644
--- a/src/buildstream/_artifactcache.py
+++ b/src/buildstream/_artifactcache.py
@@ -541,26 +541,27 @@ class ArtifactCache(BaseCache):
 
         keys = list(utils._deduplicate([artifact_proto.strong_key, artifact_proto.weak_key]))
 
-        # Check whether the artifact is on the server
+        pushed = False
+
         for key in keys:
             try:
-                remote.get_artifact(element.get_artifact_name(key=key))
+                remote_artifact = remote.get_artifact(element.get_artifact_name(key=key))
+                # Skip push if artifact is already on the server
+                if remote_artifact == artifact_proto:
+                    continue
             except grpc.RpcError as e:
                 if e.code() != grpc.StatusCode.NOT_FOUND:
                     raise ArtifactError(
                         "Error checking artifact cache with status {}: {}".format(e.code().name, e.details())
                     )
-            else:
-                return False
 
-        # If not, we send the artifact proto
-        for key in keys:
             try:
                 remote.update_artifact(element.get_artifact_name(key=key), artifact_proto)
+                pushed = True
             except grpc.RpcError as e:
                 raise ArtifactError("Failed to push artifact with status {}: {}".format(e.code().name, e.details()))
 
-        return True
+        return pushed
 
     # _pull_artifact_storage():
     #


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

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb 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"]