Create plots for cps performance tests 82/19082/4
authoremaclee <lee.anjella.macabuhay@est.tech>
Fri, 18 Aug 2023 13:14:49 +0000 (14:14 +0100)
committeremaclee <lee.anjella.macabuhay@est.tech>
Tue, 22 Aug 2023 10:13:57 +0000 (11:13 +0100)
Issue-ID: CPS-1777
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Change-Id: I93a6ea568e67edeb65cb3f20c5f9fbf86d3f7aaf

jjb/onap/cps/cps-performance-test-jobs.yaml
jjb/onap/cps/prepare-performance-tests-data.sh [new file with mode: 0644]
jjb/onap/global-templates-onap-java.yaml

index d08f4f8e36ee3454774e4c4a1eab60a6e980b01e..8e1ce69921c249be6dec824942d6af30bc168229 100644 (file)
 
     jobs:
       - 'onap-{project-name}-{stream}-performance-test-java'
+
+- project:
+    name: cps-tests-plots
+    project: cps
+    project-name: cps
+
+    jobs:
+        - 'onap-{project-name}-performance-tests-plots'
\ No newline at end of file
diff --git a/jjb/onap/cps/prepare-performance-tests-data.sh b/jjb/onap/cps/prepare-performance-tests-data.sh
new file mode 100644 (file)
index 0000000..c305cdd
--- /dev/null
@@ -0,0 +1,76 @@
+#!/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
\ No newline at end of file
index 8902f57adb815d8da52427b0394cecf08068fa32..3132f956cf09bcaba03513cc46e121d6acf286a3 100644 (file)
@@ -68,7 +68,7 @@
       - shell:
           !include-raw-escape: ./verify-jobs.sh
 
-# A job to perform CSIT on policy components 
+# A job to perform CSIT on policy components
 - job-template:
     name: 'onap-{project-name}-{stream}-policy-csit-verify-java'
     disabled_job_var: false
       - string:
           name: CSIT_NAME
           default: '{csit-name}'
-          description: The name of the csit-test to run          
+          description: The name of the csit-test to run
       - string:
           name: SUBDIRECTORY
           default: '{subdirectory}'
           !include-raw-escape: ./verify-jobs.sh
       - shell:
           !include-raw-escape: ./verify-policy-csit.sh
+
+- job-template:
+    name: 'onap-{project-name}-performance-tests-plots'
+    disabled_job_var: false
+    node: onap-ubuntu1804
+
+    builders:
+      - shell:
+          !include-raw-escape: ./cps/prepare-performance-tests-data.sh
+
+    publishers:
+      - plot:
+          - title: "performance"
+            group: "performance"
+            csvFileName: "results.txt"
+            style: line
+            exclude-zero-yaxis: true
+            num-builds: '30'
+            series:
+              - file:
+                url: 'results.txt'
+                inclusion-flag: 'off'
+                display-table: false
+                format: csv
+
 - job-template:
     name: 'onap-{project-name}-{stream}-performance-test-java'
     disabled_job_var: false
       - shell:
           !include-raw-escape: ./verify-jobs.sh
 
+    post-build:
+      - project: onap-cps-performance-tests-plots
 
 # csits for diferent projects are different so need to have special handling
 - job-template: