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
- Create a Virtual Service from a Virtual Service Template
- Assign a Template to a Virtual Service
- Create a Virtual Service Template from a Virtual Service
Create a Virtual Service Template
Follow these steps:
- Log into your BlazeMeter account.
- On the Service Virtualization tab, click Virtual Services.
- Go to the Virtual Service Templates tab and click the Add button.
- 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. - 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:- Click Select Service.
- Enter the name for your new Service and click Add Service.
- Click the arrow to the left of the Template name to edit Template details.
- Enter a description for the Template.
- (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.
The Import Transactions dialog opens. - Select the Service that you specified in the Service field next to the Template name.
-
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.
- Click Import.
The imported Transactions appear in the Other Transactions in Your Catalog pane. - 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.
- (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.
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. - Click the Parameters tab.
- 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.
- 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.
- 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.
- Go to the Virtual Service Templates tab.
- In the Actions column, click the Create Virtual Service button.
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.
To assign a Template to a virtual service:
- Navigate to a virtual service and in the Actions column, click the icon for Assign Virtual Service Template from this Virtual Service:
- 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.
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:
A template is created with the same configuration as the virtual service and you can find it in the Virtual Service Templates tab.