Stateful simulation

When simulating a service, the order of requests is often important. A service may return different responses to the same request depending on the current state of the service. Service Virtualization can simulate this type of stateful behavior.

A virtual service uses tracks to simulate stateful behavior. Tracks enable you to order request/response pairs in a virtual service’s data model, to define the sequence in which they are used during simulation.

Service Virtualization creates tracks during learning. You can also manually create and edit tracks.

During simulation, Service Virtualization evaluates each request to determine which track it fits into, and in which position in the track, and returns the appropriate response.

How are tracks created?

Service Virtualization creates tracks automatically based on learned data. During learning, tracks are split according to client sessions. Each session, as identified by a unique session ID, is placed into a separate track.

How are different client sessions identified?

Service Virtualization identifies client sessions according to a specific message element or metadata. Depending on the transport protocol a virtual service is using, Service Virtualization assigns a default session identifier to the service. To achieve the result you want, you can modify the session identifier that is used for a specific virtual service. For example, for SOAP services over HTTP, the default session ID is the IP address of a client sending requests. In the case of a proxy server, requests from several clients may appear to be coming from the same IP address, and will not be split into separate tracks.

What happens during learning?

When you record real service behavior, Service Virtualization splits the learned data into separate tracks according to the session ID. Each time you place the virtual service into Learning mode, new tracks are added, and identical tracks are removed to ensure that each track is unique. If you are using external data sources in your data model, one linear track is created for each data driven rule.

What happens during simulation?

During simulation, separate sessions are simulated for each unique session ID.

Service Virtualization matches incoming client requests to data in the data model according to the session ID and the relevant operation in the virtual service, and returns the appropriate response.

If incoming requests do not match a track exactly, heuristic simulation is performed to determine the most similar track, with newer tracks taking priority. Service Virtualization calculates the probabilities of all track positions in all tracks simultaneously to determine where in the simulated scenario this request most likely fits.

Back to top

See also: