当前位置:网站首页>Microservice test efficiency governance

Microservice test efficiency governance

2022-06-22 13:40:00 51CTO

Under the microservice service structure , The third-party services that microservices rely on 、 More and more data , It brings many difficulties to the traditional testing methods , For example, the dependent offline services are unstable ; The service cannot provide the expected response data ; Lack of test scenario construction standards, etc . To address these issues , The general idea is to improve the stability of the test environment 、 Build your own test data and test scenarios , Improve the certainty and effectiveness of testing , But these methods can not fundamentally solve the problem . such as , Service instability is still unavoidable , Changing the code injection object is not only complicated, but also very error prone , And there is no certain basis , The constructed test scenarios are not sufficient , indecisive .

One 、 Traffic recording playback test

In view of the above shortcomings of microservice testing , Try a traffic recording and playback solution , Record the real online traffic in a certain way , Playback offline . During offline test , The online playback traffic can flexibly test the respective functions of the service , You can also edit and modify based on playback traffic , For the third-party requests that the service depends on mock And customization , Make code development simple and convenient , And it can be changed and measured at any time , solve RD Inconvenient development 、 The self-test process is too long .

The recorded traffic should include the service request / Return traffic , And the third-party interactive traffic that can be associated with it . If there are only service requests / Return traffic , Can only be used in query class read-only systems , The scope of application is limited ; If the third-party interaction cannot be properly associated with the request , These flows cannot be applied correctly .

To solve the problem of traffic correlation , One solution is to Flow rectifier , Serialize it . A machine that parallels the online services , Control the traffic it receives , Reduce the traffic of its service to serial , And the interval between flows is certain ( To allow time for asynchronous third-party requests ), So these traffic requests / The response is automatically associated with its third-party interaction traffic .

How to associate requests with third-party interaction traffic , Requests can be associated with traffic to third-party system calls based on distributed tracing technology . However, the difficulty of this method is that not all third-party interaction traffic has a request tracking id . Another idea is to intercept system calls at the language level , Associate the request with a call to a third-party system .

Two 、 Simulation environment test

As an online service , In order to meet the gray-scale publishing 、 Testing and other multidimensional requirements , It is generally necessary to support flexible diversion strategies , Schedule traffic to different environments . In order to support fine grayscale publishing strategy , Online traffic needs to be diverted to small traffic clusters according to certain rules , In order to support high simulation test using real traffic , It is also necessary to introduce certain traffic into the simulation environment according to policy rules .

The characteristic of small traffic diversion is that the traffic is sent to small traffic clusters , No more processing , Wait directly for the return result of the small traffic cluster , Then forward the result to the calling side . The characteristic of simulation environment shunting is that the traffic sent to the simulation environment is only one “ shadow ” Traffic , amount to Oneway request ( No reply message is required ), There is no impact on the business process , It is the same as the case without simulation environment .

Simulation environment support can be carried out at the service framework level , In order to realize the routing and forwarding based on the request content , The framework acts as a Proxy Role , After the request is parsed, it is sent to the downstream environment . Based on the characteristics of simulation traffic , In order not to have an impact on the business , The timeout for sending to the downstream simulation environment can be set very small , Even if some traffic times out, it doesn't matter , At the same time, in order to realize the processing of simulation environment under the framework of automatically generated code Oneway effect , You can customize a transport layer , The specific implementation of this transport layer does not handle anything , Just throw it away .

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221232169284.html