Creating a Virtual Service Template

Virtual Service Templates are common collections of Transactions and Parameter selections that you can reuse when you need to test against those Transactions. For example, for a login service, you might create a Template that includes a few Transactions required for negative testing. Then, when you need to test those scenarios, you can quickly provision a virtual service based on that Template to test with.

Templates override the Transactions that are directly in a virtual service, and are meant to be a more persistent way to add commonly grouped Transactions to a virtual service on the fly.

Create a Virtual Service Template

Follow these steps:

  1. Log into your BlazeMeter account.
  2. On the Service Virtualization tab, click Virtual Services.
  3. Go to the Virtual Service Templates tab and click the Add button.
    templates
  4. Give the Template a meaningful name.
    Note: It is important to give meaningful names and descriptions, because when testers are using the Virtual Services Configuration to add virtual services to tests, they need to understand what might be relevant to their tests based on these values only.
  5. Select or create the associated Service. The Service is a representation of the underlying live service, and it serves as a container for the Transactions you will upload. If an existing Service contains Transactions that are needed for this virtual service, select the existing Service.
    To create a new Service:
    1. Click Select Service.
    2. Enter the name for your new Service and click Add Service.
  6. Click the arrow to the left of the Template name to edit Template details.
  7. Enter a description for the Template.
  8. (Optional) If the Transactions needed for the Template don't yet exist, drag a supported file type into the upload box. If the Transactions already exist in the Service you selected, skip to Step 10.
    Note: If you want to upload multiple Swagger files using a zip file, the main file in the zip file must be named index.json or index.yaml for the upload to work.
    file upload
    The Import Transactions dialog opens.
    import dialog
  9. Select the Service that you specified in the Service field next to the Template name.
  10. If you want to assign one or more tags to these transactions, type the tag name(s) in the Tags field and press Enter.
    • Tags make Transactions easier to identify, especially within a large Service. You can provide tag definitions here to apply the defined tags to all imported Transactions. Or you can define tags at the Transaction level after import.
    • To enter multiple tags, press Enter after each tag name.
  11. Click Import.
    The imported Transactions appear in the Other Transactions in Your Catalog pane.
  12. Select the Transactions to include in the Template, and click the right arrow icon to move them to the Transactions in this Virtual Service Template pane.
    You can use a quick action to move transactions with a single click. Click the Include this transaction in the Virtual Service icon in the left column. To remove a transaction from the virtual service, you can click the Remove this transaction from the Virtual Service icon in the right column. Click to enlarge the screenshots.
    a quick way to include transactions

    a quick way to remove transactions
  13. (Optional) Expand each Transaction in the Virtual Service Template and enter values in the Priority field to control the matching order to follow when a request matches multiple Transactions.
    priority value transaction template
    The Transaction with the lowest number matches first. By default, all Transactions have the same Priority value, and a multiple matching scenario matches on the Transaction with the highest ID number.
    Setting a priority for a Transaction only applies to that Transaction within the specific Template. In other virtual services or Templates, the Transaction may have a different priority value.
  14. Click the Parameters tab.
  15. In the No Matching Requests field, choose the correct logic for when a request against the virtual service does not match any of the provided transactions. The request can either throw an error or be redirected to the live service.
  16. Set the Think Time in milliseconds to control the amount of time spent between when the virtual service receives a request and returns a response. The default is 0, but you can update the field to simulate delayed responses of a fixed length in milliseconds, or define a randomized Think Time with Lognormal or Uniform distribution within bounds.
  17. Click Save.

Create a Virtual Service from a Virtual Service Template

At any time after saving the Template, click Create Virtual Service to the right of the Template name to dynamically provision a virtual service that includes the transactions in the Template.

  1. Go to the Virtual Service Templates tab.
  2. In the Actions column, click the Create Virtual Service button.
    create virtual service from template

Your virtual service is created and you can find it in the Virtual Services tab.

Assign a Template to a Virtual Service

You can assign a Template to a new or existing virtual service at any time.

actions column

To assign a Template to a virtual service:

  1. Navigate to a virtual service and in the Actions column, click the icon for Assign Virtual Service Template from this Virtual Service:
    the Assign action icon
  2. Select the Template to assign and click Apply.

The Template is assigned to the virtual service. If the virtual service already contained Transactions, they are overwritten by the Transactions in the Template.

A template can be assigned to a virtual service if the service is stopped or running. In either case, the transactions in the virtual service will be overwritten with the transactions from the template assigned.

Create a Virtual Service Template from a Virtual Service

After you create a virtual service with Transactions, you may realize that you need to reuse that virtual service at a later date. Create a Template from the virtual service to preserve its configuration for future use.

the actions column in the UI

In the Actions column for the virtual service, click the icon for Create Virtual Service Template from this Virtual Service to dynamically provision a virtual service that includes the transactions in the Template:

the Create Template action icon

A template is created with the same configuration as the virtual service and you can find it in the Virtual Service Templates tab.