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 2022/07/21 07:03:19 UTC

[buildstream] branch tristan/fix-delete-artifact-nonstrict created (now c7569089c)

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

tvb pushed a change to branch tristan/fix-delete-artifact-nonstrict
in repository https://gitbox.apache.org/repos/asf/buildstream.git


      at c7569089c tests/integration/cachedfail.py: Test deletion of artifacts in non-strict mode

This branch includes the following new commits:

     new de5929242 _stream.py: Query cache in Stream.delete_artifact()
     new c7569089c tests/integration/cachedfail.py: Test deletion of artifacts in non-strict mode

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: _stream.py: Query cache in Stream.delete_artifact()

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

tvb pushed a commit to branch tristan/fix-delete-artifact-nonstrict
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit de592924233e09721d6ceca9a7c4280c5d188731
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Jul 21 16:01:29 2022 +0900

    _stream.py: Query cache in Stream.delete_artifact()
    
    This is required to properly derive the cache key when deleting an artifact.
    
    Fixes: #1461
---
 src/buildstream/_stream.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index b8a018eda..3ee2468c3 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -853,6 +853,8 @@ class Stream:
         # Return list of Element and/or ArtifactElement objects
         target_objects = self.load_selection(targets, selection=selection, load_artifacts=True)
 
+        self.query_cache(target_objects)
+
         # Some of the targets may refer to the same key, so first obtain a
         # set of the refs to be removed.
         remove_refs = set()


[buildstream] 02/02: tests/integration/cachedfail.py: Test deletion of artifacts in non-strict mode

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

tvb pushed a commit to branch tristan/fix-delete-artifact-nonstrict
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c7569089cb692796a3b32942d8596cc8e4e4cd91
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Jul 21 16:02:32 2022 +0900

    tests/integration/cachedfail.py: Test deletion of artifacts in non-strict mode
---
 tests/integration/cachedfail.py | 72 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/tests/integration/cachedfail.py b/tests/integration/cachedfail.py
index 04fd33830..f0aad8a26 100644
--- a/tests/integration/cachedfail.py
+++ b/tests/integration/cachedfail.py
@@ -382,3 +382,75 @@ def test_nonstrict_retry_failed(cli, tmpdir, datafiles, use_share, retry):
             # build, and possibly discarded the failed artifact if the strong key did not match
             #
             assert "target.bst" in result.get_pulled_elements()
+
+
+# Tests that failed build artifacts in non-strict mode can be deleted.
+#
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+def test_nonstrict_delete_failed(cli, tmpdir, datafiles):
+    project = str(datafiles)
+    intermediate_path = os.path.join(project, "elements", "intermediate.bst")
+    dep_path = os.path.join(project, "elements", "dep.bst")
+    target_path = os.path.join(project, "elements", "target.bst")
+
+    # Global nonstrict configuration ensures all commands will be non-strict
+    cli.configure({"projects": {"test": {"strict": False}}})
+
+    def generate_dep(filename, dependency):
+        return {
+            "kind": "manual",
+            "depends": [dependency],
+            "config": {
+                "install-commands": [
+                    "touch %{install-root}/" + filename,
+                ],
+            },
+        }
+
+    def generate_target():
+        return {
+            "kind": "manual",
+            "depends": [
+                "dep.bst",
+            ],
+            "config": {
+                "build-commands": [
+                    "test -e /foo",
+                ],
+            },
+        }
+
+    intermediate = generate_dep("pony", "base.bst")
+    dep = generate_dep("bar", "intermediate.bst")
+    target = generate_target()
+    _yaml.roundtrip_dump(intermediate, intermediate_path)
+    _yaml.roundtrip_dump(dep, dep_path)
+    _yaml.roundtrip_dump(target, target_path)
+
+    # First build the dep / intermediate elements
+    result = cli.run(project=project, args=["build", "dep.bst"])
+    result.assert_success()
+
+    # Remove the intermediate element from cache, rebuild the dep, such that only
+    # a weak key for the dep is possible
+    cli.remove_artifact_from_cache(project, "intermediate.bst")
+    intermediate = generate_dep("horsy", "base.bst")
+    _yaml.roundtrip_dump(intermediate, intermediate_path)
+
+    result = cli.run(project=project, args=["build", "dep.bst"])
+    result.assert_success()
+    assert "dep.bst" not in result.get_built_elements()
+
+    # Try to build it, this should result in caching a failure of the target
+    result = cli.run(project=project, args=["build", "target.bst"])
+    result.assert_main_error(ErrorDomain.STREAM, None)
+
+    # Assert that it's cached in a failed artifact
+    assert cli.get_element_state(project, "target.bst") == "failed"
+
+    # Delete it
+    result = cli.run(project=project, args=["artifact", "delete", "target.bst"])
+
+    # Assert that it's cached in a failed artifact
+    assert cli.get_element_state(project, "target.bst") == "buildable"