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

juergbi pushed a commit to branch jbilleter/recc
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 585960c5780978a7b6c1475238e645bd29f4bf52
Author: Jürg Billeter <[email protected]>
AuthorDate: Fri Aug 29 16:38:23 2025 +0200

    tests/integration/recc.py: Add recc remote execution test
---
 tests/integration/project/elements/recc/recc.bst   |   8 ++
 .../project/elements/recc/remoteexecution.bst      |  26 ++++
 tests/integration/project/project.conf             |   1 +
 tests/integration/recc.py                          | 142 +++++++++++++++++++++
 4 files changed, 177 insertions(+)

diff --git a/tests/integration/project/elements/recc/recc.bst 
b/tests/integration/project/elements/recc/recc.bst
new file mode 100644
index 000000000..c9c203010
--- /dev/null
+++ b/tests/integration/project/elements/recc/recc.bst
@@ -0,0 +1,8 @@
+kind: import
+
+sources:
+  - kind: tar
+    base-dir: ''
+    ref: 00795f1781fd5f80757dd0c60f6335c221dacfa852edad8209b390dd9cfb1f83
+    url: 
buildbox:buildbox-integration/-/releases/1.3.31/downloads/recc-x86_64-linux-gnu.tgz
+    directory: usr/bin
diff --git a/tests/integration/project/elements/recc/remoteexecution.bst 
b/tests/integration/project/elements/recc/remoteexecution.bst
new file mode 100644
index 000000000..269895eb2
--- /dev/null
+++ b/tests/integration/project/elements/recc/remoteexecution.bst
@@ -0,0 +1,26 @@
+kind: autotools
+description: recc test with autotools
+
+build-depends:
+- filename: base/base-debian.bst
+  config:
+    digest-environment: RECC_REMOTE_PLATFORM_chrootRootDigest
+- recc/recc.bst
+
+sources:
+- kind: tar
+  url: project_dir:/files/amhello.tar.gz
+  ref: 534a884bc1974ffc539a9c215e35c4217b6f666a134cd729e786b9c84af99650
+
+sandbox:
+  remote-apis-socket:
+    path: /tmp/casd.sock
+
+environment:
+  CC: recc gcc
+  RECC_LOG_LEVEL: debug
+  RECC_LOG_DIRECTORY: .recc-log
+  RECC_DEPS_GLOBAL_PATHS: 1
+  RECC_NO_PATH_REWRITE: 1
+  RECC_LINK: 1
+  RECC_SERVER: unix:/tmp/casd.sock
diff --git a/tests/integration/project/project.conf 
b/tests/integration/project/project.conf
index ba0228348..2d5a36e90 100644
--- a/tests/integration/project/project.conf
+++ b/tests/integration/project/project.conf
@@ -5,6 +5,7 @@ element-path: elements
 
 aliases:
   test-images: 
https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/
+  buildbox: https://gitlab.com/BuildGrid/buildbox/
   project_dir: file://{project_dir}
 
 plugins:
diff --git a/tests/integration/recc.py b/tests/integration/recc.py
new file mode 100644
index 000000000..c43ece5b6
--- /dev/null
+++ b/tests/integration/recc.py
@@ -0,0 +1,142 @@
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+# Pylint doesn't play well with fixtures and dependency injection from pytest
+# pylint: disable=redefined-outer-name
+
+import os
+import pytest
+
+from buildstream._testing import cli_integration as cli  # pylint: 
disable=unused-import
+from buildstream._testing.integration import assert_contains
+from buildstream._testing._utils.site import HAVE_SANDBOX
+
+pytestmark = pytest.mark.integration
+
+
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
+
+
[email protected](not HAVE_SANDBOX, reason="Only available with a 
functioning sandbox")
[email protected](DATA_DIR)
+def test_remote_execution(cli, datafiles):
+    project = str(datafiles)
+    checkout1 = os.path.join(cli.directory, "checkout1")
+    checkout2 = os.path.join(cli.directory, "checkout2")
+    element_name = "recc/remoteexecution.bst"
+
+    # Always cache buildtrees to be able to check recc logs
+    result = cli.run(project=project, args=["--cache-buildtrees", "always", 
"build", element_name])
+    if result.exit_code != 0:
+        # Output recc logs in case of failure
+        cli.run(
+            project=project,
+            args=[
+                "shell",
+                "--build",
+                "--use-buildtree",
+                element_name,
+                "--",
+                "sh",
+                "-c",
+                "cat config.log .recc-log/* */.recc-log/*",
+            ],
+        )
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["artifact", "checkout", 
element_name, "--directory", checkout1])
+    assert result.exit_code == 0
+
+    assert_contains(
+        checkout1,
+        [
+            "/usr",
+            "/usr/bin",
+            "/usr/share",
+            "/usr/bin/hello",
+            "/usr/share/doc",
+            "/usr/share/doc/amhello",
+            "/usr/share/doc/amhello/README",
+        ],
+    )
+
+    # Check the main build log
+    result = cli.run(project=project, args=["artifact", "log", element_name])
+    assert result.exit_code == 0
+    log = result.output
+
+    # Verify we get expected output exactly once
+    assert log.count("Making all in src") == 1
+
+    result = cli.run(
+        project=project,
+        args=[
+            "shell",
+            "--build",
+            "--use-buildtree",
+            element_name,
+            "--",
+            "sh",
+            "-c",
+            "cat src/.recc-log/recc.buildbox*",
+        ],
+    )
+    assert result.exit_code == 0
+    recc_log = result.output
+
+    # Verify recc is successfully using remote execution for both, compiling 
and linking
+    assert recc_log.count("Executing action remotely") == 2
+    assert recc_log.count("Remote execution finished with exit code 0") == 2
+
+    # Delete artifact from BuildStream cache to trigger a BuildStream rebuild 
with action cache hits for recc
+    result = cli.run(project=project, args=["artifact", "delete", 
element_name])
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["--cache-buildtrees", "always", 
"build", element_name])
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["artifact", "checkout", 
element_name, "--directory", checkout2])
+    assert result.exit_code == 0
+
+    assert_contains(
+        checkout2,
+        [
+            "/usr",
+            "/usr/bin",
+            "/usr/share",
+            "/usr/bin/hello",
+            "/usr/share/doc",
+            "/usr/share/doc/amhello",
+            "/usr/share/doc/amhello/README",
+        ],
+    )
+
+    result = cli.run(
+        project=project,
+        args=[
+            "shell",
+            "--build",
+            "--use-buildtree",
+            element_name,
+            "--",
+            "sh",
+            "-c",
+            "cat src/.recc-log/recc.buildbox*",
+        ],
+    )
+    assert result.exit_code == 0
+    recc_log = result.output
+
+    # Verify recc is getting action cache hits for both, compiling and linking
+    assert recc_log.count("Action Cache hit") == 2

Reply via email to