14325: Build crunch-dispatch-cloud package.
[arvados.git] / build / create-plot-data-from-log.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 build=$1
7 file=$2
8 outputdir=$3
9
10 usage() {
11     echo "./$0 build_number file_to_parse output_dir"
12     echo "this script will use the build output to generate *csv and *txt"
13     echo "for jenkins plugin plot https://github.com/jenkinsci/plot-plugin/"
14 }
15
16 if [ $# -ne 3 ]
17 then
18     usage
19     exit 1
20 fi
21
22 if [ ! -e $file ]
23 then
24     usage
25     echo "$file doesn't exist! exiting"
26     exit 2
27 fi
28 if [ ! -w $outputdir ]
29 then
30     usage
31     echo "$outputdir isn't writeable! exiting"
32     exit 3
33 fi
34
35 #------------------------------
36 ## MAXLINE is the amount of lines that will read after the pattern
37 ## is match (the logfile could be hundred thousands lines long).
38 ## 1000 should be safe enough to capture all the output of the individual test
39 MAXLINES=1000
40
41 ## TODO: check $build and $file make sense
42
43 for test in \
44  test_Create_and_show_large_collection_with_manifest_text_of_20000000 \
45  test_Create,_show,_and_update_description_for_large_collection_with_manifest_text_of_100000 \
46  test_Create_one_large_collection_of_20000000_and_one_small_collection_of_10000_and_combine_them
47 do
48  cleaned_test=$(echo $test | tr -d ",.:;/")
49  (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
50  result=$?
51  if [ $result -eq 0 ]
52  then
53    echo processing  $outputdir/$cleaned_test-$build.txt creating  $outputdir/$cleaned_test.csv
54    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
55    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
56    #echo URL=https://ci.curoverse.com/view/job/arvados-api-server/ws/apps/workbench/log/$cleaned_test-$build.txt/*view*/ >>  $outputdir/$test.properties
57  else
58    echo "$test was't found on $file"
59    cleaned_test=$(echo $test | tr -d ",.:;/")
60    >  $outputdir/$cleaned_test.csv
61  fi
62 done