-
Notifications
You must be signed in to change notification settings - Fork 47
How to use Flashback to test non java service
Within JVM application, Test driver and Flashback instance are started in the same process. Test driver can directly call Flashback API to start proxy, shut down proxy, change scene and change match rules. However, Flashback is wrote in Java and other Non-JVM test driver can't call Flashback directly.
The most scalable way is to create Http server which can manage Flashback proxy's life cycle. I am using Resli to demonstrate how it works and also prove how easy to use Rest.li framework outside Linkedin.
Using Flashback admin to manage a bunch of flashback instance allow test drivers run in parallel. (Note: Flashback itself could support multiple http request in parallel but each Flashback instance only support can use one Scene and one Match rule at one time.)
Note: this diagram is only focus on design for flashback admin so the real target web service is hided from this diagram. Test driver(NON-JAVA) Contains a list of test cases that will be used to test Service Service(NON-JAVA) Your service need to be tested. Flashback admin(JAVA) Restli resource that accept request from test driver to start one flashback proxy instance, shut down, change scene dynamically, change match rules dynamically. It controls each flashback proxy instance behaves. Flashback proxy(JAVA) Contains normal Flashback functionalities such as record, playback etc
Take playback mode as example(so there is not external providers in this diagram
- Test driver send http request to Flashback admin to start Flashback proxy on the port 5001, with match rule 1 and scene 1 stored in the location it specified. If this requires Https interaction, it will also specify CA certificate related parameters.
- Flashback Admin accept request and process it and start Flashback proxy on the port 5001 and install match rule 1 and scene 1 for Flashback 1.
- Test driver 1 start test case for service.
- Service make HttpRequest 1 to external providers via Flashback proxy instance 1 Flashback proxy instance 1 will use match rule1 and scene1 to return proper response to Service and test driver will verify if what service send out is what it expected.
- Now, the first test is done. Test driver want to switch to another stored scene(i.e. bad request, it want test failure case). It send http request to Flashback admin again to change scene name.
- Flashback Admin notify Flashback Proxy instance 1 to switch to scene 1 for new test cases. 7 and 8. repeated 3 and 4 n and n+1: shut down one flashback service instance
- Wire in restli lib to solve this problems is a little overkill. It would be better to just create netty Http server to process request instead.
- We predefined most popular match rules such as matchEntireRequest, matchMethodUri etc but what if client need very customized match rule? we need enhance this to accept customized match rules