#!/bin/bash
-
#############################################################################################################################
################################################ F U N C T I O N S ##########################################################
#############################################################################################################################
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"
}
-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"
-
- 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"
-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=""
+lastRecordedBuild=""
+dateOfLastRecordedBuild=""
JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
# Create and add header to the file
fi
}
-# Get latest build
-getLatestBuild() {
- latestBuild=$(curl -s "${JENKINS_JOB_URL}/lastBuild/api/json" | jq -r '.number')
- echo "latest build is $latestBuild"
-}
-
getConsoleText() {
buildToRead=$1
consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
echo "$buildNumber,$new_data" >> $dataFile
echo "New data added"
fi
+ lastRecordedBuild=$buildNumber
+ dateOfLastRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${lastRecordedBuild}/api/json" | jq -r '.timestamp' | xargs -I {} date -d "@{}")
+ echo "last Recorded build: $lastRecordedBuild"
+ echo "date of last recorded build: $dateOfLastRecordedBuild"
}
buildStaticReport() {
# 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"
+ # Set Y-axis label
+ set ylabel "Percentage of limit %"
+
+ # Get stats for min and max
+ stats '$dataFile' using 1
+ xmin = STATS_min
+ freq = 5 #frequency
+ xLabel(x) = (int((x - xmin) / freq) % 2 == 0) ? sprintf("%d", x) : ""
+
+ plot '$dataFile' using (column(0)+1):2:xtic(xLabel(column(1))) with linespoints title "limit"
EOT
# Run the Gnuplot script
rm gnuplot_script.gp
}
-
buildHTMLReport() {
chartTitle1="$1"
</head>
<body>
<h1 style="text-align: center;">$reportTitle</h1>
+ <h4>Last recorded build number: $lastRecordedBuild</h4>
+ <h4>Date of the last recoded build: $dateOfLastRecordedBuild</h4>
<table align="center">
<tr> <!-- First Row -->
<td align="center">
</head>
<body>
<h1>$reportTitle</h1>
+ <h4>Last recorded build number: $lastRecordedBuild</h4>
+ <h4>Date of the last recoded build: $dateOfLastRecordedBuild</h4>
<img src="$chartFileName" alt="Graph Image">
</body>
</html>
getLatestBuild
if [ -z "$(ls -A)" ]; then
# Calculate the starting value for the loop
- startValue=$((latestBuild - 50))
+ startValue=$((latestBuild - 70))
# Start the loop from startValue up to latestBuild
for ((i=startValue; i<=latestBuild; i++)); do