build improvement: really include apps/workbench_functionals when
[arvados.git] / build / create-plot-data-from-log.sh
1 #!/bin/bash
2
3 build=$1
4 file=$2
5 outputdir=$3
6
7 usage() {
8     echo "./$0 build_number file_to_parse output_dir"
9     echo "this script will use the build output to generate *csv and *txt"
10     echo "for jenkins plugin plot https://github.com/jenkinsci/plot-plugin/"
11 }
12
13 if [ $# -ne 3 ]
14 then
15     usage
16     exit 1
17 fi
18
19 if [ ! -e $file ]
20 then
21     usage
22     echo "$file doesn't exist! exiting"
23     exit 2
24 fi
25 if [ ! -w $outputdir ]
26 then
27     usage
28     echo "$outputdir isn't writeable! exiting"
29     exit 3
30 fi
31
32 #------------------------------
33 ## MAXLINE is the amount of lines that will read after the pattern
34 ## is match (the logfile could be hundred thousands lines long).
35 ## 1000 should be safe enough to capture all the output of the individual test
36 MAXLINES=1000
37
38 ## TODO: check $build and $file make sense
39
40 for test in \
41  test_Create_and_show_large_collection_with_manifest_text_of_20000000 \
42  test_Create,_show,_and_update_description_for_large_collection_with_manifest_text_of_100000 \
43  test_Create_one_large_collection_of_20000000_and_one_small_collection_of_10000_and_combine_them
44 do
45  cleaned_test=$(echo $test | tr -d ",.:;/")
46  (zgrep -i -E -A$MAXLINES "^[A-Za-z0-9]+Test: $test" $file && echo "----") | tail -n +1 | tail --lines=+3|grep -B$MAXLINES -E "^-*$" -m1 > $outputdir/$cleaned_test-$build.txt
47  result=$?
48  if [ $result -eq 0 ]
49  then
50    echo processing  $outputdir/$cleaned_test-$build.txt creating  $outputdir/$cleaned_test.csv
51    echo $(grep ^Completed $outputdir/$cleaned_test-$build.txt | perl -n -e '/^Completed (.*) in [0-9]+ms.*$/;print "".++$line."-$1,";' | perl -p -e 's/,$//g'|tr " " "_" ) >  $outputdir/$cleaned_test.csv
52    echo $(grep ^Completed $outputdir/$cleaned_test-$build.txt | perl -n -e '/^Completed.*in ([0-9]+)ms.*$/;print "$1,";' | perl -p -e 's/,$//g' ) >>  $outputdir/$cleaned_test.csv
53    #echo URL=https://ci.curoverse.com/view/job/arvados-api-server/ws/apps/workbench/log/$cleaned_test-$build.txt/*view*/ >>  $outputdir/$test.properties
54  else
55    echo "$test was't found on $file"
56    cleaned_test=$(echo $test | tr -d ",.:;/")
57    >  $outputdir/$cleaned_test.csv
58  fi
59 done