Performance plots for CPS in Jenkins
Things to know:
Jenkins Job project name is onap-cps-performance-tests-plots (https://jenkins.nordix.org/job/onap-cps-performance-tests-plots/)
To amend the job configuration which is managed by Jenkins Job Builder, you will need to download the infra/cicd repo and commit the changes.
Relevant files in the repo:
jjb/onap/cps/cps-performance-test-jobs.yaml
Initializes the creation of the project/job
jjb/onap/cps/prepare-performance-tests-data.sh
Contains the bash script that is run by the job
jjb/onap/global-templates-onap-java.yaml
Defines the job
Configures the HTML publisher to be added to the job as a post-build
Configures the performance tests job (onap-cps-master-performance-test-java, https://jenkins.nordix.org/job/onap-cps-master-performance-test-java/) to trigger the job 'onap-cps-performance-tests-plots' after stable build
The plot is created via the HTML publisher plugin in Jenkins
Jenkins does not allow the use of CSS and Javascript by default (unless security configurations for the server are changed)
IMPORTANT: Since the performance plot job is 'Managed by Jenkins Job Builder', all changes you create manually on the Jenkins API and not via Jenkins Job Builder will be discarded and set back to the default once the job is called via the defined trigger. Therefore, all modifications in the configuration must be made via modifying the repo files in order to update it via the Jenkins Job Builder.
Creating the performance plots via the HTML publisher plugin
The job runs by executing a shell script which follows the following steps:
Gets the latest build
If the current workspace is empty (which assumes to have no previous data anymore) then collect all other build information and call subsequent methods (see below) such as building plot and building static report methods; else if the current workspace is not empty then just call the subsequent methods
getConsoleText()
parameter- latest build number(integer)
uses curl to retrieve the console text on a specific build
buildPlotForCreateOperation(), buildPlotForReadOperation(), buildPlotForUpdateOperation(), buildPlotForBatchOperation()
parameter- build number (integer)
calls the method createAndAddHeader
creates the file (if does not exist) to store the data for the plot and adds the appropriate header for the data to be added
calls the method getAndRecordDataResults
parameters - relevant console text (string), pattern to match on the console text (string), data file name (string), build number (integer)
finds the information on the console text via the pattern given to collect the relevant data information (limit value, took value)
calculates the collected data appropriately (percentage)
records the result for the plot to use on the file given - if the result is the same as the last result, i.e. same build number and same data, then data is not added again as 'data already exists'
buildStaticReport()
parameters - data file name (string), image file name (string)
installs Gnuplot
runs gnuPlot script which creates line plots using the given data file
creates the plot and saves it as an image file (.png) on the current workspace
Create HTML files for the HTML publisher plugin
Calls the method builHTMLReport()
parameters-
parameters 1,3,5,7 - plot titles corresponding the plot image with it (string)
parameters 2,4,6,8 - plot images file (string)
parameter 9 - report title (string)
this method defines the main index page (index.html)
currently only supporting 4 plot images for main plots of the 4 operation available (create, read, update, delete)
Calls buildPageReport()
parameters - plot image file(string), plot title (string), html file(string)
defines the separate pages for the plots
After the job has executed the defined shell script, post-build actions are executed which are defined to run the HTML publisher plugin ('Publish HTML reports')
In Jenkins API, the following configuration shows:
HTML directory archive
"." - current workspace
Index pages
all html files that exists that must be included in the report
Report title
"Performance Review" - the report title to show in the Jenkins Job main page
The following configuration above corresponds to the configuration on the following file:
jjb/onap/global-templates-onap-java.yaml
The given file names must always already exist, these files are not created by the HTML publisher plugin.
Additional Information:
Setting up Jenkins locally:
Install Docker
Run Jenkins via docker image
bash: docker run -d -p 8080:8080 -p 50000:50000 --name jenkins jenkins/jenkins:lts
Access jenkins through your web browser via
Jenkins will ask for initial admin password and you can retrieve this by running the following on your terminal:
docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
On set up
Install suggested plugins
Create username and password for yourself
If you would like to test configurations on a Job you would like to modify wherein the Job is "Managed by Jenkins Job Builder", install Jenkins Job Builder locally.