Creating a Virtual Service
In BlazeMeter, you can create a virtual service from transactions, from a recording, or from a template. in BlazeMeter, a "Service" is the representation of the underlying live service, and it serves as a container for the Transactions.
Use one of the following ways to create Virtual Services:
- From Transactions
- From Recording
- From Template
After creating the virtual service, set up transactions:
- Add/remove transactions and define parameters
- Modify transactions in a running virtual service
- Add transactions to Services
- Define the priority of multiple matching transactions in a virtual service
Manage Virtual Services:
- Group multiple Virtual Services under a single endpoint
- Rename a Virtual Service
- Move a Virtual Service
Configuration for Private Locations:
Create a Virtual Service from a New Service
In this scenario, you first create a new Service, and you upload transactions from a supported file type to the Service. Then you create a virtual service from the Service.
If you already have an existing Service contain transactions, see 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 + 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 virtual service name 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. 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. If enabled, it will create one log file per virtual service on the Private Location, or if the file exists, append the log.
-
Drag your transaction file into the upload area, or click the Upload area to browse to the file. This file should contain all of the transactions that you want to use 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.
- In the Service drop-down list, choose the Service you just selected or created.
- 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.
Create a Virtual Service from an Existing Service
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 new 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.
- Select the Service that contains the Transactions that you need for your virtual service.
- Select the location that you want to deploy your virtual service to from the Location drop-down list. 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. - 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.
- (Private Location only) Under Create Log, enable or disable logging on the Private Location. If enabled, it will create one log file per virtual service on the Private Location, or if the file exists, append the log.
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
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.
Add/Remove Transactions
After you have created a virtual service, the next step is always to define its transactions and 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:
No Authentication (default)
1-way SSL
2-way SSL
Select an existing Keystore or upload a new one. Provide the Keystore Password and the password used to access individual keys in the keystore.
(Optional) To define how to identify during SSL/TLS communication using an alias for aprivate key entry
defined in your keystore, select the Alias and provide an Alias Password. - 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.
Add Transactions to the Service
To add Transactions to a Service, you can upload additional Transactions 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.
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.
Group multiple Virtual Services under a single endpoint
If you have 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.
Rename a Virtual Service
To rename a virtual service, stop it if it is running. Now you can edit the display name field.
Move a Virtual Service
You can change the location of a virtual service from one private location to another. To move a virtual service, stop it if it is running. Now you can select a new location from the drop-down. Moving deploys the virtual service on the new private location. The existing container, its logs, etc. from the old location are removed.
(Private Locations/Docker) Select a Preferred Port
If you plan to run the virtual service in a private location and you are creating a Docker-based transaction virtual service, you can define a preferred port. If the port is available, it will be assigned to the virtual service.
- If you leave the Port field blank, a port is chosen from the range defined for the Private location. For more information, see Setting Port Range on Your Agent.
- If the preferred port is outside of the defined port range, a notification message is shown and a new port within the defined range has to be entered.
- If an existing service is running on the preferred port already, a notification message appears when you run the virtual service. BlazeMeter then selects the first available port within the defined range.
To update the preferred port for a virtual service running in a Docker-based private location, stop the running virtual service, update the existing preferred port to the new port number, and then run the virtual service again. If the port is available, it will be assigned to the virtual service.
(Private Locations/Kubernetes) Rules for Endpoints Generated for Kubernetes Virtual Services Deployment
The URL format is the following:
http(s)://(mock-name[40])(serviceid[9])-<port>-<namespace>.<sub-domain>
- Virtual Service Name
First 40 lowercase alpha numeric characters of the virtual service name. - Service ID
ID associated with the service name. Service ID is used in the endpoints that are generated after you deploy your virtual service. When you know your service ID, you can predict the format of your virtual service endpoint. - Port
8080 for transaction virtual services. - Namespace
Kubernetes namespace - Sub-domain
Configured as a part of an agent set up.
Virtual Service names can be more than 40 characters. If the first 40 characters of the name conflict with any other existing virtual service name, a unique ID is added to the endpoint in the following format:
http(s)://(mock-name[40])(some uid[4])(serviceid[9])-<port>-<namespace>.<sub-domain>
In a very rare case for virtual service deployments in a private cloud: If you specify a virtual service name to be a lowercase alphanumeric string with 128-character length, it is treated as an encoded string and the old format for endpoints is used to support backward compatibility.
The old format for Transaction virtual services is the following:
http(s)://servicemock<mock_id>-8080-<k8s_namespace>.<sub-domain>