Generating a virtualized stub service using deep learning for testing a software module
The disclosure herein describes generating a virtualized stub service based on deep learning for use in simulating a service during testing of a software module configured to interact with the service. Request-response pairs between the software module and the service are captured by an interceptor module, each request-response pair including a request and a response to the request. The captured request-response pairs are added to a training data set. A service virtualization engine trains a request categorization model based on the training data set, wherein the request categorization model is trained to respond to requests with responses based on the request-response pairs of the training data set. Then, a virtualized stub service is generated for the service based on the trained request categorization model. The disclosure provides for automatic generation of virtualized stub services using deep learning techniques for use in testing software modules.
1. A system for generating a virtualized stub service based on deep learning for use in simulating a service, the system comprising:
at least one processor; and
at least one memory comprising computer program code, the at least one memory and the computer program code configured to, with the at least one processor, cause the at least one processor to:
capture, by an interceptor module, request-response pairs between a software module and the service, each request-response pair including a request and a response to the request;
add, by the interceptor module, the captured request-response pairs to a training data set;
train, by a service virtualization engine, a request categorization model based on the training data set and a ground truth rule defined to identify invalid formatting of an input request, wherein the request categorization model is trained to respond to requests with responses based on the request-response pairs of the training data set;
evaluate validity of a request format of the input request against the ground truth rule;
responsive to a valid input request, map the input request to an output response based on a request category map associated with the request categorization model;
responsive to an invalid input request, automatically respond to the invalid input request with a fixed response, wherein the output response mapped to the invalid input request is overridden by the ground truth rule;
determine the output response to the input request based on application of the request category map and the ground truth rule, the request category map is adjusted during training based on new request-response pairs being added to the training data set; and
generate, by the service virtualization engine, a virtualized stub service for the service based on the trained request categorization model, wherein the virtualized stub service is configured to respond to requests from the software module with responses during testing of the software module.
2. The system of claim 1 , wherein generating the virtualized stub service includes generating the virtualized stub service as a testing library of the software module, the testing library configured to respond to requests from the software module during unit testing of the software module.
3. The system of claim 1 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
deploy the virtualized stub service on a web server; and
perform at least one test of the software module, the at least one test including sending, by the software module, a request to the deployed stub service and receiving, by the software module, a response to the request from the deployed stub service.
4. The system of claim 1 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
evaluate every received request against the ground truth rule to identify invalid formatting.
5. The system of claim 1 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
receive at least one ground truth rule that defines a specific request and a fixed response to the specific request, wherein training the request categorization model includes training the request categorization model to respond to the specific request with the fixed response, wherein the at least one ground truth rule is defined to identify invalid formatting of a received request; and
provide the fixed response, including an invalid request format message on condition the invalid formatting of the received request is identified, wherein the request categorization model evaluates validity of format of a received request against the at least one ground truth rule for every received request and automatically responds with the invalid request format message.
6. The system of claim 1 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
detect, by the service virtualization engine, new request-response pairs being added to the training data set after generation of a first version of the virtualized stub service based on a first version of the service, wherein the new request-response pairs are associated with a second version of the service; and
based on detecting the new request-response pairs being added to the training data set, retrain, by the service virtualization engine, the request categorization model based on the training data set that includes the new request-response pairs; and
generate, by the service virtualization engine, a second version of the virtualized stub service based on the retrained request categorization model and associated with the second version of the service.
7. The system of claim 6 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
provide the first version of the virtualized stub service and the second version of the virtualized stub service for testing of the software module, whereby the software module is enabled to be tested based on the first version of the service and the second version of the service, wherein the request categorization model associated with the first version of the virtualized stub service is iteratively trained based on an updated training data set as new request-response pairs are captured and added to the updated training data set to generate the second version of the virtualized stub service.
8. A computerized method for generating a virtualized stub service based on deep learning for use in simulating a service during testing of a software module configured to interact with the service, the method comprising:
capturing, by an interceptor module, request-response pairs between the software module and the service, each request-response pair including a request and a response to the request;
adding, by the interceptor module, the captured request-response pairs to a training data set;
training, by a service virtualization engine, a request categorization model based on the training data set and a ground truth rule defined to identify invalid formatting of an input request, wherein the request categorization model is trained to respond to requests with responses based on the request-response pairs of the training data set;
evaluate validity of a request format of the input request against the ground truth rule;
responsive to a valid input request, map the input request to an output response based on a request category map associated with the request categorization model;
responsive to an invalid input request, automatically respond to the invalid input request with a fixed response, wherein the output response mapped to the invalid input request is overridden by the ground truth rule;
determining the output response to the input request based on application of the request category map, the request category map is adjusted during training based on new request-response pairs being added to the training data set; and
generating, by the service virtualization engine, a virtualized stub service for the service based on the trained request categorization model, wherein the virtualized stub service is configured to respond to requests from the software module with responses during testing of the software module.
9. The computerized method of claim 8 , wherein the at least one memory and the computer program code are configured to further cause the at least one processor to:
evaluate every received request against the ground truth rule to identify invalid formatting.
10. The computerized method of claim 8 , further comprising:
deploying the virtualized stub service on a web server; and
performing at least one test of the software module, the at least one test including sending, by the software module, a request to the deployed virtualized stub service and receiving, by the software module, a response to the request from the deployed virtualized stub service.
11. The computerized method of claim 8 , wherein capturing the request-response pairs between the software module and the service includes capturing the request-response pairs during at least one of unit testing of at least one of the software module or the service, regression testing of at least one of the software module or the service, or general operation of at least one of the software module or the service.
12. The computerized method of claim 8 , further comprising:
receiving a set of format-based ground truth rules that defines fixed responses to specific requests, wherein training the request categorization model includes training the request categorization model to respond to the specific requests with the fixed responses.
13. The computerized method of claim 12 , wherein the set of format-based ground truth rules are defined to identify invalid formatting of a received request, and further comprising:
providing the fixed responses, including an invalid request format message on condition the invalid formatting of the received request is identified, wherein the request categorization model evaluates validity of format of a received request against the at least one ground truth rule for every received request and automatically responds with the invalid request format message.
14. The computerized method of claim 8 , further comprising:
detecting, by the service virtualization engine, new request-response pairs being added to the training data set after generation of a first version of the virtualized stub service based on a first version of the service, wherein the new request-response pairs are associated with a second version of the service; and
based on detecting the new request-response pairs being added to the training data set, retraining, by the service virtualization engine, the request categorization model based on the training data set that includes the new request-response pairs; and
generating, by the service virtualization engine, a second version of the virtualized stub service based on the retrained request categorization engine and associated with the second version of the service.
15. One or more non-transitory computer storage media having computer-executable instructions for generating a virtualized stub service based on deep learning for use in simulating a service during testing of a software module configured to interact with the service that, upon execution by a processor, cause the processor to at least:
capture, by an interceptor module, request-response pairs between the software module and the service, each request-response pair including a request and a response to the request;
add, by the interceptor module, the captured request-response pairs to a training data set;
train, by a service virtualization engine, a request categorization model based on the training data set and a ground truth rule defined to identify invalid formatting of an input request, wherein the request categorization model is trained to respond to requests with responses based on the request-response pairs of the training data set;
evaluate validity of a request format of the input request against the ground truth rule;
responsive to a valid input request, map the input request to an output response based on the request category map associated with the request categorization model;
responsive to an invalid input request, automatically respond to the invalid input request with a fixed response, wherein the output response mapped to the invalid input request is overridden by the ground truth rule;
determine the output response to the input request based on application of the request category map and the ground truth rule, the request category map is adjusted during training based on new request-response pairs being added to the training data set; and
generate, by the service virtualization engine, the virtualized stub service for the service based on the trained request categorization model, wherein the virtualized stub service is configured to respond to requests from the software module with responses during testing of the software module.
16. The one or more computer storage media of claim 15 , wherein generating the virtualized stub service includes generating the virtualized stub service as a testing library of the software module, the testing library configured to respond to requests from the software module during unit testing of the software module.
17. The one or more computer storage media of claim 15 , wherein the computer-executable instructions, upon execution by a processor, further cause the processor to at least:
deploy the virtualized stub service on a web server; and
perform at least one test of the software module, the at least one test including sending, by the software module, a request to the deployed stub service and receiving, by the software module, a response to the request from the deployed stub service.
18. The one or more computer storage media of claim 15 , wherein the computer-executable instructions, upon execution by a processor, further cause the processor to at least:
evaluate every received request against the ground truth rule to identify invalid formatting.
19. The one or more computer storage media of claim 15 , wherein the computer-executable instructions, upon execution by a processor, further cause the processor to at least:
receive at least one ground truth rule that defines a specific request and a fixed response to the specific request, wherein training the request categorization model includes training the request categorization model to respond to the specific request with the fixed response, wherein the at least one ground truth rule is defined to identify invalid formatting of a received request provide the fixed response, including an invalid request format message on condition the invalid formatting of the received request is identified, wherein the trained request categorization model evaluates the validity of format of a received request against the at least one ground truth rule for every received request and automatically responds with the invalid request format message.
20. The one or more computer storage media of claim 15 , wherein the computer-executable instructions, upon execution by a processor, further cause the processor to at least:
detect, by the service virtualization engine, new request-response pairs being added to the training data set after generation of a first version of the virtualized stub service based on a first version of the service, wherein the new request-response pairs are associated with a second version of the service;
based on detecting the new request-response pairs being added to the training data set, retrain, by the service virtualization engine, the request categorization model based on the training data set that includes the new request-response pairs; and
generate, by the service virtualization engine, a second version of the virtualized stub service based on the retrained request categorization model and associated with the second version of the service.