Skip to content

Commit 523f759

Browse files
committed
tests/integration/recc.py: Add recc remote execution test
1 parent ff51120 commit 523f759

File tree

4 files changed

+177
-0
lines changed

4 files changed

+177
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: import
2+
3+
sources:
4+
- kind: tar
5+
base-dir: ''
6+
ref: 00795f1781fd5f80757dd0c60f6335c221dacfa852edad8209b390dd9cfb1f83
7+
url: buildbox:buildbox-integration/-/releases/1.3.31/downloads/recc-x86_64-linux-gnu.tgz
8+
directory: usr/bin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
kind: autotools
2+
description: recc test with autotools
3+
4+
build-depends:
5+
- filename: base/base-debian.bst
6+
config:
7+
digest-environment: RECC_REMOTE_PLATFORM_chrootRootDigest
8+
- recc/recc.bst
9+
10+
sources:
11+
- kind: tar
12+
url: project_dir:/files/amhello.tar.gz
13+
ref: 534a884bc1974ffc539a9c215e35c4217b6f666a134cd729e786b9c84af99650
14+
15+
sandbox:
16+
remote-apis-socket:
17+
path: /tmp/casd.sock
18+
19+
environment:
20+
CC: recc gcc
21+
RECC_LOG_LEVEL: debug
22+
RECC_LOG_DIRECTORY: .recc-log
23+
RECC_DEPS_GLOBAL_PATHS: 1
24+
RECC_NO_PATH_REWRITE: 1
25+
RECC_LINK: 1
26+
RECC_SERVER: unix:/tmp/casd.sock

tests/integration/project/project.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ element-path: elements
55

66
aliases:
77
test-images: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/
8+
buildbox: https://gitlab.com/BuildGrid/buildbox/
89
project_dir: file://{project_dir}
910

1011
plugins:

tests/integration/recc.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
# Pylint doesn't play well with fixtures and dependency injection from pytest
16+
# pylint: disable=redefined-outer-name
17+
18+
import os
19+
import pytest
20+
21+
from buildstream._testing import cli_integration as cli # pylint: disable=unused-import
22+
from buildstream._testing.integration import assert_contains
23+
from buildstream._testing._utils.site import HAVE_SANDBOX
24+
25+
pytestmark = pytest.mark.integration
26+
27+
28+
DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
29+
30+
31+
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
32+
@pytest.mark.datafiles(DATA_DIR)
33+
def test_remote_execution(cli, datafiles):
34+
project = str(datafiles)
35+
checkout1 = os.path.join(cli.directory, "checkout1")
36+
checkout2 = os.path.join(cli.directory, "checkout2")
37+
element_name = "recc/remoteexecution.bst"
38+
39+
# Always cache buildtrees to be able to check recc logs
40+
result = cli.run(project=project, args=["--cache-buildtrees", "always", "build", element_name])
41+
if result.exit_code != 0:
42+
# Output recc logs in case of failure
43+
cli.run(
44+
project=project,
45+
args=[
46+
"shell",
47+
"--build",
48+
"--use-buildtree",
49+
element_name,
50+
"--",
51+
"sh",
52+
"-c",
53+
"cat config.log .recc-log/* */.recc-log/*",
54+
],
55+
)
56+
assert result.exit_code == 0
57+
58+
result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout1])
59+
assert result.exit_code == 0
60+
61+
assert_contains(
62+
checkout1,
63+
[
64+
"/usr",
65+
"/usr/bin",
66+
"/usr/share",
67+
"/usr/bin/hello",
68+
"/usr/share/doc",
69+
"/usr/share/doc/amhello",
70+
"/usr/share/doc/amhello/README",
71+
],
72+
)
73+
74+
# Check the main build log
75+
result = cli.run(project=project, args=["artifact", "log", element_name])
76+
assert result.exit_code == 0
77+
log = result.output
78+
79+
# Verify we get expected output exactly once
80+
assert log.count("Making all in src") == 1
81+
82+
result = cli.run(
83+
project=project,
84+
args=[
85+
"shell",
86+
"--build",
87+
"--use-buildtree",
88+
element_name,
89+
"--",
90+
"sh",
91+
"-c",
92+
"cat src/.recc-log/recc.buildbox*",
93+
],
94+
)
95+
assert result.exit_code == 0
96+
recc_log = result.output
97+
98+
# Verify recc is successfully using remote execution for both, compiling and linking
99+
assert recc_log.count("Executing action remotely") == 2
100+
assert recc_log.count("Remote execution finished with exit code 0") == 2
101+
102+
# Delete artifact from BuildStream cache to trigger a BuildStream rebuild with action cache hits for recc
103+
result = cli.run(project=project, args=["artifact", "delete", element_name])
104+
assert result.exit_code == 0
105+
106+
result = cli.run(project=project, args=["--cache-buildtrees", "always", "build", element_name])
107+
assert result.exit_code == 0
108+
109+
result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout2])
110+
assert result.exit_code == 0
111+
112+
assert_contains(
113+
checkout2,
114+
[
115+
"/usr",
116+
"/usr/bin",
117+
"/usr/share",
118+
"/usr/bin/hello",
119+
"/usr/share/doc",
120+
"/usr/share/doc/amhello",
121+
"/usr/share/doc/amhello/README",
122+
],
123+
)
124+
125+
result = cli.run(
126+
project=project,
127+
args=[
128+
"shell",
129+
"--build",
130+
"--use-buildtree",
131+
element_name,
132+
"--",
133+
"sh",
134+
"-c",
135+
"cat src/.recc-log/recc.buildbox*",
136+
],
137+
)
138+
assert result.exit_code == 0
139+
recc_log = result.output
140+
141+
# Verify recc is getting action cache hits for both, compiling and linking
142+
assert recc_log.count("Action Cache hit") == 2

0 commit comments

Comments
 (0)