Creating a Virtual Service
In BlazeMeter, you can create a virtual service from transactions, from a recording, or from a template.
Use one of the following ways to create Virtual Services:
- From Transactions
- From Recording
- From Template
After creating virtual services, set up transactions:
- Complete the configuration of your Virtual Service
- Add/remove transactions and define parameters
- Modify transactions in a running virtual service
- Add transactions to Services
- Define the priority of multiple matching transactions
After setting up transactions, configure optional properties:
Create a New Service from Transactions
In BlazeMeter, a "Service" is the representation of the underlying live service, and it serves as a container for Transactions. You first create a Service, and upload Transactions into the Service.
Having a least one Service with transactions is a prerequisite for creating a virtual service. If you already have a Service, jump directly to Create a Virtual Service from an Existing Service.
Follow these steps:
- Navigate to the Service Virtualization tab and click Virtual Services.
- In the Virtual Services tab, click the Plus button to create a virtual service, and select Create from Transactions.
A new row is added to the top of the Virtual Services list. - Enter a name for the virtual service in the Name field.
- Click the arrow next to the virtual service name to expand the details for the virtual service.
- (Optional) Enter a Description for your virtual service.
- (Optional) Select a Configuration. If needed, define attribute-value pairs for your environment variables on the Configurations tab.
- (Private Location only) Under Create Log, enable or disable logging on the Private Location. For more information, see Running Virtual Services on Private Locations.
-
Drag your transaction file into the upload area, or click the Upload area to browse to the file. Select a file that contains the transactions for your virtual service.
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 you want to add these transactions to. 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.
- Or create a new service:
- Click Add Service.
- (Optional) To assign one or more tags, 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.
Create a Virtual Service from an Existing Service
In BlazeMeter, a "Service" is the representation of the underlying live service, and it serves as a container for the Transactions. In this scenario, you create a virtual service by selecting an existing service that already contains the transactions that you need for your virtual service.
Follow these steps:
- Navigate to the Service Virtualization tab and click Virtual Services.
- In the Virtual Services tab, click the + button to create a virtual service, and select Create from Transactions.
A new row is added to the top of the Virtual Services list. - From the Service drop-down list, select the service that contains the Transactions that you need for your virtual service.
Create Virtual Services Using the BlazeMeter Proxy Recorder
You can record a series of interactions from your browser, capture those interactions as transactions, and create a virtual service based on those transactions. Use the BlazeMeter Proxy Recorder to record the interactions.
Follow these steps:
- Navigate to the Service Virtualization tab and click Virtual Services.
- In the Virtual Services tab, click the + button to create a new virtual service, and select Create from Recording.
The BlazeMeter Recorder page opens in a separate tab. - Follow the steps (starting with Step 3) in Creating the Proxy Recorder to create your proxy for recording.
- Follow the steps for setting up recording based on your operating system:
- Click the Record button and record the necessary interactions within your application.
- Click Pause when finished.
- Click Virtual Service to export the recording to a virtual service.
This creates a virtual service under the selected Service with all of the recorded Transactions assigned to it. - Disable any proxy settings you had to enable to create the recording.
Create a Virtual Service from a Virtual Service Template
A requirement for this way of creating virtual services is that you create 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.
Other template actions include:
- Assign a template to a virtual service
- Create a Virtual Service template from a virtual service
For more information, see Creating a Virtual Service Template.
Complete the Configuration of your Virtual Service
After you have created a virtual service using one of the above methods, complete its configuration.
- Enter a name for the virtual service in the Name field.
- Click the arrow next to the virtual service name to expand the details for the virtual service.
- (Optional) Enter a Description for your virtual service.
- (Optional) Select a Configuration. If needed, define attribute-value pairs for your environment variables on the Configurations tab.
- (Private Location only) Under Create Log, enable or disable logging on the Private Location. For more information, see Running Virtual Services on Private Locations.
- In the Location drop-down list, select the location that you want to deploy your virtual service to. Select from the available Google Cloud Platform locations (US East or EU West) depending on your location. Or select a Private Location.
- Select either HTTPS or HTTP from the Endpoint drop-down list. The default is HTTPS.
- (Optional) If you plan to run the virtual service in a private location, select a preferred port in the Port field.
For more information about preferred ports, see Select a Preferred Port.
Add Transactions to the Service
To add Transactions to a Service, you can upload additional Transactions directly on the Service Virtualization tab without having to switch tabs. Drop a file into the upload area or click the Plus button to create new Transactions. For more information about supported transaction file formats, see Adding Transactions.
Include/Exclude Transactions in a Virtual Service
After you have added transactions to the Service and have created a virtual service, the next step is always to select the transactions for this virtual service and define their parameters.
On the Transactions tab:
- Select transactions that you want to include. You have several options:
Search and filter transactions in the columns by entering a tag or search text.
To select all transactions visible in the column (not all Transactions in the service), click the check box in the column header.
- Or, manually select checkboxes in the columns.
- Move selected transactions from the Other Transactions in Your Catalog column to the Transactions in This Virtual Service column.
You have several options how to do this:- Click the Right Arrow to move selected transactions from Other Transactions in Your Catalog column to the Transactions in This Virtual Service column. Select checkboxes in the Transactions in This Virtual Service column and click the Left Arrow to remove these transactions from the virtual service.
Use the quick action to move selected 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, click the corresponding Remove this transaction from the Virtual Service icon in the right column.
- Click the Right Arrow to move selected transactions from Other Transactions in Your Catalog column to the Transactions in This Virtual Service column. Select checkboxes in the Transactions in This Virtual Service column and click the Left Arrow to remove these transactions from the virtual service.
- (Optional) In Transactions in This Virtual Service column, expand each transaction and define a Priority to control the matching order when a request matches multiple transactions. The transaction with the lowest priority number matches first. For details, see Priority of Multiple Matching Transactions in a Virtual Service.
On the Parameters tab:
- (Optional) In the Think Time section, define an artificial delay between the request and the response. For more information, see Simulating Irregular Response Latencies.
Default: "No Delay". - (Optional) In the No Matching Requests section, choose the correct logic for when a request against the virtual services does not match any of the provided transactions. The request can either throw an error or be redirected to the live service.
Default: Return no match found (404) - (Optional) In the Proxy section, define a proxy to connect to the live system endpoint.
Default: No proxy- Proxy URL
- Username
- Password
- Certificate — Upload or select a certificate needed for the connection.
- No Proxy — Provide a comma-separated list of URLs to exclude from this proxy.
- (Private Locations/Docker only) Select an SSL Authentication. For more information, see Running Virtual Services on Private Locations.
- Click Save.
Your virtual service is saved and added to the list of available virtual services.
The virtual service is not active until you run it.
Click Run Virtual Service to run it. For information about the next steps, see Running a Virtual Service.
Modify Transactions in a Running Virtual Service
You can add and remove transactions or modify existing transactions without having to restart the virtual service.
- To add a transaction to or remove it from the virtual service, update the virtual service's transaction list in the virtual services tab and then click the Update button. When you run the test again, the changes will be reflected.
- To modify a transaction, make the changes and click Save in the transaction. Then click the Update button in the virtual services tab. When you run the test again, the changes will be reflected.
Define Priority of Multiple Matching Transactions in a Virtual Service
When you test against a virtual service, the virtual service first attempts to match incoming requests against any of its Transactions. The Transactions can be explicitly spelled out requests or regular expressions. When a virtual service receives a request that matches multiple Transactions, the virtual service chooses the Transaction with the lowest value in the Priority field.
Examples:
- Say you have a virtual service for a service that searches by zip code with two transactions. Transaction A matches a parameter value of 75024, and Transaction B matches any five-digit number. You want the Transaction with the more specific matching criteria (Transaction A) to have the higher priority so that it matches first, and the broader matching criteria (Transaction B) shall only match if the specific zip for Transaction A is not entered, so you give it lower priority.
- After importing 100 transactions, they are all assigned the same default priority of 10. Fifteen of them are generic transactions that should be matched only after the more specific eighty five are matched. You don't want to have to manually change the priority level of eighty five transactions to 9. In this case, it's quicker to give the fifteen generic transactions a priority of 20, below the default of 10.
Consider this matching logic when determining which Transactions to add to a virtual service, and whether one or more virtual services are required to meet your testing requirements.
Every transaction is added with the default priority level of 10.
-
To have a Transactions match first, set its priority to 1.
-
To have a Transactions match before another, set its priority to a lower number.
-
To have a Transactions match after another, set its priority to a higher number.
-
To have a Transactions match last, set its priority to 20.
You can assign the same priority to multiple transactions. Therefor it can happen that multiple matching Transactions have the same priority. In this case, the virtual service chooses the most recent Transaction first (the one with the highest Transaction ID number). To have fine control over the priority over default transactions, assign them unique priorities. Unique priorities use an index counter that defines the order without ambiguity.
To assign unique priorities:
-
Add transactions that can match.
-
Enable Unique Priorities.
The Customize Unique Transaction Priorities window opens and a table lists all included transactions. -
Arrange the rows in order of highest to lowest priority. You can use the following methods:
-
Click the handle and drag a transaction up to increase its priority.
-
Click the handle and drag a transaction down to decrease its priority.
-
To reorder a transactions to be first, click Move Transaction to Beginning.
-
To reorder a transactions to be last, click Move Transaction to End.
-
To reorder multiple transactions, enable their checkboxes and click the Move Transaction to Beginning or Move Transaction to End button (respectively) above the table.
-
To reorder priorities after Unique Priority has been enabled, click the Customize button.
Configure Runtime Properties
(Optional) Go to Virtual Services and open the Virtual Service tab to configure optional runtime properties.
-
Show Logs
-
Show Logs - Choose whether you want to capture runtime logs.
-
Show Logs Max Size - Specify the maximum amount of logs to be captured. Enter a number between 0 and 100.
-
-
Inspection Data
-
Inspection Data - Choose whether you want to capture inspection data. If you enable it, configure the following fields:
-
Inspection Data Max Request Size - Enter a number between 0 and 100.
-
Inspection Data Max Requests Per Second - Enter a number between 0 and 5.
-
Inspection Data Max Actions Per Second - Enter a number between 0 and 50.
-
Inspection Data Max Body Size - Enter a number between 0 and 1024000.
-
-
Matcher Logs
-
Console Matcher Logs Enabled
-
Show Logs Matcher Logs Enabled
-
Matcher Logs Cache Max Size - Enter a number between 1 and 1000.
-
-
More...
-
Jetty Container Threads - (Optional) Define the number of threads in the Eclipse Jetty container. Enter a value between 1 and 1000.
-
Jetty Acceptors - (Optional) Define the number of acceptors in the Eclipse Jetty container. Enter a value between 1 and 1000.
-
Request Timeout - Enter a number between 0 and 60000 milliseconds.
-
Group multiple Virtual Services under a single endpoint
(Optional) If you are running multiple virtual services across different Services, and the requirement arises that you need to run them under a single endpoint and port, you can group them.
- Go to Virtual Services and open the Virtual Service Groups tab.
- Click the blue Plus button to create a Virtual Service Group.
- Give the group a name and description.
- Select a Location.
- Select an Endpoint Protocol.
- Define an Endpoint Port.
- (Optional) Define tags.
- On the Virtual Services tab, click Assign Virtual Service to add one or more virtual services to the group.
- On the Parameters tab, optionally, configure SSL Authentication.
Now, under Actions, click the green Run button to run this group under a single endpoint.