#!/bin/bash
+sudo apt-get install bc
#############################################################################################################################
################################################ F U N C T I O N S ##########################################################
#############################################################################################################################
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=""
+JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
# Get latest build
getLatestBuild() {
}
latestBuild=$(getLatestBuild)
+latestBuildToRecord=""
consoleText=""
lastRecordedBuild=""
-dateOfLastRecordedBuild=""
-JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
+latestRecordedBuild=""
+timestampOfLatestRecordedBuild=""
# Create and add header to the file
createAndAddHeader() {
fi
}
+# Get the console text from specific build of the performance job
getConsoleText() {
buildToRead=$1
consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
# 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:]')
+ 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:]')
+ 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))
+ percentage=$(echo "scale=2; $took_value * 100.00 / $limit_value" | bc)
+
echo "Limit value: $limit_value"
echo "Took value: $took_value"
newLine="$buildNumber,$new_data"
if [ -z "$new_data" ]; then
echo "No new data"
+ lastRecordedBuild=$(echo "$lastLine" | awk -F, '{print $1}')
+ recordLatestRecordedBuild "$lastRecordedBuild"
elif [ $newLine == $lastLine ]; then
- echo "Data already exists"
+ echo "Data already exists"
+ recordLatestRecordedBuild "$buildNumber"
else
echo "$buildNumber,$new_data" >> $dataFile
echo "New data added"
+ recordLatestRecordedBuild "$buildNumber"
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"
+}
+
+recordLatestRecordedBuild() {
+ latestBuildToRecord="$1"
+ timestampOfLatestRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${latestBuildToRecord}/api/json" | jq -r '.timestamp')
+ formattedTimestampOfLatestRecordedBuild=$(date -d "@$((timestampOfLatestRecordedBuild / 1000))" "+%B %e, %Y at %H:%M")
+ echo "Latest recorded build: $latestBuildToRecord"
+ echo "Date of latest recorded build: $formattedTimestampOfLatestRecordedBuild"
+ latestRecordedBuild=$latestBuildToRecord
}
buildStaticReport() {
buildHTMLReport() {
- chartTitle1="$1"
- chartFileName1="$2" # Get the chart file name as the first parameter
+ chartTitle1="$1" # i.e Get the chart file name as the first parameter
+ chartFileName1="$2"
chartTitle2="$3"
chartFileName2="$4"
chartTitle4="$7"
chartFileName4="$8"
- reportTitle="$9" # Get the report title as the second parameter
+ reportTitle="$9" # i.e Get the report title as the ninth parameter
cat <<EOT > "index.html"
<!DOCTYPE html>
</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>
+ <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>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">
</head>
<body>
<h1>$reportTitle</h1>
- <h4>Last recorded build number: $lastRecordedBuild</h4>
- <h4>Date of the last recoded build: $dateOfLastRecordedBuild</h4>
+ <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
<img src="$chartFileName" alt="Graph Image">
</body>
</html>
getLatestBuild
if [ -z "$(ls -A)" ]; then
# Calculate the starting value for the loop
- startValue=$((latestBuild - 70))
+ startValue=$((latestBuild - 100))
# Start the loop from startValue up to latestBuild
for ((i=startValue; i<=latestBuild; i++)); do