Skip to content

Commit 9c9e17d

Browse files
committed
tests/integration/recc.py: Add recc cache-only test
1 parent 523f759 commit 9c9e17d

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
action-cache-enable-update: true
19+
20+
environment:
21+
CC: recc gcc
22+
RECC_LOG_LEVEL: debug
23+
RECC_LOG_DIRECTORY: .recc-log
24+
RECC_DEPS_GLOBAL_PATHS: 1
25+
RECC_NO_PATH_REWRITE: 1
26+
RECC_LINK: 1
27+
RECC_CACHE_ONLY: 1
28+
RECC_CACHE_UPLOAD_LOCAL_BUILD: 1
29+
RECC_SERVER: unix:/tmp/casd.sock

tests/integration/recc.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,116 @@ def test_remote_execution(cli, datafiles):
140140

141141
# Verify recc is getting action cache hits for both, compiling and linking
142142
assert recc_log.count("Action Cache hit") == 2
143+
144+
145+
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
146+
@pytest.mark.datafiles(DATA_DIR)
147+
def test_cache_only(cli, datafiles):
148+
project = str(datafiles)
149+
checkout1 = os.path.join(cli.directory, "checkout1")
150+
checkout2 = os.path.join(cli.directory, "checkout2")
151+
element_name = "recc/cacheonly.bst"
152+
153+
# Always cache buildtrees to be able to check recc logs
154+
result = cli.run(project=project, args=["--cache-buildtrees", "always", "build", element_name])
155+
if result.exit_code != 0:
156+
# Output recc logs in case of failure
157+
cli.run(
158+
project=project,
159+
args=[
160+
"shell",
161+
"--build",
162+
"--use-buildtree",
163+
element_name,
164+
"--",
165+
"sh",
166+
"-c",
167+
"cat config.log .recc-log/* */.recc-log/*",
168+
],
169+
)
170+
assert result.exit_code == 0
171+
172+
result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout1])
173+
assert result.exit_code == 0
174+
175+
assert_contains(
176+
checkout1,
177+
[
178+
"/usr",
179+
"/usr/bin",
180+
"/usr/share",
181+
"/usr/bin/hello",
182+
"/usr/share/doc",
183+
"/usr/share/doc/amhello",
184+
"/usr/share/doc/amhello/README",
185+
],
186+
)
187+
188+
# Check the main build log
189+
result = cli.run(project=project, args=["artifact", "log", element_name])
190+
assert result.exit_code == 0
191+
log = result.output
192+
193+
# Verify we get expected output exactly once
194+
assert log.count("Making all in src") == 1
195+
196+
result = cli.run(
197+
project=project,
198+
args=[
199+
"shell",
200+
"--build",
201+
"--use-buildtree",
202+
element_name,
203+
"--",
204+
"sh",
205+
"-c",
206+
"cat src/.recc-log/recc.buildbox*",
207+
],
208+
)
209+
assert result.exit_code == 0
210+
recc_log = result.output
211+
212+
# Verify recc is using local execution for both, compiling and linking
213+
assert recc_log.count("Action not cached and running in cache-only mode, executing locally") == 2
214+
215+
# Delete artifact from BuildStream cache to trigger a BuildStream rebuild with action cache hits for recc
216+
result = cli.run(project=project, args=["artifact", "delete", element_name])
217+
assert result.exit_code == 0
218+
219+
result = cli.run(project=project, args=["--cache-buildtrees", "always", "build", element_name])
220+
assert result.exit_code == 0
221+
222+
result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout2])
223+
assert result.exit_code == 0
224+
225+
assert_contains(
226+
checkout2,
227+
[
228+
"/usr",
229+
"/usr/bin",
230+
"/usr/share",
231+
"/usr/bin/hello",
232+
"/usr/share/doc",
233+
"/usr/share/doc/amhello",
234+
"/usr/share/doc/amhello/README",
235+
],
236+
)
237+
238+
result = cli.run(
239+
project=project,
240+
args=[
241+
"shell",
242+
"--build",
243+
"--use-buildtree",
244+
element_name,
245+
"--",
246+
"sh",
247+
"-c",
248+
"cat src/.recc-log/recc.buildbox*",
249+
],
250+
)
251+
assert result.exit_code == 0
252+
recc_log = result.output
253+
254+
# Verify recc is getting action cache hits for both, compiling and linking
255+
assert recc_log.count("Action Cache hit") == 2

0 commit comments

Comments
 (0)