This guide describes how to deploy complete test environments to Microsoft Azure using the Parasoft service virtualization assets available in the Azure marketplace.

In this guide:

Overview

Parasoft enables you to instantly provision dynamic test environments from a golden template in Microsoft Azure. The test environments deployed to the cloud are disposable, so you can readily destroy them after exercising a your test scenarios. There is no need to share test environments or resources across teams or test phases: the exact environment you need is instantly spun up whenever you want it, then destroyed as soon as you're done with it. Dynamic infrastructures provide advanced flexibility for extreme automation. When you need to scale the environment for performance testing or other use cases, you can do so on demand.

Requirements

  1. An Azure subscription that will allow you to create a deploy a virtual machine from the Azure Marketplace.
  2. Access to http://portal.azure.com and a compatible web browser.
  3. Your own Azure DevOps account with Administrative privileges.
  4. A copy of the ParaBank environment configuration.
  5. Repository server must be running

Licensing

Parasoft offers two licensing options:

  • Bring your own license (BYOL): Unlock Parasoft Service Virtualization with the license purchased directly from Parasoft.
  • On-demand: Immediately start using Parasoft Service Virtualization on an hourly basis.

About Parasoft Artifacts

The following Parasoft artifacts enable you to deploy a Parasoft Service Virtualization VM on Azure and are available from the Azure Marketplace.

Virtualize Server

Parasoft Virtualize Server hosts virtual assets and proxies, which drive Parasoft's service virtualization solution. Virtual assets deployed to the Virtualize server can respond to requests from the application under test. Proxies allow you to dynamically control the configuration of the application environment, such as whether requests from the application under test are being forwarded to a virtual service or real endpoint, without making changes to the application under test.

Continuous Testing Platform (CTP)

CTP is a browser-based interface that enables you to leverage functionality in the Parasoft Virtualize Server. CTP for Azure includes the following modules:

Environment Manager

The Environment Manager module enables team members to build, select, and provision environments. An environment contains representations of the AUT's dependent components set to specific states. For example, an environment may contain a virtual API that simulates network congestion and error responses, a real database, and a virtual mainframe that returns positive responses.

Service Virtualization

The Service Virtualization module is an interface for creating, configuring, and deploying virtual assets to the Virtualize server. Virtual assets send specific responses to requests that meet a set of correlation criteria.

Data Repository Server

The Data Repository Server captures and stores data associated with requests and responses when a virtual asset is created from traffic. When the virtual asset is invoked, it will pull data from the data repository server to construct a response.

Azure DevOps Tasks

Azure DevOps (formerly Visual Studio Team Services) allows you to create projects, manage code, and set up a continuous build and release process. Plugins expand Azure DevOps functionality by integrating with third-party platforms, including Parasoft Service Virtualization.

Installing the Parasoft Continuous Testing Extension for Azure DevOps makes several Parasoft tasks available to add to your pipelines. The Parasoft Deploy Environment task creates a simulated test environment so that the correct data, endpoints, and functionality are always available during a build/release process. The Parasoft Destroy Environment task instantly cleans up the simulated test environment once the build/release process has completed. Both of these steps are available as release tasks in Azure DevOps.

Other tasks include the Execute Job task for running test jobs hosted on the Virtualize server, as well as the Disconnect task for ending the pipeline session with Parasoft CTP.  Refer to the Continuous Testing Extension for Azure DevOps documentation for details about configuring and using the tasks included with the extension.

Refer to the Using Parasoft in Azure DevOps section for details on how to configure Azure DevOps to grab the source code for a demo web application ("Parabank") from the Parabank GitHub repository, build the code on a hosted build machine, and release the resulting .war file to a dedicated Azure VM. It also demonstrates how to use the Parasoft "Deploy" task to provision a simulated test environment needed to test the Parabank application.

Using Parasoft in Azure DevOps

In this section, we'll create a complete continuous delivery pipeline for Parasoft's demo application, Parabank.

  1. A developer checks code into the Github repository.
  2. Azure pulls the Parabank code from GitHub.
  3. Azure DevOps builds Parabank.
  4. Azure DevOps deploys a "release" of Parabank onto a VM in Azure. Simultaneously, we'll call the Environment Manager (EM) module of CTP to provision a virtual environment so that you can run functional tests on Parabank.

Creating a Virtual Machine in Azure

Before we create a project in Azure DevOps, we need to deploy an Azure virtual machine. The machine will serve as the host for CTP and the Parabank demo application. We'll define virtual environments in CTP and deploy them as part of the release process in Azure DevOps.

  1. Log into Azure and click Create a resource to access the Marketplace.



  2. Search for "Parasoft" and click Parasoft Service Virtualization in the search results.



  3. Choose a licensing plan service. In this guide, we'll select Service Virtualization On-Demand, but you can choose the BYOL Service Virtualization option if you already have the applicable license from Parasoft.



  4. Click Create and click the Basics tab.
  5. Choose your subscription option and either create a new resource group or add the new VM to an existing group.



  6. In the Instance Details section, provide a name for the VM and choose a size (DS2_V2 or better is recommended). You can leave the default settings for the rest of the instance details.

  7. Choose your authentication type and provide the necessary authentication details.



  8. Click Review + Create. For this guide, we are going to use the default settings, but you can click Next and make any additional adjustments to the VM.
  9. Review the configuration and click Create when ready. Click on a tab and make any changes if additional adjustments are required.

Opening CTP

Once created, click on the VM to view its details page. Click the on the VM and note the IP address.


Open the IP address in a browser to access CTP. You will be prompted to provide an email address the first time you open the application.


Importing Data into Environment Manager

  1. Click Add System in the Environment Manager toolbar.



  2. Choose Import and browse for the ParaBank.zip file.
  3. Choose AzureServer from the Target server drop-down menu.
  4. Choose localhost:2424 from the Repository server drop-down menu.
  5. Click Import.


When the system is imported, it will be represented as a diagram in the EM workspace. 

Creating the ParaBank Project in Azure DevOps

  1. Log into your Azure DevOps account and click Create project.
  2. Enter Parabank as the project name and click Advanced.
  3. Verify that Git is selected as the version control system and that Agile is selected as the Work item process.



  4. Click Create.

Building the Parabank Project in Azure DevOps

  1. Choose Repo from the project sidebar and click Import.



  2. Choose Git as the Source type and enter http://github.com/parasoft/parabank.git in the Clone URL.
  3. Click Import to finish cloning the Parabank code to your project. You will be redirected to the code editor view when the import is complete.
  4. Choose Pipeline> Builds from the project sidebar and click New Pipeline.



  5. Choose Azure Repos Git and verify that the Parabank project, Parabank repository, and master branch are selected.



  6. Click Continue and apply the Maven template. The Azure DevOps Maven template adds a Pipeline task, Get sources task, and an Agent job task.



  7. Click the Maven pom.xml subtask under the Agent job task and change the value of the Goal(s) field to install.
  8. Disable the Publish to Azure Pipelines/TFS option under the JUnit Test Results section.



  9. Click the Copy Files to subtask and change the value of the Source Folder $(Build.Repository.LocalPath)/target. You should also update the Display name for consistency.
  10. Change the value in the Contents field to */.war.



  11. Choose Save & queue from the Save & queue drop-down menu.
  12. Choose Hosted from the Agent pool drop-down.
  13. (Optional) Add commit comments to document your process.
  14. Click Save & queue when ready.
  15. Click on the link in the confirmation bar to monitor the build, which will take five to 10 minutes to complete.

A .war file will be produced as a result of the build process.

Releasing Parabank

The next step is to release the artifact by deploying it onto a Tomcat server hosted on the Azure machine we created in the Creating a Virtual Machine in Azure section.

Installing Tomcat and Parasoft Continuous Testing Plug-ins

Before releasing, we need to install the Apache Tomcat Deployment and Installing Tomcat and Service Virtualization plug-ins.

  1. Choose Browse Marketplace from the marketplace menu in Azure DevOps.
  2. Search for Parasoft Continuous Testing and click to install.



  3. Return to the marketplace and repeat the process to install the Apache Tomcat Deployment artifact.

Configuring Tomcat for Deployment

The Apache Tomcat Deployment artifact has requirements that require additional configuration on the VM.

  • A user with the Tomcat manager-script role should be enabled.
  • The webapps context.xml file must be modified to enable remote access to the manager application.

In this guide, we will use SSH to connect to the server. You can also click Connect on the VM home page in Azure and click the RDP tab to access a remote desktop configuration.

  1. Open a command prompt and connect to the VM:

    ssh <VM_USER_ID>@<VM_IP>


  2. Navigate to the /usr/local/tomcat/webapps/manager/META-INF directory

    cd /usr/local/tomcat/webapps/manager/META-INF
  3. You may not have permissions to the subdirectories under tomcat and may need to add read, write, execute access. You can change the permissions as you move through each subdirectory or recursively change the permissions.
     

    sudo chmod -R 777 webapps
  4. Edit the context.xml file with a command line editor.

    Vim context.xml
  5. Comment out the following element to enable remote access to the manager application:

    <Context antiResourceLocking="false" privileged="true" >
    <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
    allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> - ->
    </Context>

     

  6. Write the changes and close the file.

You will also need to enable the user and role for scripting access to the manager application.

Navigate to the /usr/local/tomcat/conf directory. You may need to change the permissions to enable access to the applicable subdirectories.

  1. Edit the tomcat-users.xml file with a command line editor

    Vim tomcat-users.xml

     

  2. Add the following user and role configuration to the <tomcat-users> element:

    <role rolename="manager-script"/>
    <role rolename="manager-gui"/>
    <user username="tomcat" password="tomcat" roles="manager-script,manager-gui"/>


    The username and password must both be "tomcat".
     

  3. Write the changes and close the file.
  4. You will need to restart the tomcat server. Navigate to the usr/local/tomcat/bin directory. You may need to change the permissions to enable access to the applicable subdirectories.

Configuring Release Settings

  1. After installing the plugins, return to the Parabank project and click Project settings.
  2. Click Service connections in the Pipelines section and choose Parasoft CTP from the New service connection drop-down menu.



  3. Configure the following settings when prompted:
    1. Server URL: Enter the URL of your instance of CTP on Azure (see Opening CTP). The /em path segment is required.
    2. Username/Password: The default username and password is admin/admin.
    3. Connection name: Specify a name for the connection (e.g., ParasoftCTP).



  4. Click OK when finished. The connection will appear in your Service connections.
  5. Repeat the process and configure a connection for Parasoft DTP if you intend to send Parasoft test execution results to DTP. DTP must be deployed to a publicly-available IP address.

Configuring the Release Pipeline

  1. Choose Pipelines> Builds from the sidebar and click on the build created in the Building the Parabank Project in Azure DevOps section.
  2. Click the Release button and choose Empty job when prompted.



  3. (Optional) Rename the job and close the panel.
  4. Click the Tasks tab and click the add button (+) to add a task to the agent.



  5. Click the Deploy tab and add the Deploy to Apache Tomcat Server and Parasoft Service Virtualization Deploy tasks.



  6. Click on the Deploy to Apache Tomcat Server task and configure the following settings:
    1. Tomcat Server URL: <AZURE_VM_IP_ADDRESS>. Do not include the port number.
    2. Tomcat Manager Username: tomcat
    3. Password: tomcat
    4. WAR file: Browse for the location of the parabank.war file.
    5. Application Context: /
  7. Click on the Parasoft Service Virtualization Deploy task and configure the following settings:
  8. Parasoft CTP Endpoint: Choose the ParasoftEM service endpoint created in the Configuring Release Settings section.
    1. System: ParaBank (the name of the system deployed to CTP in the Creating a Virtual Machine in Azure section).
    2. Environment: Golden
    3. Instance: Negative
  9. Click Save.
  10. (Optional) By default, the configuration will be saved to the All Pipelines directory, but you can specify a subdirectory, as well as add a comment.
  11. Click OK.

Creating a Release

  1. Click Create release.
  2. Verify that the correct artifact is selected and click Create.



    The release will take a few minutes to complete.
  3. Click on the link to your release in the confirmation dialog to view the pipeline.


Once the release has completed and is successful (this may take a few minutes), navigate to http://<VM_IP_ADDRESS>/parabank in your browser. The Parabank application should load
.

Configuring ParaBank to Use Virtualize Proxies

Now that we've provisioned our virtual environment, we must reconfigure the Parabank application to use our proxies, which are endpoints that sit between Parabank and the virtual services it will consume. Proxies can redirect traffic between the AUT and virtual components, including web services, databases, mainframes, and other endpoints. The proxies we configure in this section will redirect Parabank's requests to our virtual services.

  1. Open the ParaBank in your browser http://<VM_IP_ADDRESS>/parabank and click the Admin page link



  2. Enable the SOAP option in the Data Access Mode section
  3. In the Web Service section, enter http://<VM_IP_ADDRESS>:9080/ParabankProxy in the SOAP Endpoint field and http:// <VM_IP_ADDRESS>:9080/LoanProcessorProxy in the Loan Processor Service Endpoint field.
  4. Click Submit.

Verify that ParaBank is using the proxies:

  1. Log into ParaBank with username john and password demo.
  2. Click Request Loan and specify any values for the Loan Amount and Down Payment fields.
  3. Click Apply Now.

The following message indicates that we've successfully configured the correct environment during our release and we have received a response from the virtual environment instance we provisioned.

Provisioning Other Instances

The Golden ParaBank environment includes several environment instances.

  1. Return to Environment Manager and open ParaBank> Golden environment.
  2. Open the instances drop-down menu to view the available instances.



  3. Note the instance you want to provision and return to the release definition.
  4. Edit the Deploy task with the name of the instance you want to deploy.
  5. Remove the initial Deploy to Apache Tomcat step. This saves time and prevents you from having to reconfigure Parabank's endpoints each time Parabank redeploys.

Using the Parasoft Deploy Task in a Real Workflow

In this guide, we've executed the Deploy Parasoft task during separate release executions. This made it possible for the user to manually go into Parabank and witness the change in behavior after we deployed a certain virtual environment.

In a real use case, it's likely that a Deploy task would be utilized to create an appropriate environment for an automated test to execute. We'd then execute a Destroy task during the same workflow in order to "clean-up" the service virtualization engine after test execution. It's possible that we may iteratively provision and destroy several virtual environments in a release as we execute different categories of tests.

Creating Virtual Assets in Azure

In this section, we'll go through the process of creating a simple virtual service (also called a PVA or Parasoft Virtual Asset) from a sample response using Parasoft and Microsoft Azure. We'll then consume the virtual response through the Parabank demo application.
If you have not already done so, follow the instructions in the Creating a Virtual Machine in Azure chapter to create the virtual machine on Azure before proceeding.

  1. Open CTP in your browser and choose Service Virtualization from the applications drop-down menu.



  2. Choose Create Virtual Asset from the actions menu.



  3. Rename the asset to StaticVirtualAsset and verify that Empty is selected from the Create drop-down menu.



  4. Click Create Asset. The asset is just a node on the Virtualize server at this point. We'll need to add a message responder, which is a component that analyzes an incoming request and provides a response if the incoming message matches a set of criteria. Make a note of the HTTP Endpoint address.



  5. Choose Add Literal Message Responder from the actions drop-down menu.



  6. Rename the responder to SimpleResponder and choose XML from the format drop-down menu.



  7. Copy and paste the following SOAP response into the input field.

    <?xml version="1.0" encoding="UTF-8"?> 
     <soap:Envelope 
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
     <soap:Body> 
     <ns2:requestLoanResponse xmlns:ns2="http://service.parabank.parasoft.com/"> 
     <ns2:loanResponse> 
     <responseDate>2019-01-01T12:33:47.076-07:00</responseDate> 
     <loanProviderName>Wealth Securities Dynamic Loans (WSDL)</loanProviderName> 
     <approved>false</approved> 
     <message>error.insufficient.funds.for.down.payment</message> 
     </ns2:loanResponse> 
     </ns2:requestLoanResponse> 
     </soap:Body> 
     </soap:Envelope>

     

  8. Click Save. This response will be sent for all requests because we have not configured the criteria for correlating specific responses to specific requests.

Configuring the AUT to Use the Virtual Asset

We built ParaBank with an administration page to more easily facilitate demonstrations. In a real-world scenario, you may need to edit one or more configuration files associated with your application under test.

  1. Open ParaBank (http://<VM_IP_ADDRESS>/parabank) and click Admin Page.
  2. In the Web Service section, enter http://<VM_IP_ADDRESS>:9080/StaticVirtualAsset into the Loan Processor Service Endpoint field.
  3. Click Submit.

Invoking the Virtual Asset

  1. Log into ParaBank and choose Request Loan.
  2. Enter any amount for the loan and down payments.
  3. Click Apply Now. The response we just created will appear.

Reconfiguring the Virtual Asset

  1. Return to CTP and open the SimpleResponse virtual responder.
  2. Edit the SOAP response and click Save. For example, you could change the <approved> element to true or change the name of the loan provider.
  3. Request a loan in Parabank again. Your loan will now be approved.

Learning More

For additional details about building virtual assets, see the "Service Virtualization" section in the CTP user guide. The online documentation, as well as API reference, is available from help menu (question).

  • No labels