Merge "Create jenkins pipeline for k6 performance tests"
[infra/cicd.git] / jjb / onap / cps / prepare-performance-tests-data.sh
index 47739442a9ceeaed4c21d93c6632ce2e865beb63..276ea4735f929581686309f75cf5c191748f3fd3 100755 (executable)
@@ -24,9 +24,13 @@ set -o pipefail # Use last non-zero exit code in a pipeline
 ################################################ F U N C T I O N S ##########################################################
 #############################################################################################################################
 
-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")
+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")
 
-ncmp_test_name_names=("Look up CM-handles by module-set-tag")
+ncmp_stable_test_names=("Look up CM-handles by module-set-tag" "CpsPath Registry attributes Query")
+
+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")
+
+ncmp_unstable_test_names=("Look up CM-handle by id" "Update matching subscription" "Look up CM-handle by alternate-id")
 
 JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
 
@@ -54,7 +58,7 @@ getLastRecordedBuildNumber() {
     local left_side=$(echo "$last_line" | cut -d ',' -f 1)
     echo "$left_side"
   else
-    echo "File '$file_name' not found in the current directory"
+    echo "0"
   fi
 }
 
@@ -75,11 +79,17 @@ 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"
+  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 ncmp_test_name in "${ncmp_test_name_names[@]}"; do
-    getAndRecordDataResults "$consoleText" "$ncmp_test_name" "$ncmp_test_name.txt" "$buildNumber"
+  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
 }
 
@@ -153,59 +163,10 @@ EOT
   rm gnuplot_script.gp
 }
 
-# Builds index.html file (main page)
-buildMainPageHtmlReport() {
-cat <<EOT >"index.html"
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Performance Review</title>
-</head>
-<body>
-    <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 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">
-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>"$cps_test_name (CPS)"</figcaption>
-                <img src="$cps_test_name.png" width="750" height="300">
-            </td>
-        </tr>
-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>"$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
-}
-
-# Builds sub-HTML pages
-buildSubPageHtmlReport() {
-  chartFileName="$1"
+# Builds category html file
+buildCategoryHtmlReport() {
+  # use indirect expansion to get all elements of the array
+  categoryName=("${!1}")
   reportTitle="$2"
   outputFile="$3"
   cat <<EOT >"$outputFile"
@@ -215,11 +176,29 @@ buildSubPageHtmlReport() {
     <title>$reportTitle</title>
     </head>
     <body>
-        <h1>$reportTitle</h1>
-        <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
-        <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
 }
 
@@ -251,21 +230,36 @@ else
   fi
 fi
 
-# 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"
+# Limit the plots to last 100 builds for each test
+for cps_stable_test_name in "${cps_stable_test_names[@]}"; do
+  tail -n 100 "$cps_stable_test_name.txt" > file.tmp && mv file.tmp "$cps_stable_test_name.txt"
 done
-for ncmp_test_name in "${ncmp_test_name_names[@]}"; do
-  buildPlotImage "$ncmp_test_name.txt" "$ncmp_test_name.png"
+for ncmp_stable_test_name in "${ncmp_stable_test_names[@]}"; do
+  tail -n 100 "$ncmp_stable_test_name.txt" > file.tmp && mv file.tmp "$ncmp_stable_test_name.txt"
+done
+for cps_unstable_test_name in "${cps_unstable_test_names[@]}"; do
+  tail -n 100 "$cps_unstable_test_name.txt" > file.tmp && mv file.tmp "$cps_unstable_test_name.txt"
+done
+for ncmp_unstable_test_name in "${ncmp_unstable_test_names[@]}"; do
+  tail -n 100 "$ncmp_unstable_test_name.txt" > file.tmp && mv file.tmp "$ncmp_unstable_test_name.txt"
 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"
+# 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 ncmp_test_name in "${ncmp_test_name_names[@]}"; do
-  buildSubPageHtmlReport "$ncmp_test_name.png" "$ncmp_test_name" "$ncmp_test_name.html"
+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"