Share this page

# Continuous integration

The Application Automation Tools plugin for the Jenkins continuous integration server provides a mechanism for incorporating virtual services into a build script. This open source plugin enables you to add steps to your Jenkins build job to:

- deploy and undeploy virtual services
- start and stop simulation and learning
- export virtual services

This section describes several testing scenarios that you can automate using Jenkins.

Note: The Application Automation Tools Plugin for Jenkins is a java application that can be run on a Jenkins server running on Windows or on any Linux platform.

In this topic:

## General prerequisites

Before you begin setting up a job in Jenkins, make sure to:

- Create a virtual service. In the Service Virtualization Designer, create or open the virtual service that you want to use in your build job.
- Deploy the virtual service. Try to deploy the virtual service to the target Service Virtualization Server to verify that all required agents are ready.
- Use source control. It is recommended to commit virtual service files to source control to enable easy distribution to build machines.

Back to top

## Configure the connection to your Service Virtualization Server

You can configure connections to multiple Service Virtualization Servers in Jenkins. The Servers are then available for selection when you create build steps.

This section describes how to configure the Jenkins connection to your Service Virtualization Server.

To configure the connection:

1. Install the plugin. Select Manage Jenkins > Manage Plugins and choose the "Micro Focus Application Automation Tools" plugin.

2. Go to the Jenkins Server home page and click Manage Jenkins in the left pane.

3. In the Manage Jenkins page, click Configure System.

4. In the Configuration tab, scroll down to the Service Virtualization section.

5. Click Add SV Server.

6. Specify the Service Virtualization Server details. The Server URL must be in the following format:

       <scheme>://<Service Virtualization Server IP or hostname>:<port number>/management

   For example: `https://agata:6085/management`

7. Verify the connection.
8. Optionally, add additional servers.

Back to top

## Use a virtual service in a Jenkins test

A virtualized service may be very useful when your tests need to use services which are not available in your testing environment. You can use Jenkins to utilize the virtual services in your tests. The following build steps are available:

- Deploy Virtual Service
- Undeploy Virtual Service
- Change Mode of Virtual Service
- Export Virtual Service

Create a build job in Jenkins

1. Create a new free-style project.
2. Specify source control options to checkout your tests and virtual service files.

3. Add the SV: Deploy Virtual Service build step to deploy the virtual service on the Service Virtualization Server.

   Specify the Service Virtualization project path relative to the checkout directory. You can optionally choose to specify a specific virtual service from the project, if you do not want to deploy all the virtual services.

4. Run the build to verify the source control connection, paths, and the connection to the Service Virtualization Server.

   Review the build log to confirm the names and IDs of the deployed virtual services and the simulation models that were used. The names or IDs are also needed for setting up the subsequent steps in the build job.

   Example:

5. Add the SV: Change Mode of Virtual Service build step to change the virtual service mode to Simulate. Specify the Service Virtualization Server, virtual service, and data and performance models to use.

6. Add a build step to run your Jenkins tests that are using the virtual service.
7. At the end of the job, add the SV: Undeploy Virtual Service build step to undeploy the virtual service from the Service Virtualization Server.

Back to top

## Automate the update of virtual service models

This section describes how to set up a Jenkins job to automatically update a simulation model (data or performance) in your service. A virtual service with a periodically updated model can be used as a fresh backup of the real service in the event of unexpected failure.

Prerequisite: Prepare the virtual service.

Create or open a virtual service and create a simulation model. The data model can be empty.

Create a build job in Jenkins

1. Perform steps 1-4 of Use a virtual service in a Jenkins test.
2. Add the SV: Change Mode of Virtual Service build step to change the virtual service mode to Learn.
3. Add a build step to run your Jenkins tests that are using the virtual service, in order to record data.

4. Add the SV: Export Virtual Service build step to export the virtual service. The export step creates a new folder named according to the virtual service name in the target directory that you specify .

   Note: Before export, the virtual service must be switched from Learning to Stand-By mode to stop learning and generate the updated simulation models. Make sure to select the option to switch the service to Stand-By mode before export.

5. Add the SV: Undeploy Virtual Service build step to undeploy the virtual service from the Service Virtualization Server.
6. Add a post-build action to select a storage option for the exported service. For example, you can use the built-in Jenkins Archive the artifacts option to download the updated data model files. Alternatively, zip the files using the Compress Artifacts plugin, check the files back in to source control, upload the files via FTP, and so on.

Back to top

## Use a virtual service in a LoadRunner Professional scenario

This section describes how to setup a Jenkins job for a LoadRunner Professional scenario that is using a virtual service.

Prerequisite: Prepare the virtual service

1. Create or open a virtual service in the Designer. Prepare simulation models to use in the LoadRunner Professional scenario.
2. Try to deploy the virtual service on the Service Virtualization Server to verify the settings.
3. Commit all virtual service files to your version control system or place them on shared storage so they are accessible by the Jenkins job.

Prerequisite: Prepare the LoadRunner Professional script

1. In the Virtual User Generator (VuGen), create a script that calls the virtual service.
2. In LoadRunner Controller, create a scenario that consumes the script from the previous step.
3. In the Design tab of the LoadRunner Professional scenario, open the Service Virtualization Setup dialog box .
4. Enter the management endpoint (URL) of the Service Virtualization Server, and related credentials, to view the list of deployed services on your Service Virtualization Server.
5. Select your virtual service, models, and virtual service mode.
6. Try to run the LoadRunner scenario from LoadRunner Controller to verify the settings.
7. Commit all LoadRunner scenario files to your version control system or place them on shared storage so they are accessible by the Jenkins job.

Create a build job in Jenkins

1. Perform steps 1-4 of Use a virtual service in a Jenkins test.

1. Add the Run LoadRunner script build step to execute the LoadRunner Professional scenario, as described in the plugin documentation. This step runs the scenario, and switches your virtual service to Simulate mode, using the simulation models defined in the LoadRunner Professional scenario.
2. Add the SV: Undeploy Virtual Service build step to undeploy the virtual service from the Service Virtualization Server.
3. Add a post-build action to publish the LoadRunner Professional test results.

Back to top

## Use Service Virtualization build steps in a Jenkins pipeline script

The functionality of the Service Virtualization build steps in the Application Automation Tools Plugin is also available for use in Jenkins Pipeline Scripts.

This example presents a commented script that uses all four of the Service Virtualization build steps from the plugin.

    node {
       // name of Service Virtualization Server configuration defined
       // in Jenkins Configuration section
       def serverName ='localhost'
       def virtualServiceUrl = 'http://localhost:6070/OlympicMedalSummaryService'

       stage 'Checkout'
       checkout scm: [$class   : "SubversionSCM",
    		locations: [[remote       :
    	'https://svnserver/svn/Demo/OlympicMedalSummaryRestDemo',
    		credentialsId: 'SvnCreds', local: 'Demo']]]
       // Try to undeploy service first to be sure that following deployment
       // will not fail
       stage 'Undeploy service from server'
       svUndeployStep continueIfNotDeployed: true, force: true, serverName: serverName,
    	serviceSelection: [projectPassword: '', selectionType: 'SERVICE',
    		service: 'OlympicMedalSummaryService']

       stage 'Deploy service'
       svDeployStep firstAgentFallback: true, force: false, projectPassword: '',
    	projectPath: 'Demo\\Simulation\\OlympicMedalSummaryService.vproj',
    	serverName: serverName, service: ''

       // Switch service to learning mode using empty 'AutoUpdate DM'
       stage 'Switch service to Learning'
       svChangeModeStep force: false, mode: 'LEARNING', serverName: serverName,
    	dataModel: [dataModel: 'AutoUpdate DM', selectionType: 'BY_NAME'],
    	performanceModel: [selectionType: 'NONE'],
    	serviceSelection: [projectPassword: '', selectionType: 'SERVICE',
    		service: 'OlympicMedalSummaryService']

       // Compile test application
    	stage 'Build test client'
    	bat 'msbuild Demo\\Application\\OlympicMedalSummaryRestDemo.csproj'

       // Run test application against virtual service in learning mode.
       // This application contains client & server in one executable.
       // Output of client thread is prefixed with "c:"
       // and output of server thread is prefixed with "s:".
       // We should see server & client outputs in log because virtual service is in
       // learning mode and forwards real service.
       stage 'Run test client'
       bat 'Demo\\Application\\bin\\Debug\\OlympicMedalSummaryRestDemo.exe ' + virtualServiceUrl

       // Switching service from learning to simulation mode updates data model.
       stage 'Switch service to Simulating'
       svChangeModeStep force: false, mode: 'SIMULATING', serverName: serverName,
    	dataModel: [dataModel: 'AutoUpdate DM', selectionType: 'BY_NAME'],
    	performanceModel: [selectionType: 'NONE'],
    	serviceSelection: [projectPassword: '', selectionType: 'SERVICE',
    		service: 'OlympicMedalSummaryService']

       // Run test application against virtual service in simulation mode
       // We should see only client outputs in log because virtual service
       // simulates responses without touching real service.
       stage 'Run test client'
       bat 'Demo\\Application\\bin\\Debug\\OlympicMedalSummaryRestDemo.exe ' + virtualServiceUrl

       // Export of updated data model.
       stage 'Export service'
       svExportStep cleanTargetDirectory: true, force: false, serverName: serverName,
    	serviceSelection: [projectPassword: '', selectionType: 'SERVICE',
    		service: 'OlympicMedalSummaryService'],
    	switchToStandByFirst: true, targetDirectory: 'freshModel'

       // Undeploy virtual service to release server resources at the end of test.
       stage 'Undeploy service from server'
       svUndeployStep continueIfNotDeployed: true, force: true, serverName: serverName,
    	serviceSelection: [projectPassword: '', selectionType: 'SERVICE',
    		service: 'OlympicMedalSummaryService']
      }

Back to top

https://admhelp.microfocus.com Service Virtualization 8942
Tips to improve your search results... Service Virtualization Help Center SV Help 5.4-5.4.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: