Mining Service Behavior for Stateful Service Emulation

Md. Arafat Hossain, Jun Han, Muhammad Ashad Kabir, Steve Versteeg, Jean-Guy Schneider, Jiaojiao JiangarXiv 2025 · DOI · arXiv

Abstract

Service virtualization is essential for testing interconnected enterprise systems, yet most automated tools fail to capture "stateful" behavior, leading to unrealistic testing environments. This paper presents a novel approach that automatically mines stateful service behavior from interaction traces. By partitioning message logs by specific data records and inferring finite state machines, the proposed system accurately emulates complex services. Evaluation across diverse protocols shows that this method significantly outperforms existing deep learning and clustering techniques in accuracy, speed, and memory efficiency.

Introduction

In modern enterprise software, systems are highly interconnected. Testing a "System Under Test" (SUT) typically requires access to third-party services, such as payment gateways or mainframes. However, these services are often expensive, restricted, or still under development. Service Virtualization (SV) aims to solve this by creating "virtual" versions of these services based on recorded traffic.

Comparison of service virtualization approaches across automation, statefulness, and message format support.

A significant limitation of existing SV tools is their "stateless" nature; they treat every request in isolation. For instance, a stateless virtual service might return a "Success" response for a user deletion even if that user was never created in the current session. This lack of state awareness leads to brittle test suites and unrealistic environments. As shown in the comparison above, the proposed approach is the first to combine automation with full statefulness and message format awareness.

Methodology

The authors propose a three-stage pipeline to transform raw interaction traces into a functional stateful emulator.

The three-stage pipeline for stateful service emulation: Message Analysis, Dependency Analysis, and Response Generation.

1. Message Analysis

The system identifies message types and formats (e.g., distinguishing an LDAP Bind request from a Search request) by aligning stable fields and analyzing keyword patterns. This ensures that the generated responses are syntactically valid.

2. Dependency Analysis

This is the core innovation of the paper. Instead of viewing a trace as a single sequence, the system performs Key-Payload Partitioning. It identifies a "key field" (like a UserID) and splits the trace into sub-traces for each specific record. It then uses a Prefix Tree Acceptor (PTA) and the kTail algorithm to convert these sequences into a Finite State Automaton (FSA). This FSA acts as the service's logic, determining which responses are valid given the current state of a specific record.

3. Response Generation

At runtime, the virtual service tracks the state of each data record. When a request arrives, the FSA selects the correct response type, and the system populates the payload using equality-based substitution or historical data selection.

Key Insights

  • Entity-Based State: The primary insight is that service state is usually tied to specific data entities (e.g., a specific account) rather than the service as a whole. Partitioning by key payload simplifies a massive state space into manageable, record-specific state machines.
  • Probabilistic Robustness: To handle "dirty" data where a test might start mid-session, the authors employ a probabilistic model to guess the most likely response type based on historical frequency.

Evaluation and Results

The approach was evaluated on four diverse datasets: CA Identity Manager (LDAP), a SOAP Bank Service, and RESTful services for Twitter and GoogleBooks.

  • Accuracy: On the LDAP dataset, the proposed method achieved 87.98% identical responses, vastly outperforming clustering-based tools (33%) and deep learning models (<1%).
  • Efficiency: The system is exceptionally fast, generating responses in a fraction of a millisecond—159x faster than the actual services and over 10,000x faster than some existing virtualization methods.
  • Scalability: While deep learning models (like SSBV) often crash due to memory overhead on complex payloads, this approach maintains a minimal memory footprint.

Conclusion

By mining stateful behavior through trace partitioning and state machine inference, this approach provides a scalable and accurate solution for service virtualization. Future work will focus on automating the discovery of key payload fields and supporting asynchronous messaging architectures.

Summary updated

Abstract

Enterprise software systems are increasingly integrating with diverse services to meet expanding business demands. Testing these highly interconnected systems presents a challenge due to the need for access to the connected services. Service virtualization has emerged as a widely used technique to derive service models from recorded interactions, for service response generation during system testing. Various methods have been proposed to emulate actual service behavior based on these interactions, but most fail to account for the service's state, which reduces the accuracy of service emulation and the realism of the testing environment, especially when dealing with stateful services. This paper proposes an approach to deriving service models from service interactions, which enhance the accuracy of response generation by considering service state. This is achieved by uncovering contextual dependencies among interaction messages and analyzing the relationships between message data values. The approach is evaluated using interaction traces collected from both stateful and stateless services, and the results reveal notable enhancements in accuracy and efficiency over existing approaches in service response generation.
BibTeX
@misc{hossain2025mining,
  author = {Md. Arafat Hossain and Jun Han and Muhammad Ashad Kabir and Steve Versteeg and Jean-Guy Schneider and Jiaojiao Jiang},
  title = {{Mining Service Behavior for Stateful Service Emulation}},
  year = {2025},
  eprint = {2510.18519},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.18519},
}
Figure