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 committed Sep 24, 2024
1 parent 7e10e3b commit 1acdd79
Show file tree
Hide file tree
Showing 2 changed files with 23 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:--}"
}
7 changes: 7 additions & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,17 @@ yaml_in_defaults="CPU=1 MEM=100M ISO=true CPUREQ=1 CPULIM=2 MEMREQ=100M MEMLIM=2
declare -A kind_count # associative arrays for counting created objects, like kind_count[pod]=1
eval "${yaml_in_defaults}"

test_start_secs=$(vm-seconds-now)

# Run test/demo
TEST_FAILURES=""
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 1acdd79

Please sign in to comment.