Skip to content

Commit

Permalink
e2e: pull and save runtime logs after each test.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub authored and askervin committed Oct 1, 2024
1 parent 6604211 commit 5d4ed7c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/e2e/lib/vm.bash
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,19 @@ vm-stop-log-collection() {
local log_file="${log_file:-nri-resource-policy.output.txt}"
vm-command "fuser --kill $log_file 2>/dev/null || :"
}

vm-seconds-now() {
vm-command-q "date +%s"
}

vm-seconds-since() {
echo $(( $(vm-seconds-now) - $1 + 1 ))
}

vm-pull-journal() {
local _service="${service:+-u} ${service:-} "
local _since="${since:+--since }${since:-}"

vm-command-q "journalctl $_service $_since" || \
command-error "failed to pull journal logs (service: ${service:-all}, since: ${since:--}"
}
6 changes: 6 additions & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,14 @@ eval "${yaml_in_defaults}"

# Run test/demo
TEST_FAILURES=""
test_start_secs=$(vm-seconds-now)

test-user-code

test_span_secs="$(vm-seconds-since $test_start_secs)"
since="-$(( test_span_secs + 5 ))s"
service="${k8scri}" since="$since" vm-pull-journal > "${TEST_OUTPUT_DIR}"/runtime."${k8scri}".log

# If there are any nri-resource-policy logs in the DUT, copy them back to host.
host-command "$SCP $VM_HOSTNAME:nri-resource-policy.output.txt \"${TEST_OUTPUT_DIR}/\"" ||
out "copying \"$nri-resource-policy.output.txt\" from VM failed"
Expand Down

0 comments on commit 5d4ed7c

Please sign in to comment.