Introduction
The documents explain how to integrate DevTest with Jenkins pipeline for Virtual Services deployment and Stage and run test cases or test suite.
DevTest tool comes with Lisa Invoke API used to integrate with DevTest via RESTFul service calls.
DevTest has two versions of this API LISA Invoke and REST INVOKE API - This is a Swagger API primarily advance version for Lisa Invoke API
Jenkins Pipeline Script to deploy mar
stage('DevTestVSDeploy') {
sh returnStdout: true, script: '''curl --request POST \\
--url http://localhost:1505/api/Dcm/VSEs/VSE/actions/deployMar \\
--header \'authorization: Basic YWRtaW46YWRtaW4=\' \\
--header \'cache-control: no-cache\' \\
--header \'content-type: multipart/form-data; boundary=----WebKitFormBoundaryDeployVirtualServiceAsMarStart\' \\
--form file=@RnDProject/Mar/UserService.mar'''
}
Jenkins console output
Jenkins Pipeline Script to delete virtual service from VSE
stage('DevTestVSRemove') {
sh returnStdout: true, script: '''curl --request DELETE \\
--url http://localhost:1505/api/Dcm/VSEs/VSE/UserService \\
--header \'authorization: Basic YWRtaW46YWRtaW4=\' \\
--header \'cache-control: no-cache\' \\
--output deleteService.xml
'''
}
Jenkins console output:
Jenkins Pipeline Script to run the Suite in Sync mode
New REST INVOKE API don't have any option to execute the test or suite in sync mode, so I have used the Lisa Invoke API.
The advantage with this API is, the test results will be returned as part of the rest request, for CI and CD Integration this is critical because based on the results the build can either setup to pass or fail and notifications can send to the appropriate team.
stage('DevTestContinuousTesting') {
sh returnStdout: true, script: '''curl --request GET \\
--url \'http://localhost:1505/lisa-invoke/runSuite?suitePath=Projects%2FRnDPorject%2FTests%2FSuites%2FAllTestsSuite.ste\' \\
--header \'cache-control: no-cache\' \\
--output testResults.xml'''
String results = readFile 'testResults.xml'
if(!results.contains("<fail count=\"0\"")) {
error 'Integration tests area failed and results will be emailed to techopsteam@aa.com'
}
println results
}
Jenkins output results.
Sample Jenkins Pipeline Script
package jenkins.sv.pipeline
node {
stage('DevTestBuild') {
sh returnStdout: true, script: '''rm -rf RepairPurchaseOrder'''
sh returnStdout: true, script: '''git clone https://github.com/cicddevtest/RepairPurchaseOrder.git RepairPurchaseOrder'''
sh '''cp -rf RepairPurchaseOrder /Users/vamsi/ca/lisa/server/9.1.0/Projects'''
}
stage('DevTestDeploy') {
sh returnStdout: true, script: '''curl --request DELETE \\
--url http://localhost:1505/api/Dcm/VSEs/VSE/RepairPurchaseOrderServiceV1 \\
--header \'authorization: Basic YWRtaW46YWRtaW4=\' \\
--header \'cache-control: no-cache\' \\
--output deleteService.xml
'''
sh returnStdout: true, script: '''curl --request POST \\
--url http://localhost:1505/api/Dcm/VSEs/VSE/actions/deployMar \\
--header \'authorization: Basic YWRtaW46YWRtaW4=\' \\
--header \'cache-control: no-cache\' \\
--header \'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW\' \\
--form file=@RepairPurchaseOrder/Mar/RepairPurchaseOrderServiceV1.mar'''
}
stage('DevTestContinuousTesting') {
// sh returnStdout: true, script: '''curl --request POST \\
// --url http://localhost:1505/api/Dcm/CoordinatorServers/Coordinator/actions/deployMar \\
// --header \'authorization: Basic YWRtaW46YWRtaW4=\' \\
// --header \'cache-control: no-cache\' \\
// --header \'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW\' \\
// --form file=@RepairPurchaseOrder/Mar/AllTestsSuite.mar'''
sh returnStdout: true, script: '''curl --request GET \\
--url \'http://localhost:1505/lisa-invoke/runSuite?suitePath=Projects%2FRepairPurchaseOrder%2FTests%2FSuites%2FAllTestsSuite.ste\' \\
--header \'cache-control: no-cache\' \\
--output testResults.xml'''
}
stage('DevTestValidateResults') {
String results = readFile 'testResults.xml'
if(!results.contains("<fail count=\"0\"")) {
error 'Integration tests area failed and results will be emailed to techopsteam@aa.com'
}
println results
}
stage('DevTestCleanup') {
sh returnStdout: true, script: '''rm -rf /Users/vamsi/ca/lisa/server/9.1.0/Projects/RepairPurchaseOrder'''
sh returnStdout: true, script: '''rm -rf RepairPurchaseOrder'''
// step([$class: 'WsCleanup'])
}
}