Skip to content

Commit

Permalink
use system-probe.print-failed-tests instead of duplicated security …
Browse files Browse the repository at this point in the history
…agent version
  • Loading branch information
paulcacheux committed Nov 23, 2023
1 parent eaf2374 commit 344adbb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion .gitlab/functional_test/security_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- echo "CI_JOB_STAGE=${CI_JOB_STAGE}" >> $DD_AGENT_TESTING_DIR/site-cookbooks/dd-security-agent-check/files/job_env.txt
- tasks/run-test-kitchen.sh security-agent-test $AGENT_MAJOR_VERSION
- popd
- inv security-agent.print-failed-tests --output-dir $DD_AGENT_TESTING_DIR/testjson
- inv system-probe.print-failed-tests --output-dir $DD_AGENT_TESTING_DIR/testjson
artifacts:
expire_in: 2 weeks
when: always
Expand Down
36 changes: 0 additions & 36 deletions tasks/security_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,42 +822,6 @@ def run_ebpf_unit_tests(ctx, verbose=False, trace=False):
ctx.run(f"go test {flags} ./pkg/security/ebpf/tests/... {args}")


# TODO: this task does the same thing as system-probe.print-failed-tests.
# They could be refactored to have the logic in only one place.
@task
def print_failed_tests(_, output_dir):
"""
print_failed_tests is run at the end of the platform functional test Gitlab job to print failed tests
"""
fail_count = 0
for testjson_tgz in glob.glob(f"{output_dir}/**/testjson.tar.gz"):
test_platform = os.path.basename(os.path.dirname(testjson_tgz))

if os.path.isdir(testjson_tgz):
# handle weird kitchen bug where it places the tarball in a subdirectory of the same name
testjson_tgz = os.path.join(testjson_tgz, "testjson.tar.gz")

with tempfile.TemporaryDirectory() as unpack_dir:
with tarfile.open(testjson_tgz) as tgz:
tgz.extractall(path=unpack_dir)

for test_json in glob.glob(f"{unpack_dir}/*.json"):
bundle, _ = os.path.splitext(os.path.basename(test_json))
with open(test_json) as tf:
for line in tf:
json_test = json.loads(line.strip())
if 'Test' in json_test:
name = json_test['Test']
action = json_test["Action"]

if action == "fail":
print(f"FAIL: [{test_platform}] [{bundle}] {name}")
fail_count += 1

if fail_count > 0:
raise Exit(code=1)


@task
def print_fentry_stats(ctx):
fentry_o_path = "pkg/ebpf/bytecode/build/runtime-security-fentry.o"
Expand Down

0 comments on commit 344adbb

Please sign in to comment.