blob: c305cdd9fa872f7d16e48b6aee48e8b7643ed396 [file] [log] [blame]
#!/bin/bash
cd $WORKSPACE
data_file="results.txt"
data_file_headers="Creating openroadm anchors with large data,Read datatrees using openroadm root,Update 100 data nodes,Batch delete 100 whole lists"
if [[ ! -f "$data_file" ]]; then
echo "Creating $data_file"
touch "$data_file"
echo "$data_file_headers" > $data_file
else
echo "$data_file already exists"
fi
echo "-----------------------------------------------------------------------------------"
echo "-----------------------------------------------------------------------------------"
# Extracting data results from performance job
JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
latest_build=$(curl -s "${JENKINS_JOB_URL}/lastBuild/api/json" | jq -r '.number')
echo "latest build is $latest_build"
# Get the latest build status
latest_build_status=$(curl -s "${JENKINS_JOB_URL}/api/json" | jq -r '.color')
echo "latest build status is $latest_build_status"
# Construct the URL for getting the console text
CONSOLE_URL="${JENKINS_JOB_URL}/${latest_build}/consoleText"
# Get the console text
console_text=$(curl -s "$CONSOLE_URL")
echo "-----------------------------------------------------------------------------------"
echo "-----------------------------------------------------------------------------------"
# 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=""
# Extract numerical values as data results
for pattern in "${all_patterns[@]}"; do
if matched_line=$(echo "$console_text" | grep -o -P "$pattern"); then
echo "Matched line: $matched_line"
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=$((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
done
echo "-----------------------------------------------------------------------------------"
echo "-----------------------------------------------------------------------------------"
# Publish results in file for building plot
if [ -z "$new_data" ]; then
echo "No new data"
else
echo "$new_data" >> $data_file
fi