#393 Add runtime entry in results.yml: https://pagure.io/standard-test-roles/issue/392
Merged 4 years ago by astepano. Opened 4 years ago by astepano.

@@ -158,6 +158,7 @@ 

      printf '%s\n' '' \

          "- test: $STR_TEST_NAME" \

          "  result: $result"      \

+         "  runtime: $runtime_seconds" \

          "  logs:"  \

          >> "$results"

      for log in "$logfile"; do
@@ -179,6 +180,13 @@ 

      # If killed outside, return code will not be 0, no matter what.

      exit 0

  }

+ 

+ # next vars are used in clean_exit()

+ runtime_start="$(date '+%s')"

+ # runtime == 0 if test is not started or terminated outside

+ runtime_finish="$runtime_start"

+ runtime_seconds=0

+ 

  trap clean_exit SIGINT SIGTERM SIGABRT EXIT

  terminated_outside=1

  rc=0
@@ -197,6 +205,8 @@ 

      chmod 0775 "$STR_CMD"

  fi

  timeout --foreground "$STR_TIMEOUT" bash -c "$STR_CMD" || rc=$?

+ runtime_finish="$(date '+%s')"

+ runtime_seconds=$((runtime_finish - runtime_start))

  # `terminated_outside` epxlanation:

  # This is for a case when STR is driven by STR-pipeline.

  # The STR-pipeline has code: `timeout 4h ansible-playbook`.

@@ -151,6 +151,7 @@ 

      printf '%s\n' '' \

          "- test: $STR_BKR_TEST" \

          "  result: $result"      \

+         "  runtime: $runtime_seconds" \

          "  logs:"  \

          >> "$results"

      for log in "$log_file_path" "$logfile_stdout" "$logfile_stderr"; do
@@ -164,6 +165,13 @@ 

      # If killed outside, return code will not be 0, no matter what.

      exit 0

  }

+ 

+ # next vars are used in clean_exit()

+ runtime_start="$(date '+%s')"

+ # runtime == 0 if test is not started, or terminated outside

+ runtime_finish="$runtime_start"

+ runtime_seconds=0

+ 

  trap clean_exit SIGINT SIGTERM SIGABRT EXIT

  terminated_outside=1

  rc=0
@@ -192,6 +200,8 @@ 

      cd $(dirname "$STR_BKR_TEST")

      timeout --foreground "$STR_TIMEOUT" /bin/sh -e ./$(basename "$STR_BKR_TEST") || rc=$?

      terminated_outside=0

+     runtime_finish="$(date '+%s')"

+     runtime_seconds=$((runtime_finish - runtime_start))

      exit $rc

  fi

  
@@ -210,5 +220,7 @@ 

          echo "FAIL test $STR_BKR_TEST do not know how to run test"

      fi

      terminated_outside=0

+     runtime_finish="$(date '+%s')"

+     runtime_seconds=$((runtime_finish - runtime_start))

      exit $rc

  fi

rebased onto a0df3a0

4 years ago
./roles/standard-test-basic/files/run-basic-test -w wdir1 -a adir1 -t testname -c 'echo hi; sleep 3'               
hi
Run test 'testname': done. Test's exit code: 0
(python3ve) ➜  standard-test-roles git:(runtime) ✗ cat adir1/results.yml 
results:

- test: testname
  result: pass
  runtime_seconds: 3
  logs:
  - PASS-str_testname.log

Could we call it just runtime pls? it is shorter and we do not expect to add runtime_hours or similar

Could we call it just runtime pls? it is shorter and we do not expect to add runtime_hours or similar

@astepano thanks for fixing so quickly, just one comment

rebased onto cecdb3a

4 years ago
➜ ./roles/standard-test-basic/files/run-basic-test -w wdir2 -a adir2 -t testname -c 'echo hi; sleep 3'               

hi
Run test 'testname': done. Test's exit code: 0
➜ cat adir2/results.yml 
results:

- test: testname
  result: pass
  runtime: 3
  logs:
  - PASS-str_testname.log

@astepano ty! looks good. I found out that TMT aleady has the attribute named as duration and uses HH:MM:SS, but w can use seconds here

"duration" is also a good word :) LGTM :wink:

pretty please pagure-ci rebuild

Commit 93b7f7c fixes this pull-request

Pull-Request has been merged by astepano

4 years ago

Pull-Request has been merged by astepano

4 years ago