In this section:
Table of Contents | ||
---|---|---|
|
Introduction
The Data Learning tool is used to incrementally extend a virtual asset's reach to cover a broader range of use cases. It automatically expands the data set by observing traffic and adding net new observations to the data repository—enabling teams to rapidly enhance data-driven virtual assets. The update process can be fully-automated (invoked whenever new data is detected, via the File Event Listener Marketplace tool) or initiated on an as-needed basis (via provisioning actions).
Requirements
This tool requires access to a Virtualize Server with version 9.9.5 or later; the tool itself can be used on Virtualize 9.9.0 or higher.
Installation
This tool is implemented as datalearningtool.jar. You can install the tool from the UI or the command line.
UI Installation
- Choose Parasoft > Preferences and click System Properties.
- Click Add JARs and browse for the datalearningtool.jar.
- Click Apply and restart Virtualize.
Command Line Installation
Add the datalearningtool.jar file to the system.properties.classpath
property in your settings properties file. For example:
system.properties.classpath=<path to jar>/datalearningtool.jar
Usage
You can add the tool as a provisioning action if you want to invoke it as needed or integrate data learning into the test environment provisioning process with Continuous Testing Platform.
Add a .pvn file to the project (see Defining Provisioning Actions) and right-click the Action Suite node.
- Choose Add New> Action and choose Data Learning Tool from the Add Action wizard.
- Click Finish and configure the tool (see Configuration).
If you want it to run automatically whenever new or updated traffic is detected in a specific traffic file directory, chain the tool to the outgoing response of a Message Responder and ensure that the associated virtual asset is configured with the File Event Listener (visit the Parasoft Marketplace to download the File Event Listener). For File Event Listener configuration details, see the File Event Listener documentation.
In both cases, the tool will do the following once it is triggered:
- Scan the specified local directory for new or modified traffic files whose names match a specific pattern.
- If matching traffic files are found, use the specified Virtualize Server to process that traffic according to the settings defined in the designated template file.
- Import the identified data into the designated Data Repository.
Configuration
The tool is configured by setting the following options.
Source Traffic Settings
These options control how the tool identifies and processes traffic files.
Scroll Table Layout | ||
---|---|---|
|
Directory to Scan for Traffic Files | Specify the local directory to scan for traffic files. The directory is relative to the Data Learning tool. If the tool is deployed in a .pva that is deployed in "VirtualAssets", it is relative to "VirtualAssets". If the tool is in a .pvn in another project, the path is relative to that other project. |
---|---|
Traffic File Pattern | (Optional) If you want to process only specific traffic files in the above directory, specify a pattern that indicates which traffic files you want to include. You can use |
Template File | Specify the location of the Virtualize configuration template you want to apply to guide the traffic processing. If the tool is deployed in a .pva that is deployed in "VirtualAssets", it is relative to "VirtualAssets". If the tool is in a .pvn in another project, the path is relative to that other project. |
Character Encoding | (Optional) Specify the character encoding for the tool. Default is |
Data Reuse | (Optional) If you want to override the data reuse settings specified in the template file, specify the desired reuse option. |
Remote Server Settings
These options specify which Virtualize Server should process the traffic files.
Scroll Table Layout | ||
---|---|---|
|
Use Remote Server (Default: false) | Enter |
---|---|
Host | Specify the host of the Virtualize Server that should process the traffic files. |
Port (Default: 9080) | Specify the port of the Virtualize Server that should process the traffic files. Default is |
Username | Specify a username for authenticating with this Virtualize Server. |
Password | Specify a password for authenticating with this Virtualize Server. |
Upload Path (Relative to VirtualAsset) | Specify where on this Virtualize Server to upload the files that are used to identify and process new traffic. This directory should be relative to the Virtualize Server's VirtualAssets project. This setting is optional. |
Data Repository Settings
These options specify what Data Repository the new/updated data should be imported into. If you do not specify a host, all Data Repository settings will be taken from the template specific in the Source Traffic tab.
Scroll Table Layout | ||
---|---|---|
|
Host | Specify the host of the Data Repository Server where the new/updated data should be imported. |
---|---|
Port | Specify the port of the Data Repository Server where the new/updated data should be imported. The default is |
Username | Specify username for authenticating with this Data Repository Server. |
Password | Specify a password for authenticating with this Data Repository Server. |
Logging
This option specifies the level of logging detail that is recorded.
Scroll Table Layout | ||
---|---|---|
|
Log Level | Specify how much information you want logged to the console and the Event Monitoring view. The default is If the tool is used in a .pva, information will also be logged to the Event Details perspective. Informational events are logged to the Console if the log level is greater than |
---|
Running the Examples
The zip file that you downloaded from Marketplace provides several example configurations and exercises for using the Data Learning tool. The examples show you how to deploy the tool as a tool directly in a Provisioning Action (pvn) and as a tool chained to a Message Responder in a Virtual Asset (pva).
Using the Tool Directly
- Copy the following files to a project within your workspace (such as ProvisioningAssets):
- DataLearner.pvn
- DataLearner_1.txt
- DataLearner_2.txt
- DataLearningExample.traffictemplate
- Invoke the .pvn by either running it directly in the Virtualize UI or through CTP. The tool will scan the directory for the traffic template and DataLearner_*.txt traffic files, importing data from them into the Data Repository on localhost.
Using the Tool Chained to a Responder
- Deploy DataLearner.pva as a Virtual Asset in Virtualize at the HTTP path: /DataLearner.
- Copy DataLearner_1.txt and DataLearner_2.txt to VirtualAssets/traffic_files/ on the Virtualize server where the DataLearner Virtual Asset is deployed.
- Copy DataLearnerExample.traffictemplate to VirtualAssets/traffic_templates/ on the Virtualize server where the DataLearner Virtual Asset is deployed.
- (Optional) Update the Environment in DataLearner.tst to point to the correct Virtualize host.
- (Optional and recommended) Start Monitoring the DataLearner Virtual Asset.
- Run DataLearner.tst. This test invokes the DataLearner Virtual Asset over HTTP, causing the chained Data Learning Tool to run. The chained tool uses the traffic template and traffic files that were copied in steps 2 and 3.
- Note events reported to the Virtualize Event Log and that the traffic files are deleted from traffic_files when done.
Using a Message Proxy to Record Transactions
- Create a Message Proxy and add a connection (see Creating Proxies).
- Configure the connection to use a unique traffic file pattern (i.e., %n) and enable the New session file for each message pair option.
- Make sure the Data Learning Tool is configured to scan the directory to which the Proxy Connection will record. Relative paths in the Data Learning Tool configuration are relative to the .pva or .pvn that contains the tool.
- Record traffic normally through the Message Proxy.
- Run the Data Learning Tool to process recorded transactions.
Data Learning Tool Use Case
If a virtual asset doesn't know how to respond to a given request, you can record the request and its corresponding response from the live service or local server and add it to the Data Repository. The next time the virtual asset receives that same request, the appropriate response will be returned.
Workflow
In a typical proxy configuration, a connection forwards a request to a virtual asset. If the asset knows how to respond to the request, the response from the associated repository will be returned to the client.
If the virtual asset does not know how to respond to a given request, an error message will be returned to the client and no additional action will be taken.
You can configure Virtualize so that the request and corresponding response will be recorded and added to the Data Repository (see Configuration below). The following outline describes the overall process for "teaching" a virtual asset how to respond to new requests.
- The virtual asset fails to respond.
- The request is sent to the live system, which is configured as the proxy's secondary connection.
- The corresponding response is returned to the client and the request and response are recorded in a traffic file.
The traffic file creation/update triggers the virtual asset's File Event Listener, which invokes the responder with the Data Learning tool.
The Data Learning tool sends the traffic file to the designated Virtualize Server, which then uses the designated template file to process the traffic and add it to the Data Repository.
- The next time that this request is received, the virtual asset will return the recorded response.
Anchor | ||||
---|---|---|---|---|
|
- Configure the Message Proxy's primary connection to forward to the virtual asset.
- Configure the Message Proxy's secondary connection to forwards to the live virtual service.
- Enable the Record on secondary connection only and New session file for each message pair options for the Message Proxy.
- Configure the virtual asset to use the File Event Listener as a Custom Transport and configure the listener to monitor the directory where the proxy will save traffic files.
- Add a responder with a Data Learning Tool chained to it to the .pva associated with the virtual asset.
- Configure the tool to add data to the Data Repository that originally did not have the request/response.