add new topology parameter: arch
[csit.git] / resources / tools / report_gen / run_report.sh
index 3ce64b7..ec779ad 100755 (executable)
@@ -2,26 +2,51 @@
 
 set -x
 
-# Build locally without jenkins integrations
-DEBUG=0
-
 # Script directory
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
+# Get actual date
+DATE=$(date -u '+%d-%b-%Y')
+
 # Load configuration
 source ${SCRIPT_DIR}/run_report.cfg
 
+# Process parameters
+for i in "$@"; do
+case $i in
+    --debug)
+        CFG[DEBUG]=1
+    ;;
+    --no_latex)
+        CFG[BLD_LATEX]=0
+    ;;
+    --no_html)
+        CFG[BLD_HTML]=0
+    ;;
+    *)
+        # unknown option
+    ;;
+esac
+done
+
 # Install system dependencies
 sudo apt-get -y update
 sudo apt-get -y install libxml2 libxml2-dev libxslt-dev build-essential \
     zlib1g-dev unzip
+if [[ ${CFG[BLD_LATEX]} -eq 1 ]] ;
+then
+    sudo apt-get -y install xvfb texlive-latex-recommended \
+        texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra latexmk wkhtmltopdf
+    sudo sed -i.bak 's/^\(main_memory\s=\s\).*/\110000000/' /usr/share/texlive/texmf-dist/web2c/texmf.cnf
+fi
 
 # Clean-up when finished
 trap 'rm -rf ${DIR[WORKING]}; exit' EXIT
 trap 'rm -rf ${DIR[WORKING]}; exit' ERR
 
 # Remove the old build
-rm -rf ${DIR[BUILD]} || true
+rm -rf ${DIR[BUILD,HTML]} || true
+rm -rf ${DIR[BUILD,LATEX]} || true
 rm -rf ${DIR[WORKING]} || true
 
 # Create working directories
@@ -47,7 +72,7 @@ mkdir -p ${DIR[PLOT,DPDK]}
 
 ### VPP PERFORMANCE SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[PERF,VPP]}-${JOB[PERF,VPP,FBLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[PERF,VPP]}-${JOB[PERF,VPP,FBLD]}.zip
 #fi
 
@@ -55,14 +80,17 @@ blds=${JOB[PERF,VPP,BLD]}
 for i in ${blds[@]}; do
     curl --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,VPP]}/${i}/robot/report/output_perf_data.xml \
         --output ${DIR[PLOT,VPP]}/${JOB[PERF,VPP]}-${i}.xml
-    #curl --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,VPP]}/${i}/robot/report/output_perf_data.json \
-    #    --output ${DIR[PLOT,VPP]}/${JOB[PERF,VPP]}-${i}.json
-    if [[ ${DEBUG} -eq 0 ]] ;
+    if [[ ${CFG[DEBUG]} -eq 0 ]] ;
     then
         curl --fail --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,VPP]}/${i}/robot/report/\*zip\*/robot-plugin.zip \
             --output ${DIR[STATIC,ARCH]}/${JOB[PERF,VPP]}-${i}.zip
     fi
 done
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
+then
+    curl --fail --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,VPP]}/${JOB[PERF,VPP,FBLD]}/robot/report/\*zip\*/robot-plugin.zip \
+        --output ${DIR[STATIC,ARCH]}/${JOB[PERF,VPP]}-${JOB[PERF,VPP,FBLD]}.zip
+fi
 # Archive trending
 cp ${DIR[PLOT,VPP]}/* ${DIR[STATIC,TREND]}
 blds=${JOB[1704,VPP,BLD]}
@@ -73,7 +101,7 @@ done
 
 ### DPDK PERFORMANCE SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[PERF,DPDK]}-${JOB[PERF,DPDK,FBLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[PERF,DPDK]}-${JOB[PERF,DPDK,FBLD]}.zip
 #fi
 
@@ -81,9 +109,7 @@ blds=${JOB[PERF,DPDK,BLD]}
 for i in ${blds[@]}; do
     curl --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,DPDK]}/${i}/robot/report/output_perf_data.xml \
         --output ${DIR[PLOT,DPDK]}/${JOB[PERF,DPDK]}-${i}.xml
-    #curl --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,DPDK]}/${i}/robot/report/output_perf_data.json \
-    #    --output ${DIR[PLOT,DPDK]}/${JOB[PERF,DPDK]}-${i}.json
-    if [[ ${DEBUG} -eq 0 ]] ;
+    if [[ ${CFG[DEBUG]} -eq 0 ]] ;
     then
         curl --fail --silent ${URL[JENKINS,CSIT]}/${JOB[PERF,DPDK]}/${i}/robot/report/\*zip\*/robot-plugin.zip \
             --output ${DIR[STATIC,ARCH]}/${JOB[PERF,DPDK]}-${i}.zip
@@ -93,11 +119,11 @@ cp ${DIR[PLOT,DPDK]}/* ${DIR[STATIC,TREND]}
 
 ### FUNCTIONAL SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[FUNC,VPP]}-${JOB[FUNC,VPP,BLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[FUNC,VPP]}-${JOB[FUNC,VPP,BLD]}.zip
 #fi
 
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     curl --fail --silent ${URL[JENKINS,CSIT]}/${JOB[FUNC,VPP]}/${JOB[FUNC,VPP,BLD]}/robot/report/\*zip\*/robot-plugin.zip \
         --output ${DIR[STATIC,ARCH]}/${JOB[FUNC,VPP]}-${JOB[FUNC,VPP,BLD]}.zip
@@ -105,11 +131,11 @@ fi
 
 ### HONEYCOMB FUNCTIONAL SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[FUNC,HC]}-${JOB[FUNC,HC,BLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[FUNC,HC]}-${JOB[FUNC,HC,BLD]}.zip
 #fi
 
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     curl --fail --silent ${URL[JENKINS,HC]}/${JOB[FUNC,HC]}/${JOB[FUNC,HC,BLD]}/robot/report/\*zip\*/robot-plugin.zip \
         --output ${DIR[STATIC,ARCH]}/${JOB[FUNC,HC]}-${JOB[FUNC,HC,BLD]}.zip
@@ -117,26 +143,26 @@ fi
 
 ### HONEYCOMB PERFORMANCE SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[PERF,HC]}-${JOB[PERF,HC,BLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[PERF,HC]}-${JOB[PERF,HC,BLD]}.zip
 #fi
 
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     blds=${JOB[PERF,HC,BLD]}
     for i in ${blds[@]}; do
-        curl --silent ${URL[JENKINS,HC]}/${JOB[PERF,HC]}/${JOB[PERF,HC,BLD]}/robot/report/\*zip\*/robot-plugin.zip \
-            --output ${DIR[STATIC,ARCH]}/${JOB[PERF,HC]}-${JOB[PERF,HC,BLD]}.zip
+        curl --silent ${URL[JENKINS,HC]}/${JOB[PERF,HC]}/${i}/robot/report/\*zip\*/robot-plugin.zip \
+            --output ${DIR[STATIC,ARCH]}/${JOB[PERF,HC]}-${i}.zip
 done
 fi
 
 ### NSH_SFC SOURCE DATA
 
-#if [[ ${DEBUG} -eq 1 ]] ;
+#if [[ ${CFG[DEBUG]} -eq 1 ]] ;
 #    cp ./${JOB[FUNC,NSH]}-${JOB[FUNC,NSH,BLD]}.zip ${DIR[STATIC,ARCH]}/${JOB[FUNC,NSH]}-${JOB[FUNC,NSH,BLD]}.zip
 #fi
 
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     curl --fail --silent ${URL[JENKINS,CSIT]}/${JOB[FUNC,NSH]}/${JOB[FUNC,NSH,BLD]}/robot/report/\*zip\*/robot-plugin.zip \
         --output ${DIR[STATIC,ARCH]}/${JOB[FUNC,NSH]}-${JOB[FUNC,NSH,BLD]}.zip
@@ -144,7 +170,7 @@ fi
 
 # Data post processing
 
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     # VPP PERF
     unzip -o ${DIR[STATIC,ARCH]}/${JOB[PERF,VPP]}-${JOB[PERF,VPP,FBLD]}.zip -d ${DIR[WORKING]}/
@@ -196,7 +222,7 @@ then
 fi
 
 # Generate tables for performance improvements
-if [[ ${DEBUG} -eq 0 ]] ;
+if [[ ${CFG[DEBUG]} -eq 0 ]] ;
 then
     python run_improvments_tables.py \
         --input ${DIR[DTR,PERF,VPP,IMPRV]} \
@@ -206,29 +232,6 @@ fi
 # Delete temporary json files
 find ${DIR[RST]} -name "*.json" -type f -delete
 
-# Generate the documentation
-DATE=$(date -u '+%d-%b-%Y')
-sphinx-build -v -c . -a -b html -E \
-    -D release=$1 -D version="$1 report - $DATE" \
-    ${DIR[RST]} ${DIR[BUILD]}/
-
-# Patch the CSS for tables layout
-cat - > ${DIR[CSS_PATCH_FILE]} <<"_EOF"
-/* override table width restrictions */
-@media screen and (min-width: 767px) {
-    .wy-table-responsive table td, .wy-table-responsive table th {
-        white-space: normal !important;
-    }
-
-    .wy-table-responsive {
-        font-size: small;
-        margin-bottom: 24px;
-        max-width: 100%;
-        overflow: visible !important;
-    }
-}
-_EOF
-
 # Plot packets per second
 
 # VPP L2 sel1
@@ -237,6 +240,7 @@ python run_plot.py --input ${DIR[PLOT,VPP]} \
     --output ${DIR[STATIC,VPP]}/64B-1t1c-l2-sel1-ndrdisc \
     --title "64B-1t1c-(eth|dot1q|dot1ad)-(l2xcbase|l2bdbasemaclrn)-ndrdisc" \
     --xpath '//*[@framesize="64B" and contains(@tags,"BASE") and contains(@tags,"NDRDISC") and contains(@tags,"1T1C") and (contains(@tags,"L2BDMACSTAT") or contains(@tags,"L2BDMACLRN") or contains(@tags,"L2XCFWD")) and not(contains(@tags,"VHOST"))]'
+
 python run_plot.py --input ${DIR[PLOT,VPP]} \
     --output ${DIR[STATIC,VPP]}/64B-2t2c-l2-sel1-ndrdisc \
     --title "64B-2t2c-(eth|dot1q|dot1ad)-(l2xcbase|l2bdbasemaclrn)-ndrdisc" \
@@ -571,6 +575,53 @@ python run_plot.py --input ${DIR[PLOT,DPDK]} \
     --title "64B-2t2c-ethip4-ip4base-l3fwd-ndrdisc" \
     --xpath '//*[@framesize="64B" and contains(@tags,"BASE") and contains(@tags,"NDRDISC") and contains(@tags,"2T2C") and contains(@tags,"IP4FWD")]' --latency lat_50
 
+# HTML BUILDER
+if [[ ${CFG[BLD_HTML]} -eq 1 ]] ;
+then
+    sphinx-build -v -c . -a -b html -E \
+        -D release=$1 -D version="$1 report - $DATE" \
+        ${DIR[RST]} ${DIR[BUILD,HTML]}/
+
+    # Patch the CSS for tables layout
+    cat - > ${DIR[CSS_PATCH_FILE]} <<"_EOF"
+/* override table width restrictions */
+@media screen and (min-width: 767px) {
+    .wy-table-responsive table td, .wy-table-responsive table th {
+        white-space: normal !important;
+    }
+
+    .wy-table-responsive {
+        font-size: small;
+        margin-bottom: 24px;
+        max-width: 100%;
+        overflow: visible !important;
+    }
+}
+_EOF
+fi
+
+# LATEX BUILDER
+if [[ ${CFG[BLD_LATEX]} -eq 1 ]] ;
+then
+    # Convert PyPLOT graphs in HTML format to PDF.
+    for f in ${DIR[STATIC,VPP]}/*; do
+        xvfb-run -a wkhtmltopdf ${f} ${f%.html}.pdf
+    done
+    for f in ${DIR[STATIC,DPDK]}/*; do
+        xvfb-run -a wkhtmltopdf ${f} ${f%.html}.pdf
+    done
+
+    # Generate the LaTeX documentation
+    sphinx-build -v -c . -a -b latex -E \
+        -D release=$1 -D version="$1 report - $DATE" \
+        ${DIR[RST]} ${DIR[BUILD,LATEX]}
+    cd ${DIR[BUILD,LATEX]}
+    pdflatex -shell-escape -interaction nonstopmode csit.tex || true
+    pdflatex -interaction nonstopmode csit.tex || true
+    cp csit.pdf ../${DIR[STATIC,ARCH]}/csit_$1.pdf
+    cd ${SCRIPT_DIR}
+fi
+
 # Create archive
 echo Creating csit.report.tar.gz ...
-tar -czvf ./csit.report.tar.gz ${DIR[BUILD]}
+tar -czvf ./csit.report.tar.gz ${DIR[BUILD,HTML]}