Service Virtualization

 View Only

Jenkins Pipeline Integration with DevTest 

Jan 31, 2017 10:17 PM

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'])
          
          
      }
  
}

Statistics
1 Favorited
27 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Mar 08, 2017 10:18 PM

I have explained in artical how to run suite from Jenkins and pass the build based on results , you can use the same method to run the tests as well. 

Feb 15, 2017 06:00 AM

HI,

 

Thanks for the document....

 

Could you please provide more information on Jenkins Integration with DevTest Application test.

 

Regards

Jaya

Feb 01, 2017 11:26 AM

Nice Article Vamsi !

 

Regards,

- Ankush

Related Entries and Links

No Related Resource entered.