4 data_file="results.txt"
5 data_file_headers="Creating openroadm anchors with large data,Read datatrees using openroadm root,Update 100 data nodes,Batch delete 100 whole lists"
7 if [[ ! -f "$data_file" ]]; then
8 echo "Creating $data_file"
10 echo "$data_file_headers" > $data_file
12 echo "$data_file already exists"
15 echo "-----------------------------------------------------------------------------------"
16 echo "-----------------------------------------------------------------------------------"
17 # Extracting data results from performance job
18 JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
19 latest_build=$(curl -s "${JENKINS_JOB_URL}/lastBuild/api/json" | jq -r '.number')
20 echo "latest build is $latest_build"
22 # Get the latest build status
23 latest_build_status=$(curl -s "${JENKINS_JOB_URL}/api/json" | jq -r '.color')
24 echo "latest build status is $latest_build_status"
26 # Construct the URL for getting the console text
27 CONSOLE_URL="${JENKINS_JOB_URL}/${latest_build}/consoleText"
29 # Get the console text
30 console_text=$(curl -s "$CONSOLE_URL")
32 echo "-----------------------------------------------------------------------------------"
33 echo "-----------------------------------------------------------------------------------"
35 # Text patterns to match in console log
36 creating_bookstore_pattern="^.*Creating openroadm anchors with large.*"
37 read_datatreees_pattern="^.*Read datatrees using openroadm root.*"
38 update_datanodes_pattern="^.*Update 100 data nodes.*"
39 batch_delete_pattern="^.*Batch delete 100 whole lists.*"
41 all_patterns=("$creating_bookstore_pattern" "$read_datatreees_pattern" "$update_datanodes_pattern" "$batch_delete_pattern")
44 # Extract numerical values as data results
45 for pattern in "${all_patterns[@]}"; do
46 if matched_line=$(echo "$console_text" | grep -o -P "$pattern"); then
47 echo "Matched line: $matched_line"
48 limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
49 took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
50 percentage=$((took_value * 100 / limit_value))
52 echo "Limit value: $limit_value"
53 echo "Took value: $took_value"
54 echo "Percentage: $percentage"
56 if [ -z "$new_data" ]; then
57 new_data="$percentage"
59 new_data+=",$percentage"
61 echo "New data: $new_data"
64 echo "No match found."
67 echo "-----------------------------------------------------------------------------------"
68 echo "-----------------------------------------------------------------------------------"
71 # Publish results in file for building plot
72 if [ -z "$new_data" ]; then
75 echo "$new_data" >> $data_file