Add header to performance test categories
[infra/cicd.git] / jjb / onap / cps / prepare-performance-tests-data.sh
old mode 100644 (file)
new mode 100755 (executable)
index 1a840a8..3ccb5ed
 #!/bin/bash
+#
+# Copyright 2023-2024 Nordix Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -o errexit  # Exit on most errors
+set -o nounset  # Disallow expansion of unset variables
+set -o pipefail # Use last non-zero exit code in a pipeline
+#set -o xtrace   # Trace logging - disabled to avoid producing gigabytes of logs
 
 #############################################################################################################################
 ################################################ 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"
+cps_stable_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")
 
-# Data files headers
-create_data_title_1="Creating openroadm anchors with large data"
-read_data_title_1="Read datatrees using openroadm root"
-update_data_title_1="Update 100 data nodes"
-delete_data_title_1="Batch delete 100 whole lists"
+ncmp_stable_test_names=("Look up CM-handles by module-set-tag" "CpsPath Registry attributes Query")
 
-# Text patterns to match in console log
-creating_bookstore_pattern="^.*Creating openroadm anchors with large.*"
-read_datatreees_pattern="^.*Read datatrees using openroadm root.*"
-update_datanodes_pattern="^.*Update 100 data nodes.*"
-batch_delete_pattern="^.*Batch delete 100 whole lists.*"
+cps_unstable_test_names=("Batch delete 100 non-existing"  "Batch delete 100 whole lists"  "Query with direct descendants"  "Delete 100 whole lists"  "Query 1 anchor non-existing data"  "Read datatrees with no descendants"  "Read non-existing xpaths"  "Query with no descendants"  "Update leaves for 100 data nodes"  "Query ancestors with no descendants"  "Replace 100 with new leaf values"  "Query ancestors with direct descendants"  "Replace list of 100 with new leaf values"  "Replace list of 100 using same data"  "Deleting test data"  "Replace list of 100 nodes with 1"  "Read datatrees using openroadm whole lis"  "Replace 100 using same data"  "Read datatrees with direct descendants"  "Replace 100 nodes with 0"  "Replace list with 50 existing and 50 new"  "Delete 100 lists elements"  "Replace 50 existing and 50 new"  "Writing 800 books"  "Delete 100 containers"  "Replace list with 100 new nodes"  "Replace 100 with 100 new nodes"  "Writing 1600 books"  "Saving list of 200 devices"  "Read datatrees for multiple xpaths")
 
-all_patterns=("$creating_bookstore_pattern" "$read_datatreees_pattern" "$update_datanodes_pattern" "$batch_delete_pattern")
-new_data=""
+ncmp_unstable_test_names=("Look up CM-handle by id" "Update matching subscription" "Look up CM-handle by alternate-id")
 
-latestBuild=$(getLatestBuild)
-availableBuilds=()
-consoleText=""
 JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
 
-# Create and add header to the file
-createAndAddHeader() {
-    file="$1"
-    header="$2"
-    if [[ ! -f "$file" ]]; then
-        echo "Creating $file"
-        touch "$file"
-        echo "Build,$header" > $file
-    else
-        echo "$file already exists"
-    fi
-}
+latestBuildToRecord=""
+consoleText=""
+latestRecordedBuild=""
+timestampOfLatestRecordedBuild=""
 
-# Get latest build
-getLatestBuild() {
-    latestBuild=$(curl -s "${JENKINS_JOB_URL}/lastBuild/api/json" | jq -r '.number')
-    echo "latest build is $latestBuild"
+# 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"
 }
 
-getConsoleText() {
-    buildToRead=$1
-    consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
-    consoleText=$(curl -s "$consoleURL")
-}
-
-getAndRecordDataResults() {
-    consoleText=$1
-    patternToMatch=$2
-    dataFile=$3
-    buildNumber=$4
-    new_data=""
-    matched_line=""
-    limit_value=""
-    took_value=""
-
-    # Get and calculate data for plot
-    if matched_line=$(echo "$consoleText" | grep -o -P "$patternToMatch"); then
-       echo "Matched line: $matched_line"
-       limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
-        echo $limit_value
-       took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
-        echo $took_value
-       percentage=$(($took_value * 100 / $limit_value))
-
-       echo "Limit value: $limit_value"
-       echo "Took value: $took_value"
-       echo "Percentage: $percentage"
+# 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"
 
-    if [ -z "$new_data" ]; then
-       new_data="$percentage"
-       else
-       new_data+=",$percentage"
-       fi
-       echo "New data: $new_data"
-
-       else
-       echo "No match found."
-       fi
-
-    # Record result
-    lastLine=$(tail -n 1 "$dataFile")
-    newLine="$buildNumber,$new_data"
-    if [ -z "$new_data" ]; then
-        echo "No new data"
-    elif [ $newLine == $lastLine ]; then
-       echo "Data already exists"
-    else
-        echo "$buildNumber,$new_data" >> $dataFile
-        echo "New data added"
-    fi
+  # 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 "0"
+  fi
 }
 
-buildStaticReport() {
-    dataFile="$1"  # Get the input file name from the function parameter
-    chartTitle="$2"
-
-    sudo apt-get update
-    sudo apt-get install -y gnuplot
-
-    # Create a temporary Gnuplot script
-    cat <<EOT > gnuplot_script.gp
-    set datafile separator ","
-    set terminal pngcairo size 1500,600
-    set output "${chartTitle}.png"
-
-    # Set X-axis label
-    set xlabel "Build"
-
-    # Read titles from the first line of the CSV
-    plot '$dataFile' using (column(0)+1):2:xtic(1) with linespoints title "Y values"
-EOT
-
-    # Run the Gnuplot script
-    gnuplot gnuplot_script.gp
-
-    # Remove the temporary script
-    rm gnuplot_script.gp
-}
-
-
-buildHTMLReport() {
-
-    chartTitle1="$1"
-    chartFileName1="$2"   # Get the chart file name as the first parameter
-
-    chartTitle2="$3"
-    chartFileName2="$4"
-
-    chartTitle3="$5"
-    chartFileName3="$6"
-
-    chartTitle4="$7"
-    chartFileName4="$8"
-
-    reportTitle="$9"     # Get the report title as the second parameter
-
-cat <<EOT > "index.html"
-<!DOCTYPE html>
-<html>
-<head>
-  <title>$reportTitle</title>
-</head>
-<body>
-    <h1 style="text-align: center;">$reportTitle</h1>
-    <table align="center">
-        <tr> <!-- First Row -->
-            <td align="center">
-                <figcaption>"$chartTitle1"</figcaption>
-                <img src="$chartFileName1" alt="Image 1" width="750" height="300">
-            </td>
-            <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle2"</figcaption>
-                <img src="$chartFileName2" alt="Image 2" 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>
-            <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle4"</figcaption>
-                <img src="$chartFileName4" alt="Image 4" width="750" height="300">
-            </td>
-        </tr>
-    </table>
-</body>
-</html>
-EOT
-}
-
-#!/bin/bash
-
-#############################################################################################################################
-################################################ 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="Creating openroadm anchors with large data"
-read_data_title_1="Read datatrees using openroadm root"
-update_data_title_1="Update 100 data nodes"
-delete_data_title_1="Batch delete 100 whole lists"
-
-# Text patterns to match in console log
-creating_bookstore_pattern="^.*Creating openroadm anchors with large.*"
-read_datatreees_pattern="^.*Read datatrees using openroadm root.*"
-update_datanodes_pattern="^.*Update 100 data nodes.*"
-batch_delete_pattern="^.*Batch delete 100 whole lists.*"
-
-all_patterns=("$creating_bookstore_pattern" "$read_datatreees_pattern" "$update_datanodes_pattern" "$batch_delete_pattern")
-new_data=""
-
-latestBuild=$(getLatestBuild)
-availableBuilds=()
-consoleText=""
-JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
-
-# Create and add header to the file
-createAndAddHeader() {
-    file="$1"
-    header="$2"
-    if [[ ! -f "$file" ]]; then
-        echo "Creating $file"
-        touch "$file"
-        echo "Build,$header" > $file
-    else
-        echo "$file already exists"
-    fi
-}
-
-# Get latest build
-getLatestBuild() {
-    latestBuild=$(curl -s "${JENKINS_JOB_URL}/lastBuild/api/json" | jq -r '.number')
-    echo "latest build is $latestBuild"
+# Get all builds numbers
+getAllBuildNumbers() {
+  curl -s "${JENKINS_JOB_URL}/api/json?tree=allBuilds\[id\]" | jq -r '.allBuilds[].id' | sort -n
 }
 
+# Get the console text from specific build of the performance job
 getConsoleText() {
-    buildToRead=$1
-    consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
-    consoleText=$(curl -s "$consoleURL")
-}
-
+  buildToRead=$1
+  consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
+  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_stable_test_name in "${cps_stable_test_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$cps_stable_test_name" "$cps_stable_test_name.txt" "$buildNumber"
+  done
+  for ncmp_stable_test_name in "${ncmp_stable_test_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$ncmp_stable_test_name" "$ncmp_stable_test_name.txt" "$buildNumber"
+  done
+  for cps_unstable_test_name in "${cps_unstable_test_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$cps_unstable_test_name" "$cps_unstable_test_name.txt" "$buildNumber"
+  done
+  for ncmp_unstable_test_name in "${ncmp_unstable_test_names[@]}"; do
+    getAndRecordDataResults "$consoleText" "$ncmp_unstable_test_name" "$ncmp_unstable_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
-    dataFile=$3
-    buildNumber=$4
-    new_data=""
-    matched_line=""
-    limit_value=""
-    took_value=""
-
-    # Get and calculate data for plot
-    if matched_line=$(echo "$consoleText" | grep -o -P "$patternToMatch"); then
-       echo "Matched line: $matched_line"
-       limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
-        echo $limit_value
-       took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
-        echo $took_value
-       percentage=$(($took_value * 100 / $limit_value))
-
-       echo "Limit value: $limit_value"
-       echo "Took value: $took_value"
-       echo "Percentage: $percentage"
-
-    if [ -z "$new_data" ]; then
-       new_data="$percentage"
-       else
-       new_data+=",$percentage"
-       fi
-       echo "New data: $new_data"
-
-       else
-       echo "No match found."
-       fi
-
-    # Record result
-    lastLine=$(tail -n 1 "$dataFile")
-    newLine="$buildNumber,$new_data"
-    if [ -z "$new_data" ]; then
-        echo "No new data"
-    elif [ $newLine == $lastLine ]; then
-       echo "Data already exists"
-    else
-        echo "$buildNumber,$new_data" >> $dataFile
-        echo "New data added"
-    fi
-}
-
-buildStaticReport() {
-    dataFile="$1"  # Get the input file name from the function parameter
-    chartTitle="$2"
-
-    sudo apt-get update
-    sudo apt-get install -y gnuplot
-
-    # Create a temporary Gnuplot script
-    cat <<EOT > gnuplot_script.gp
-    set datafile separator ","
-    set terminal pngcairo size 1500,600
-    set output "${chartTitle}.png"
-
-    # Set X-axis label
-    set xlabel "Build"
-
-    # Read titles from the first line of the CSV
-    plot '$dataFile' using (column(0)+1):2:xtic(1) with linespoints title "Y values"
+  consoleText=$1
+  patternToMatch=$2
+  dataFile=$3
+  buildNumber=$4
+  new_data=""
+  matched_line=""
+  limit_value=""
+  took_value=""
+
+  # 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 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 probably the build failed
+    echo "$buildNumber,0" >>"$dataFile"
+    recordLatestRecordedBuild "$buildNumber"
+  elif [ "$newLine" == "$lastLine" ]; then
+    # Data already exists
+    recordLatestRecordedBuild "$buildNumber"
+  else
+    # 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')
+  formattedTimestampOfLatestRecordedBuild=$(date -d "@$((timestampOfLatestRecordedBuild / 1000))" "+%B %e, %Y at %H:%M")
+  latestRecordedBuild=$latestBuildToRecord
+}
+
+# Plot the image (graph) in png format
+buildPlotImage() {
+  dataFile="$1" # Get the input file name from the function parameter
+  chartFileName="$2"
+
+  # Create a temporary Gnuplot script
+  cat <<EOT >gnuplot_script.gp
+set datafile separator ","
+set terminal pngcairo size 1500,600
+set output "${chartFileName}"
+set xlabel "Build"
+set ylabel "Percentage of limit %"
+set yrange [0 < * < 80 : 120 < *]
+set xtics rotate
+plot '$dataFile' using (column(0)):2:xtic(sprintf("%d", column(1))) with linespoints title "measured", \
+     100 with lines linestyle 2 title "100% limit"
 EOT
 
-    # Run the Gnuplot script
-    gnuplot gnuplot_script.gp
+  # Run the temporary Gnuplot script
+  gnuplot gnuplot_script.gp
 
-    # Remove the temporary script
-    rm gnuplot_script.gp
+  # Remove the temporary Gnuplot script
+  rm gnuplot_script.gp
 }
 
-
-buildHTMLReport() {
-
-    chartTitle1="$1"
-    chartFileName1="$2"   # Get the chart file name as the first parameter
-
-    chartTitle2="$3"
-    chartFileName2="$4"
-
-    chartTitle3="$5"
-    chartFileName3="$6"
-
-    chartTitle4="$7"
-    chartFileName4="$8"
-
-    reportTitle="$9"     # Get the report title as the second parameter
-
-cat <<EOT > "index.html"
-<!DOCTYPE html>
-<html>
-<head>
-  <title>$reportTitle</title>
-</head>
-<body>
-    <h1 style="text-align: center;">$reportTitle</h1>
-    <table align="center">
-        <tr> <!-- First Row -->
-            <td align="center">
-                <figcaption>"$chartTitle1"</figcaption>
-                <img src="$chartFileName1" alt="Image 1" width="750" height="300">
-            </td>
-            <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle2"</figcaption>
-                <img src="$chartFileName2" alt="Image 2" 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>
-            <td align="center" style="padding: 10px;">
-                <figcaption>"$chartTitle4"</figcaption>
-                <img src="$chartFileName4" alt="Image 4" width="750" height="300">
-            </td>
-        </tr>
-    </table>
-</body>
-</html>
-EOT
-}
-
-buildPageReport() {
-    chartFileName="$1"
-    reportTitle="$2"
-    outputFile="$3"
-    cat <<EOT > "$outputFile"
+# Builds category html file
+buildCategoryHtmlReport() {
+  # use indirect expansion to get all elements of the array
+  categoryName=("${!1}")
+  reportTitle="$2"
+  outputFile="$3"
+  cat <<EOT >"$outputFile"
     <!DOCTYPE html>
     <html>
     <head>
     <title>$reportTitle</title>
     </head>
     <body>
-        <h1>$reportTitle</h1>
-        <img src="$chartFileName" alt="Graph Image">
+      <h1 style="text-align: center;">$reportTitle</h1>
+      <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
+      <table align="center">
+EOT
+# Loop through the test names to generate HTML rows
+for test_name_in_category in "${categoryName[@]}"; do
+    cat <<EOF >>"$outputFile"
+        <tr> <!-- Row for $test_name_in_category -->
+            <td align="center" style="padding: 10px;">
+                <figcaption>"$test_name_in_category"</figcaption>
+                <img src="$test_name_in_category.png" width="750" height="300">
+            </td>
+        </tr>
+EOF
+done
+# Close the HTML file
+cat <<EOT >>"$outputFile"
+      </table>
+        <p>The performance tests job runs every two (even) hours, providing performance metrics. The following graphs being updated every two (odd) hours.</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>
     </body>
-    </html>
+  </html>
 EOT
 }
 
-buildPlotForCreateOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$create_data" "$create_data_title_1"
-    getAndRecordDataResults "$consoleText" "$creating_bookstore_pattern" "$create_data" "$buildNumber"
-}
-
-buildPlotForReadOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$read_data" "$read_data_title_1"
-    getAndRecordDataResults "$consoleText" "$read_datatreees_pattern" "$read_data"  "$buildNumber"
-}
-
-buildPlotForUpdateOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$update_data" "$update_data_title_1"
-    getAndRecordDataResults "$consoleText" "$update_datanodes_pattern" "$update_data"  "$buildNumber"
-}
-
-buildPlotForBatchOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$delete_data" "$delete_data_title_1"
-    getAndRecordDataResults "$consoleText" "$batch_delete_pattern" "$delete_data"  "$buildNumber"
-}
-
 #############################################################################################################################
+################################################ M A I N ####################################################################
 #############################################################################################################################
-#############################################################################################################################
-#############################################################################################################################
-
-cd $WORKSPACE
-
-getLatestBuild
-if [ -z "$(ls -A)" ]; then
-       # Calculate the starting value for the loop
-        startValue=$((latestBuild - 50))
-
-        # Start the loop from startValue up to latestBuild
-        for ((i=startValue; i<=latestBuild; i++)); do
-            getConsoleText "$i"
-            buildPlotForCreateOperation "$i"
-            buildPlotForReadOperation "$i"
-            buildPlotForUpdateOperation "$i"
-            buildPlotForBatchOperation "$i"
-        done
-            buildStaticReport "$create_data" "createLargeData"
-            buildStaticReport "$read_data" "readDataTrees"
-            buildStaticReport "$update_data" "updateDatanodes"
-            buildStaticReport "$delete_data" "batchDelete"
-else
-    getConsoleText $latestBuild
-    buildPlotForCreateOperation $latestBuild
-    buildPlotForReadOperation $latestBuild
-    buildPlotForUpdateOperation $latestBuild
-    buildPlotForBatchOperation $latestBuild
-
-    buildStaticReport "$create_data" "createLargeData"
-    buildStaticReport "$read_data" "readDataTrees"
-    buildStaticReport "$update_data" "updateDatanodes"
-    buildStaticReport "$delete_data" "batchDelete"
-fi
-
-
-touch index.html createOperation.html readOperation.html updateOperation.html deleteOperation.html
-
-buildHTMLReport \
-    "Creating openroadm anchors with large data" \
-    "createLargeData.png" \
-    "Read datatrees using openroadm root" \
-    "readDataTrees.png" \
-    "Update 100 data nodes" \
-    "updateDatanodes.png" \
-    "Batch delete 100 whole lists" \
-    "batchDelete.png" \
-    "Performance Review"
-
-buildPageReport "createLargeData.png" "Creating openroadm anchors with large data"  "createOperation.html"
-buildPageReport "readDataTrees.png" "Read datatrees using openroadm root"  "readOperation.html"
-buildPageReport "updateDatanodes.png" "Update 100 data nodes" "updateOperation.html"
-buildPageReport "batchDelete.png" "Batch delete 100 whole lists" "deleteOperation.html"
-
-
-buildPlotForCreateOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$create_data" "$create_data_title_1"
-    getAndRecordDataResults "$consoleText" "$creating_bookstore_pattern" "$create_data" "$buildNumber"
-}
 
-buildPlotForReadOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$read_data" "$read_data_title_1"
-    getAndRecordDataResults "$consoleText" "$read_datatreees_pattern" "$read_data"  "$buildNumber"
-}
-
-buildPlotForUpdateOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$update_data" "$update_data_title_1"
-    getAndRecordDataResults "$consoleText" "$update_datanodes_pattern" "$update_data"  "$buildNumber"
-}
-
-buildPlotForBatchOperation() {
-       buildNumber="$1"
-    createAndAddHeader "$delete_data" "$delete_data_title_1"
-    getAndRecordDataResults "$consoleText" "$batch_delete_pattern" "$delete_data"  "$buildNumber"
-}
-
-#############################################################################################################################
-#############################################################################################################################
-#############################################################################################################################
-#############################################################################################################################
+# Install dependencies
+sudo apt-get install -y bc gnuplot jq
 
-cd $WORKSPACE
-
-getLatestBuild
+# Download data from CPS performance Jenkins job
+cd "$WORKSPACE"
 if [ -z "$(ls -A)" ]; then
-       # Calculate the starting value for the loop
-        startValue=$((latestBuild - 50))
-
-        # Start the loop from startValue up to latestBuild
-        for ((i=startValue; i<=latestBuild; i++)); do
-            getConsoleText "$i"
-            buildPlotForCreateOperation "$i"
-            buildPlotForReadOperation "$i"
-            buildPlotForUpdateOperation "$i"
-            buildPlotForBatchOperation "$i"
-        done
-            buildStaticReport "$create_data" "createLargeData"
-            buildStaticReport "$read_data" "readDataTrees"
-            buildStaticReport "$update_data" "updateDatanodes"
-            buildStaticReport "$delete_data" "batchDelete"
+  # If workspace is empty, pull data from all previous performance job runs
+  for buildNumber in $(getAllBuildNumbers); do
+    getAndRecordPerformanceJobResultForBuild "$buildNumber"
+  done
 else
-    getConsoleText $latestBuild
-    buildPlotForCreateOperation $latestBuild
-    buildPlotForReadOperation $latestBuild
-    buildPlotForUpdateOperation $latestBuild
-    buildPlotForBatchOperation $latestBuild
-
-    buildStaticReport "$create_data" "createLargeData"
-    buildStaticReport "$read_data" "readDataTrees"
-    buildStaticReport "$update_data" "updateDatanodes"
-    buildStaticReport "$delete_data" "batchDelete"
+  # 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
 
-
-touch index.html createOperation.html readOperation.html updateOperation.html deleteOperation.html
-
-buildHTMLReport \
-    "Creating openroadm anchors with large data" \
-    "createLargeData.png" \
-    "Read datatrees using openroadm root" \
-    "readDataTrees.png" \
-    "Update 100 data nodes" \
-    "updateDatanodes.png" \
-    "Batch delete 100 whole lists" \
-    "batchDelete.png" \
-    "Performance Review"
-
-buildPageReport "createLargeData.png" "Creating openroadm anchors with large data"  "createOperation.html"
-buildPageReport "readDataTrees.png" "Read datatrees using openroadm root"  "readOperation.html"
-buildPageReport "updateDatanodes.png" "Update 100 data nodes" "updateOperation.html"
-buildPageReport "batchDelete.png" "Batch delete 100 whole lists" "deleteOperation.html"
+# Plot image (graphs) files in png format
+for cps_stable_test_name in "${cps_stable_test_names[@]}"; do
+  buildPlotImage "$cps_stable_test_name.txt" "$cps_stable_test_name.png"
+done
+for ncmp_stable_test_name in "${ncmp_stable_test_names[@]}"; do
+  buildPlotImage "$ncmp_stable_test_name.txt" "$ncmp_stable_test_name.png"
+done
+for cps_unstable_test_name in "${cps_unstable_test_names[@]}"; do
+  buildPlotImage "$cps_unstable_test_name.txt" "$cps_unstable_test_name.png"
+done
+for ncmp_unstable_test_name in "${ncmp_unstable_test_names[@]}"; do
+  buildPlotImage "$ncmp_unstable_test_name.txt" "$ncmp_unstable_test_name.png"
+done
+
+# Build the category pages
+buildCategoryHtmlReport cps_stable_test_names[@] "cps stable tests performance review" "cpsStableTestsPerformanceReview.html"
+buildCategoryHtmlReport ncmp_stable_test_names[@] "ncmp stable tests performance review" "ncmpStableTestsPerformanceReview.html"
+buildCategoryHtmlReport cps_unstable_test_names[@] "cps unstable tests performance review" "cpsUnstableTestsPerformanceReview.html"
+buildCategoryHtmlReport ncmp_unstable_test_names[@] "ncmp unstable tests performance review" "ncmpUnstableTestsPerformanceReview.html"