Plot more performance test graphs on the CPS performance report 97/20897/6
authorhalil.cakal <halil.cakal@est.tech>
Thu, 18 Apr 2024 15:17:10 +0000 (16:17 +0100)
committerhalil.cakal <halil.cakal@est.tech>
Mon, 22 Apr 2024 13:01:12 +0000 (14:01 +0100)
- change the algorithm to reflect the build range on the
  graphs rather than the last build
- add new perf. tests (around thirty) having lowest normalized
  stdv to plot
- add new ncmp perf test to plot
- fix the issue effects replace and delete graphs
- wipe workspace set to true for plot job

Issue-ID: CPS-2162

Change-Id: I857048e15db520aeff393a431220067e1dfc9fe4
Signed-off-by: halil.cakal <halil.cakal@est.tech>
jjb/onap/cps/prepare-performance-tests-data.sh [changed mode: 0644->0755]
jjb/onap/global-templates-onap-java.yaml

old mode 100644 (file)
new mode 100755 (executable)
index 9705858..4773944
@@ -24,40 +24,45 @@ set -o pipefail # Use last non-zero exit code in a pipeline
 ################################################ F U N C T I O N S ##########################################################
 #############################################################################################################################
 
-create_data="create_performance_data.txt"
-read_data="read_performance_data.txt"
-update_data="update_performance_data.txt"
-delete_data="delete_performance_data.txt"
-
-# Data files headers
-create_data_title_1="Writing 400 devices"
-read_data_title_1="Read datatrees using openroadm root"
-update_data_title_1="Replace 100 with new leaf values"
-delete_data_title_1="Batch delete 100 containers"
-
-# Text patterns to match in console log
-create_pattern="^.*Writing 400 devices.*"
-read_pattern="^.*Read datatrees using openroadm root.*"
-update_pattern="^.*Replace 100 with new leaf values.*"
-delete_pattern="^.*Batch delete 100 containers.*"
+cps_test_names=("Delete data nodes for anchor" "Delete one large node" "Batch delete 100 lists elements" "Batch delete 100 containers" "Query across anchors top element" "Delete root node" "Query across anchors ancestors" "Query across anchors leaf condition + an" "Read datatrees using openroadm root" "Read datatrees using openroadm top eleme" "Query 1 anchor leaf condition + ancestor" "Query 1 anchor top element" "Creating 33,000 books" "Replace list of 0 with 100" "Query ancestors with all descendants" "Replace 0 nodes with 100" "Writing 6400 books" "Read datatrees with all descendants" "Query 1 anchor ancestors" "Writing 400 devices" "Writing 3200 books" "Saving list of 100 devices" "Saving list of 50 devices" "Saving list of 400 devices" "Query with all descendants" "Writing 100 devices" "Writing 50 devices" "Writing 200 devices" "Read datatrees for multiple xpaths" "Saving list of 200 devices")
+
+ncmp_test_name_names=("Look up CM-handles by module-set-tag")
 
 JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
 
-# Get latest build
-getLatestBuildId() {
-  curl -s "${JENKINS_JOB_URL}/lastBuild/buildNumber"
+latestBuildToRecord=""
+consoleText=""
+latestRecordedBuild=""
+timestampOfLatestRecordedBuild=""
+
+# Get latest-completed build number from the jenkins job
+# The number has not been plotted on the graphs yet
+getLastCompletedBuildNumber() {
+  curl -s "${JENKINS_JOB_URL}/lastCompletedBuild/buildNumber"
+}
+
+# Get the last build number from local workspace
+# The number has already been plotted on the graphs
+getLastRecordedBuildNumber() {
+  cd "$WORKSPACE"
+  local file_name="Delete root node.txt"
+
+  # Check if the file exists
+  if [ -f "$file_name" ]; then
+    # Get the last line from the file
+    local last_line=$(tail -n 1 "$file_name")
+    local left_side=$(echo "$last_line" | cut -d ',' -f 1)
+    echo "$left_side"
+  else
+    echo "File '$file_name' not found in the current directory"
+  fi
 }
 
 # Get all builds numbers
-getAllBuildIds() {
+getAllBuildNumbers() {
   curl -s "${JENKINS_JOB_URL}/api/json?tree=allBuilds\[id\]" | jq -r '.allBuilds[].id' | sort -n
 }
 
-latestBuildToRecord=""
-consoleText=""
-latestRecordedBuild=""
-timestampOfLatestRecordedBuild=""
-
 # Get the console text from specific build of the performance job
 getConsoleText() {
   buildToRead=$1
@@ -65,6 +70,20 @@ getConsoleText() {
   consoleText=$(curl -s "$consoleURL")
 }
 
+# Get and record the percentage (performance job result) for each test name for a build number
+getAndRecordPerformanceJobResultForBuild() {
+  buildNumber="$1"
+  getConsoleText "$buildNumber"
+  # Loop through each text name
+  for cps_test_name in "${cps_test_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$cps_test_name" "$cps_test_name.txt" "$buildNumber"
+  done
+  for ncmp_test_name in "${ncmp_test_name_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$ncmp_test_name" "$ncmp_test_name.txt" "$buildNumber"
+  done
+}
+
+# Calculate the percentage value for a specific test and append into test data file with build number
 getAndRecordDataResults() {
   consoleText=$1
   patternToMatch=$2
@@ -75,32 +94,33 @@ getAndRecordDataResults() {
   limit_value=""
   took_value=""
 
-  # Get and calculate data for plot
-  if matched_line=$(echo "$consoleText" | grep -o -P "$patternToMatch"); then
+  # Get and calculate percentage for the graph
+  if matched_line=$(echo "$consoleText" | grep "$patternToMatch"); then
     limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(\.\d+)?' | tr -cd '[:digit:].')
     took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(\.\d+)?' | tr -cd '[:digit:].')
     percentage=$(echo "scale=2; $took_value * 100.00 / $limit_value" | bc)
     new_data="$percentage"
   fi
 
-  # Record result
+  # Record result into related test data file
   touch "$dataFile"
   lastLine=$(tail -n 1 "$dataFile")
   newLine="$buildNumber,$new_data"
   if [ -z "$new_data" ]; then
-    # No data found for this build
+    # No data found for this build probably the build failed
     echo "$buildNumber,0" >>"$dataFile"
     recordLatestRecordedBuild "$buildNumber"
   elif [ "$newLine" == "$lastLine" ]; then
     # Data already exists
     recordLatestRecordedBuild "$buildNumber"
   else
-    # New data added
+    # New data added into the file
     echo "$buildNumber,$new_data" >>"$dataFile"
     recordLatestRecordedBuild "$buildNumber"
   fi
 }
 
+# Save the latest recorded build number with date and time
 recordLatestRecordedBuild() {
   latestBuildToRecord="$1"
   timestampOfLatestRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${latestBuildToRecord}/api/json?tree=timestamp" | jq -r '.timestamp')
@@ -108,6 +128,7 @@ recordLatestRecordedBuild() {
   latestRecordedBuild=$latestBuildToRecord
 }
 
+# Plot the image (graph) in png format
 buildPlotImage() {
   dataFile="$1" # Get the input file name from the function parameter
   chartFileName="$2"
@@ -125,70 +146,65 @@ plot '$dataFile' using (column(0)):2:xtic(sprintf("%d", column(1))) with linespo
      100 with lines linestyle 2 title "100% limit"
 EOT
 
-  # Run the Gnuplot script
+  # Run the temporary Gnuplot script
   gnuplot gnuplot_script.gp
 
-  # Remove the temporary script
+  # Remove the temporary Gnuplot script
   rm gnuplot_script.gp
 }
 
-buildHTMLReport() {
-
-  chartTitle1="$1" # i.e Get the chart file name as the first parameter
-  chartFileName1="$2"
-
-  chartTitle2="$3"
-  chartFileName2="$4"
-
-  chartTitle3="$5"
-  chartFileName3="$6"
-
-  chartTitle4="$7"
-  chartFileName4="$8"
-
-  reportTitle="$9" # i.e Get the report title as the ninth parameter
-
-  cat <<EOT >"index.html"
+# Builds index.html file (main page)
+buildMainPageHtmlReport() {
+cat <<EOT >"index.html"
 <!DOCTYPE html>
 <html>
 <head>
-  <title>$reportTitle</title>
+  <title>Performance Review</title>
 </head>
 <body>
-    <h1 style="text-align: center;">$reportTitle</h1>
+    <h1 style="text-align: center;">Performance Review</h1>
     <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
-    <p>The performance tests job runs daily at 02:15 UTC, providing performance metrics. The following graphs update at 04:15 UTC.</p>
+    <p>The performance tests job runs every two hours, providing performance metrics. The following graphs update at 04:15 UTC.</p>
     <p>Successful performance tests job build adds new data, but even if a build fails, existing data is retained.</p>
     <p>Updates occur whenever new successful data is available.</p>
 
     <table align="center">
-        <tr> <!-- First Row -->
-            <td align="center">
-                <figcaption>"$chartTitle1"</figcaption>
-                <img src="$chartFileName1" alt="Image 1" width="750" height="300">
-            </td>
+EOT
+
+# Loop through the test names and chart file names to generate HTML rows for CPS
+for cps_test_name in "${cps_test_names[@]}"; do
+    cat <<EOF >>index.html
+        <tr> <!-- Row for $cps_test_name -->
             <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle2"</figcaption>
-                <img src="$chartFileName2" alt="Image 2" width="750" height="300">
+                <figcaption>"$cps_test_name (CPS)"</figcaption>
+                <img src="$cps_test_name.png" width="750" height="300">
             </td>
         </tr>
-        <tr> <!-- Second Row -->
-            <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle3"</figcaption>
-                <img src="$chartFileName3" alt="Image 3" width="750" height="300">
-            </td>
+EOF
+done
+
+# Loop through the test names and chart file names to generate HTML rows for NCMP
+for ncmp_test_name in "${ncmp_test_name_names[@]}"; do
+    cat <<EOF >>index.html
+        <tr> <!-- Row for $ncmp_test_name -->
             <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle4"</figcaption>
-                <img src="$chartFileName4" alt="Image 4" width="750" height="300">
+                <figcaption>"$ncmp_test_name (NCMP)"</figcaption>
+                <img src="$ncmp_test_name.png" width="750" height="300">
             </td>
         </tr>
+EOF
+done
+
+# Close the HTML file
+cat <<EOT >>index.html
     </table>
 </body>
 </html>
 EOT
 }
 
-buildPageReport() {
+# Builds sub-HTML pages
+buildSubPageHtmlReport() {
   chartFileName="$1"
   reportTitle="$2"
   outputFile="$3"
@@ -207,18 +223,8 @@ buildPageReport() {
 EOT
 }
 
-getAndRecordAllDataResults() {
-  buildNumber="$1"
-  getConsoleText "$buildNumber"
-  getAndRecordDataResults "$consoleText" "$create_pattern" "$create_data" "$buildNumber"
-  getAndRecordDataResults "$consoleText" "$read_pattern" "$read_data" "$buildNumber"
-  getAndRecordDataResults "$consoleText" "$update_pattern" "$update_data" "$buildNumber"
-  getAndRecordDataResults "$consoleText" "$delete_pattern" "$delete_data" "$buildNumber"
-}
-
-#############################################################################################################################
-#############################################################################################################################
 #############################################################################################################################
+################################################ M A I N ####################################################################
 #############################################################################################################################
 
 # Install dependencies
@@ -228,35 +234,38 @@ sudo apt-get install -y bc gnuplot jq
 cd "$WORKSPACE"
 if [ -z "$(ls -A)" ]; then
   # If workspace is empty, pull data from all previous performance job runs
-  for buildNumber in $(getAllBuildIds); do
-    getAndRecordAllDataResults "$buildNumber"
+  for buildNumber in $(getAllBuildNumbers); do
+    getAndRecordPerformanceJobResultForBuild "$buildNumber"
   done
 else
-  # Append data from latest job run only
-  buildNumber=$(getLatestBuildId)
-  getAndRecordAllDataResults "$buildNumber"
+  # Append new data from latest jobs run
+  lastCompletedBuildNumber=$(getLastCompletedBuildNumber)
+  lastRecordedBuildNumber=$(getLastRecordedBuildNumber)
+  # Check if last completed build number is greater than last recorded build number
+  if [ "$lastCompletedBuildNumber" -gt "$lastRecordedBuildNumber" ]; then
+    for ((i = lastRecordedBuildNumber + 1; i <= lastCompletedBuildNumber; i++)); do
+      getAndRecordPerformanceJobResultForBuild "$i"
+    done
+  else
+    echo "No new builds to process."
+  fi
 fi
 
-# Trim to last 30 entries
-tail -n 30 "$create_data" > file.tmp && mv file.tmp "$create_data"
-tail -n 30 "$read_data" > file.tmp && mv file.tmp "$read_data"
-tail -n 30 "$update_data" > file.tmp && mv file.tmp "$update_data"
-tail -n 30 "$delete_data" > file.tmp && mv file.tmp "$delete_data"
-
-# Generate plot image files
-buildPlotImage "$create_data" "createLargeData.png"
-buildPlotImage "$read_data" "readDataTrees.png"
-buildPlotImage "$update_data" "updateDatanodes.png"
-buildPlotImage "$delete_data" "batchDelete.png"
-
-buildHTMLReport \
-  "$create_data_title_1" "createLargeData.png" \
-  "$read_data_title_1" "readDataTrees.png" \
-  "$update_data_title_1" "updateDatanodes.png" \
-  "$delete_data_title_1" "batchDelete.png" \
-  "Performance Review"
-
-buildPageReport "createLargeData.png" "$create_data_title_1" "createOperation.html"
-buildPageReport "readDataTrees.png" "$read_data_title_1" "readOperation.html"
-buildPageReport "updateDatanodes.png" "$update_data_title_1" "updateOperation.html"
-buildPageReport "batchDelete.png" "$delete_data_title_1" "deleteOperation.html"
+# Plot image (graphs) files in png format
+for cps_test_name in "${cps_test_names[@]}"; do
+  buildPlotImage "$cps_test_name.txt" "$cps_test_name.png"
+done
+for ncmp_test_name in "${ncmp_test_name_names[@]}"; do
+  buildPlotImage "$ncmp_test_name.txt" "$ncmp_test_name.png"
+done
+
+# Build the summary(index.html) page
+buildMainPageHtmlReport
+
+# Build individual html page reports for each test
+for cps_test_name in "${cps_test_names[@]}"; do
+  buildSubPageHtmlReport "$cps_test_name.png" "$cps_test_name" "$cps_test_name.html"
+done
+for ncmp_test_name in "${ncmp_test_name_names[@]}"; do
+  buildSubPageHtmlReport "$ncmp_test_name.png" "$ncmp_test_name" "$ncmp_test_name.html"
+done
index da068a144a64b9e65d2cdc81bf65383ec01478b5..00b8b281a0b779d0cb9040ffa4c88ea35b9def2f 100644 (file)
     name: 'onap-{project-name}-performance-tests-plots'
     disabled_job_var: false
     node: xerces-cps-hw
+    wipe_workspace: false
 
     triggers:
       - timed: '{timer}'