In BlazeMeter, you can create a Mock Service from transactions, from a recording and from a MAR file.
- From Transactions
- From Recording
- From MAR file
If you want to add more Transactions to the Service, you can upload additional Transactions without having to switch tabs. As you create your Mock Service, you can select the specific Transactions that you want to include and then run them to make them available for tests.
Transactions in Mock Services
When you test against a Mock Service, the Mock Service attempts to match an incoming request against any of its Transactions. The Transactions can be fully formed requests or regular expressions that an incoming request will match against. When a Mock Service receives a request that would be a match with multiple Transactions, the Mock Service matches against the Transaction with the lowest number in the Priority field. For example, if you have an incoming request matching multiple Transactions, the Transaction with a Priority value of 1 is picked up first if it matches that request. If multiple Transactions have the same priority, the Mock Service matches the most recent Transaction (with the highest Transaction ID number).
Consider this matching logic when determining which Transactions to add to a Mock Service, and whether one or more multiple Mock Services are required to meet testing requirements. For example, assume you have a Mock Service for a service that searches by zip code with two transactions: Transaction A matches on a parameter value of 75024, and Transaction B matches any five-digit number. You may want the Transaction with the more specific matching criteria (Transaction A) to have the higher priority value so that it matches first, and the broader matching criteria (Transaction B) is only matched if the specific zip for Transaction A is not entered.
Note: For more information about supported transaction file formats, see Adding Transactions.
Create a Mock 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 Mock Service from the newly created service.
If you have an existing service with transactions already, see Create a Mock Service from an Existing Service.
Follow these steps:
- Navigate to the Mock Services tab and click Mock Services.
- In the Mock Services section, click the + button to create a new Mock Service, and select Create from Transactions.
A new row is added to the top of the Mock Services list. - Enter a Mock Service name in the Name field.
- Click the arrow next to the Mock Service name to expand the details for the Mock Service.
- Enter a description for your Mock Service.
- Drag your transaction file into the upload area.
- This file should contain all of the transactions that you want to use for your Mock Service.
- 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.
- Tip: You can also click the Upload area to browse to the file.
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 Mock Service, select the existing Service.
- Or, create a new service:
-
- Click Add Service.
- (Optional) T o assign one or more tags, type the tag name(s) in the Tags field and press Enter.
Tip: 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 Mock 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 Mock Service in a private location, select a preferred port in the Port field.
For more information about preferred ports, see Select a Preferred Port. - In the Transactions tab, select the check box for each Transaction that you want to include in your Mock Service and click the arrow to move them from the Other Transactions in Your Catalog column to the Transactions in This Mock Service column.
Tip: You can use a quick action to move transactions with a single click. Click the Include this transaction in the Mock Service icon in the left column. To remove a transaction from the Mock Service, you can click the Remove this transaction form the Mock Service icon in the right column.
Note: You can search by tag or text in the Other Transactions in Your Catalog column to find the Transactions that you want to include. Click the check box in the header to select all Transactions. This check box selects all of the Transactions on the current page. It does not select all Transactions in the service.- (Optional) In Transactions in This Mock Service column, expand each Transaction in the Mock Service 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 Mock Service. In other Mock Services or templates, the Transaction may have a different priority value. - Click the Parameters tab.
- (Optional) Set the Think Time to control an artificial delay between the request and the response. The default is "No Delay". For more information, see Simulating Irregular Response Latencies.
- In the No Matching Requests field, choose the correct logic for when a request against the Mock Services does not match any of the provided transactions. The request can either throw an error or be redirected to the live service.
- Click Save.
Your Mock Service is saved and added to the list of available Mock Services.
The Mock Service is not active until you run it. Click Run Mock Service to run it, and see Running a Mock Service for next steps.
Create a Mock Service from an Existing Service
In this scenario, you create a Mock Service by selecting an existing service that already contains the transactions that you need for your Mock Service.
Follow these steps:
- Navigate to the Mock Services tab and click Mock Services.
- In the Mock Services section, click the + button to create a new Mock Service, and select Create from Transactions.
A new row is added to the top of the Mock Services list. - Enter a Mock Service name in the Name field.
- Select the Service that contains the Transactions that you need for your Mock Service. The Service is a representation of the underlying live service, and it serves as a container for the Transactions.
- Select the location that you want to deploy your Mock 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 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 Mock 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 Mock Service name to expand the details for the Mock Service.
- (Optional) Enter a description for your Mock Service.
- Select the check box for each Transaction you want to include in your Mock Service and click the arrow to move them from the Other Transactions in Your Catalog to column and add them to the Transactions in This Mock Service.
Tip: You can use a quick action to move transactions with a single click. Click the Include this transaction in the Mock Service icon in the left column. To remove a transaction from the Mock Service, you can click the Remove this transaction form the Mock Service icon in the right column.
Note: You can search by tag or text in the Other Transactions in Your Catalogs column to find the Transactions you want to include. Click the check box in the header to select all Transactions. This check box selects all of the Transactions on the current page. It does not select all Transactions in the Service. - (Optional) In Transactions in This Mock Service column, expand each Transaction in the Mock Service 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 Mock Service. In other Mock Services or templates, the Transaction may have a different priority value. - Click the Parameters tab.
- (Optional) Set the Think Time to control an artificial delay between the request and the response. The default is "No Delay". For more information, see Simulating Irregular Response Latencies.
- In the No Matching Requests field, choose the correct logic for when a request against the Mock Services does not match any of the provided transactions. The request can either throw an error or be redirected to the live service.
- Click Save.
Your Mock Service is saved and added to the list of available Mock Services.
The Mock Service is not active until you run it. Click Run Mock Service to run it, and see Running a Mock Service for next steps.
Add, Remove and Modify Transactions in a Running Mock Service
For a transactional Mock Service, you can add and remove transactions or modify existing transactions without having to restart the Mock Service.
- To add or remove a transaction, update your transaction list and click the update button in the Mock Services tab. When you run the test again, the changes will be reflected.
- To modify a transaction, make the changes as needed and click save. Then click the update button in the Mock Services tab. When you run the test again, the changes will be reflected.
Select a Preferred Port
If you plan to run the Mock Service in a private location and you are creating a Docker-based transaction Mock Service, you can define a preferred port. If the port is available, it will be assigned to the Mock 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 a 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 is shown when you run the mock service. The first available port within the defined range is automatically selected.
Create a Mock Services U sing the Blazemeter Proxy Recorder
You can record a series of interactions from your browser, capture those interactions as transactions, and create a mock service based on those transactions. Use the BlazeMeter Proxy Recorder to record the interactions.
Follow these steps:
- Navigate to the Mock Services tab and click Mock Services.
- In the Mock Services section, click the + button to create a new Mock 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 Mock Service to export the recording to a Mock Service.
This creates a Mock 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 Mock Service from a MAR File
You can create and deploy Mock Services from a stored MAR file. The Mock Services uses the host VSE (virtual service environment) to deploy the virtual service associated with the MAR file. Use a MAR file from Broadcom's enterprise Service Virtualization.
When you create a Mock Service from a MAR file, you are simply allowing BlazeMeter to deploy the underlying virtual service to a BlazeMeter VSE or to your on-premise Service Virtualization VSE. For the on-premise Service Virtualization VSE, the virtual service runs on the VSE and can be edited in Service Virtualization using the DevTest Portal or Workstation.
Integration with Service Virtualization allows you to to store MAR files in an Asset Repository so that you can find, review, and deploy Mock Service/Virtual Service to a VSE. For more information on how to configure the Service Virtualization integration, see Integrate with Service Virtualization.
Note: The following procedure explains how to create a Mock Service from a MAR file and deploy it to your on-premise Service Virtualization VSE. For deployment to BlazeMeter VSE, see Deploy a MAR-based Mock Service to a BlazeMeter Virtual Service Environment.
Follow these steps:
- Navigate to the Mock Services tab and click Mock Services.
- In the Mock Services section, click the + button to create a new Mock Service, and select Create from Recording.
- In the Mock Services section, click the + button to create a new Mock Service , and select Create from MAR File .
A new row is added to the top of the Mock Services list. - Enter a Mock Service name in the Name field.
- Select the Service that contains the MAR file for your Mock Service.
- Select the VSE that you want to deploy your Mock Service to from the Location drop-down list.
If you don't see the VSE you need, contact your administrator or configure the Service Virtualization integration to add the Enterprise Dashboard on which your VSE is managed. - Select the MAR file for the Mock Service.
Note: You can also upload a MAR file directly during Mock Service creation using the upload box. This procedure assumes you have already uploaded the MAR file to the Asset Catalog. For more information, see Adding MAR Files.
A Mock Service can only accept a single MAR file.
You can view helpful information about the MAR file, such as transport protocol, virtual service name, and number of transactions. Expand the MAR file entry to see when it was stored in BlazeMeter. You can view more detailed information about the MAR file in the Asset Catalog. For more information, see Adding MAR Files. - Click the Parameters tab.
The parameters on this tab control the behavior of the virtual service when it is deployed to a Service Virtualization VSE:
Think Time Scale: Controls how long the virtual service waits before acting on a received request. This is similar to the Think Time setting within a Transaction-based Mock Service. Within Service Virtualization, this is a percentage that derives a realistic think time based on recorded data and accounting for any overhead processing time.
Concurrent Capacity: Controls the number of processing threads allocated to handle requests to the virtual service within Service Virtualization. This value typically only applies to virtual services deployed to a VSE in Performance mode.
Group Tag: Enter any group tag values to display in Service Virtualization. The group tag is a value that lets you build groups of virtual services in Service Virtualization. - Click Save.
Your Mock Service is saved and added to the list of available Mock Services.
The Mock Service is not active until you run it. Click Run Mock Service to run it, and see Running a Mock Service for next steps.
Deploy a MAR-based Mock Service to a BlazeMeter Virtual Service Environment
You can deploy any MAR-based Mock Service to a BlazeMeter VSE from either directly from the Asset Catalog or from the Mock Services tab. The environment will automatically spin up when you deploy the Mock Service to it.
- Deploy a MAR-based Mock Service from Asset Catalog
- Deploy a MAR-based Mock Service from Mock Services Tab
Deploy a MAR-based Mock Service from Asset Catalog
Note: You are limited to deploying 25 Mock Services at a time.
Follow these steps:
- Navigate to the Mock Services tab and click Asset Catalog.
- Select the MAR Files tab.
Before you deploy a MAR file to a Blaze VSE, you can see if the MAR is already running. Click RUNNING to see the endpoint, location and Mock Service name. - Select one or more MAR files and click the Deploy button. You can deploy the files individually or in bulk.
- To deploy MAR files individually, click the Deploy MAR file button in the Actions column for each Mock Service that you want to deploy.
- To deploy Mock Services in bulk, select the check box next to each Mock Service that you want to deploy and select the Deploy selected MAR files button next to the MAR Files title.
A Deploy Settings pop-up window opens.
- To deploy MAR files individually, click the Deploy MAR file button in the Actions column for each Mock Service that you want to deploy.
- Expand the Location drop-down list. If BlazeMeter Virtual Service Environments are available, they will appear in a VS Environments section. Select the BlazeMeter VSE that you want to deploy your Mock Service to. If you don't see the VSE you need, contact your administrator or create a BlazeMeter Virtual Service Environment.
An Advanced Settings toggle appears. - (Optional) Toggle the Advanced Settings on. You can edit the Think Time Scale, Concurrent Capacity and Execution Mode settings.
- (Optional) Define a Tag
Tags allow you to create logical groups of your Mock Services. The Mock Services with the same tag can be deployed together and associated with various tests.
Example: If 5 different services all represent a given backend, you can tag the services as ‘Backend A’.
Use tags if you are planning to associate a set of Mock Services to a test. On the Mock Services page, you can also search by a Mock Service Tag.
To add Tags to MAR files in bulk, select the Tag selected MAR files button, select the tag and click Add.This feature is similar to the use of Templates for Transaction based Mock Services.
Note: The Mock Service tag is only applicable if you are deploying a MAR file from the Asset Catalog to a BlazeMeter Virtual Service Environment. - (Optional) Disable the Switch View to Mock Services After Deploy if you want to remain in the Asset Catalog. If you want to be taken to the deployed Mock Services, no action is required.
- Select Deploy.
- Copy the endpoint or endpoints for the Mock Service and redirect your application to point to the Mock Service instead of the real Service.
Note: A MAR file-based Mock Service may have more than one endpoint. - (Optional) For Kubernetes-based deployments only, add the Mock Services fully qualified domain name to your DNS record.
For more information, see Install BlazeMeter Virtual Service Environment in Kubernetes.
Your MAR-based Mock Service is ready to accept request at the endpoint on the BlazeMeter Virtual Service Environment. The BlazeMeter Virtual Service Environment automatically spins up when you deploy a Mock Service to it, and it should appear as Running on the Environments tab.
Note:
- From the Asset Catalog, you cannot deploy to your on-premise Service Virtualization.
- If you deploy a MAR that is already running on the location, the already running Mock Service will be updated.
Deploy a MAR-based Mock Service from Mock Services Tab
- Navigate to the Mock Services tab and click Mock Services.
- In the Mock Services section, click the + button to create a new Mock Service, and select Create from MAR File.
A new row is added to the top of the Mock Services list. - Enter a Mock Service name in the Name field.
-
Select the Service that contains the MAR file for your Mock Service.
-
Expand the Location drop-down list. If BlazeMeter Virtual Service Environments are available, they will appear in a VS Environments section. Select the BlazeMeter VSE that you want to deploy your Mock Service to. If you don't see the VSE you need, contact your administrator or create a BlazeMeter Virtual Service Environment.
-
Select the MAR file for the Mock Service.
Note: You can also upload a MAR file directly during Mock Service creation using the upload box. This procedure assumes you have already uploaded the MAR file to the Asset Catalog. For more information, see Adding MAR Files.
A Mock Service can only accept a single MAR file.You can view helpful information about the MAR file, such as transport protocol, virtual service name, and number of transactions. Expand the MAR file entry to see when it was stored in BlazeMeter. You can view more detailed information about the MAR file in the Asset Catalog. For more information, see Adding MAR Files.
-
Click the Parameters tab.
The parameters on this tab control the behavior of the virtual service when it is deployed to a Service Virtualization VSE:
Think Time Scale: Controls how long the virtual service waits before acting on a received request. This is similar to the Think Time setting within a Transaction-based Mock Service. Within Service Virtualization, this is a percentage that derives a realistic think time based on recorded data and accounting for any overhead processing time.
Concurrent Capacity: Controls the number of processing threads allocated to handle requests to the virtual service within Service Virtualization. This value typically only applies to virtual services deployed to a VSE in Performance mode.
Group Tag: Enter any group tag values to display in Service Virtualization. The group tag is a value that lets you build groups of virtual services in Service Virtualization. -
Click Save.
Your Mock Service is saved and added to the list of available Mock Services. - When you are ready to deploy the Mock Service, click Run.
- Copy the endpoint or endpoints for the Mock Service and redirect your application to point to the Mock Service instead of the real Service.
Note: A MAR file-based Mock Service may have more than one endpoint. - (Optional) For Kubernetes-based deployments only, add the Mock Services fully qualified domain name to your DNS record.
For more information, see Install BlazeMeter Virtual Service Environment in Kubernetes.
Your MAR-based Mock Service is ready to accept requests at the endpoint on the BlazeMeter Virtual Service Environment. The BlazeMeter Virtual Service Environment automatically spins up when you deploy a Mock Service to it, and it should appear as Running on the Environments tab.
Create a Mock Service from a Mock Service Template
At any time after saving the Template, click Create Mock Service to the right of the Template name to dynamically provision a Mock Service that includes the transactions in the Template.
- Go to the Mock Service Templates section.
- In the Actions column, click the Create Mock Service button.
Your Mock Service is created and you can find it in the Mock Services section.
Other template actions include:
- Assign a template to a Mock Service
- Create a Mock Service template from a Mock Service
For more information, see Creating a Mock Service Template.
Rules for Endpoints Generated for Kubernetes Mock Deployment
The URL format is the following:
http(s)://(mock-name[40])(serviceid[9])-<port>-<namespace>.<sub-domain>
- Mock name
First 40 lowercase alpha numeric characters of the mock name. - Service ID
ID associated with the service name. Service ID is used in the endpoints that are generated after you deploy your Mock Service. When you know your service ID, you can predict the format of your Mock Service endpoint.
Note: You can view the Service ID in the Service drop-down list and copy it to clipboard. - Port
8080 for transaction mock services and specified in the MAR for MAR mock services. - Namespace
Kubernetes namespace - Sub-domain
Configured as a part of an agent set up.
Mock service names can be more than 40 characters. If the first 40 characters of the name conflict with any other existing mock 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>
Note: In a very rare case for private cloud mock deployments: If you specify a mock service name to be a lowercase alphanumeric string with 128 character length, it is treated as an encoded string and the old format for endpoint is used to support backward compatibility. The old format is the following:
Transaction mock service:
http(s)://servicemock<mock_id>-8080-<k8s_namespace>.<sub-domain>
MAR mock service:
http(s)://blazevse<blazevse_id>v<time_stamp>-<port_num_from_mar>-<namespace>.<sub_domain>
0 Comments