Browse code

Add subunit output for total elapsed time

This commit adds a success output for the entire devstack run to the
subunit output. Ideally we wouldn't need this, but because we don't
have timing data for every single operation performed by devstack we
need to do this to track the total duration of the devstack run.

To capture failures this commit adds saving a devstack event when we
trip the exit_trap. This will save a similar result to the stream in
the successful case, but instead mark it as a failure.

This is backported from master branch to generate subunit result so
d-g can collect it from the new location.

Depends-On: Icc7df33e4d73ba6322af38fbdf3aea230f2fcf4d
Depends-On: I97a604ac08797909afc236401281a5d84b98d53f
Change-Id: I07112dde996c3e2c73f5aafc9b73d33d26374633

Matthew Treinish authored on 2015/10/13 22:51:17
Showing 2 changed files
... ...
@@ -42,6 +42,8 @@ if [[ -n "$NOUNSET" ]]; then
42 42
     set -o nounset
43 43
 fi
44 44
 
45
+# Set start of devstack timestamp
46
+DEVSTACK_START_TIME=$(date +%s)
45 47
 
46 48
 # Configuration
47 49
 # =============
... ...
@@ -457,11 +459,14 @@ function exit_trap {
457 457
 
458 458
     if [[ $r -ne 0 ]]; then
459 459
         echo "Error on exit"
460
+        generate-subunit $DEVSTACK_START_TIME $SECONDS 'fail' >> ${SUBUNIT_OUTPUT}
460 461
         if [[ -z $LOGDIR ]]; then
461 462
             $TOP_DIR/tools/worlddump.py
462 463
         else
463 464
             $TOP_DIR/tools/worlddump.py -d $LOGDIR
464 465
         fi
466
+    else
467
+        generate-subunit $DEVSTACK_START_TIME $SECONDS >> ${SUBUNIT_OUTPUT}
465 468
     fi
466 469
 
467 470
     exit $r
... ...
@@ -682,6 +687,9 @@ if [[ "$OFFLINE" != "True" ]]; then
682 682
     PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
683 683
 fi
684 684
 
685
+# Install subunit for the subunit output stream
686
+pip_install -U os-testr
687
+
685 688
 TRACK_DEPENDS=${TRACK_DEPENDS:-False}
686 689
 
687 690
 # Install Python packages into a virtualenv so that we can track them
... ...
@@ -29,6 +29,9 @@ DATA_DIR=${DEST}/data
29 29
 # Destination for status files
30 30
 SERVICE_DIR=${DEST}/status
31 31
 
32
+# Path for subunit output file
33
+SUBUNIT_OUTPUT=${DEST}/devstack.subunit
34
+
32 35
 # Determine stack user
33 36
 if [[ $EUID -eq 0 ]]; then
34 37
     STACK_USER=stack