Skip to content

Commit 23ab358

Browse files
committed
test: fix: stop doing PR A/B-tests across host commands
The output of the spectre/meltdown checker, and the vulnerability files on the host will not be influenced by the local checkout of the firecracker repository. Thus these A/B-tests were noops. Fix this by only doing the non-PR assertion in the nightly pipeline. Signed-off-by: Patrick Roy <[email protected]>
1 parent 35c8693 commit 23ab358

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

tests/integration_tests/security/test_vulnerabilities.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import pytest
1212
import requests
1313

14+
from framework import utils
1415
from framework.ab_test import (
1516
git_ab_test_guest_command,
1617
git_ab_test_guest_command_if_pr,
17-
git_ab_test_host_command_if_pr,
1818
is_pr,
1919
set_did_not_grow_comparator,
2020
)
@@ -212,20 +212,17 @@ def check_vulnerabilities_on_guest(status):
212212
assert report_guest_vulnerabilities == known_guest_vulnerabilities
213213

214214

215+
# Nothing can be sensibly tested in a PR context here
216+
@pytest.mark.skipif(
217+
is_pr(), reason="Test depends solely on factors external to GitHub repository"
218+
)
215219
def test_spectre_meltdown_checker_on_host(spectre_meltdown_checker):
216220
"""
217221
Test with the spectre / meltdown checker on host.
218222
"""
219-
output = git_ab_test_host_command_if_pr(
220-
f"sh {spectre_meltdown_checker} --batch json",
221-
comparator=set_did_not_grow_comparator(
222-
spectre_meltdown_reported_vulnerablities
223-
),
224-
check_in_nonpr=False,
225-
)
223+
rc, output, _ = utils.run_cmd(f"sh {spectre_meltdown_checker} --batch json")
226224

227-
# Outside the PR context, checks the return code with some exceptions.
228-
if output and output.returncode != 0:
225+
if output and rc != 0:
229226
report = spectre_meltdown_reported_vulnerablities(output)
230227
expected = {}
231228
assert report == expected, f"Unexpected vulnerabilities: {report} vs {expected}"
@@ -383,17 +380,15 @@ def get_vuln_files_exception_dict(template):
383380
return exception_dict
384381

385382

383+
# Nothing can be sensibly tested here in a PR context
384+
@pytest.mark.skipif(
385+
is_pr(), reason="Test depends solely on factors external to GitHub repository"
386+
)
386387
def test_vulnerabilities_on_host():
387388
"""
388389
Test vulnerabilities files on host.
389390
"""
390-
391-
git_ab_test_host_command_if_pr(
392-
f"! grep -r Vulnerable {VULN_DIR}",
393-
comparator=set_did_not_grow_comparator(
394-
lambda output: set(output.stdout.splitlines())
395-
),
396-
)
391+
utils.check_output(f"! grep -r Vulnerable {VULN_DIR}")
397392

398393

399394
def check_vulnerabilities_files_on_guest(microvm):

0 commit comments

Comments
 (0)