First, the flow comparison puts forward the background

When we conduct code refactoring and requirements iteration, we need to conduct one round, two rounds and regression tests before going online. If the business scenario is complicated, there will be problems in the following aspects:

(1) The test cycle will be correspondingly longer;

(2) With the continuous iteration of business functions, test cases may not be fully covered, and some obscure problems may not be found in time, making regression testing increasingly difficult;

(3) Affecting the release frequency;

(4) Development and testing personnel spend a long time in the testing phase, which is not conducive to freeing time for the next business iteration and technical transformation;

(5) Code quality often depends on artificial code review, which takes more time due to the large number of iterative code lines;

Therefore, whether we can solve these pain points, improve our work efficiency and ensure the quality of our code is a problem we need to think about. The industry practice is to direct online traffic to the comparison machine, and compare the production results with the comparison machine in real time, exposing problems in time, so that development and testing can find and modify them in time.

Second, the comparison with the flow playback platform

The current flow in the playback platform are based on the basic flow of the recording, playback will flow to the test environment, the problems existing in the system of analysis after playback, to a certain extent can only release some regression test resources, does not make us problems existing in the development of the measurement can be timely before exposure, allows developers to solve the problem in advance, improve the quality of code of the test, Our goal is to ensure the quality of our code even if there is no test participation. If there is an impact on online stock business, it is necessary to get timely feedback and form a closed-loop treatment and a real-time comparison scheme.

3. Flow comparison scheme

For general business system, we compare the dimension generally includes database data, mq message, landing interface call request parameters and output four dimensions, usually under the condition of 50% compared to flow is the whole production flow, basic can override the production case scenario, on the basis of comparison for the three dimension consistent rate close to 100%, Then the impact of our online iteration on the existing business can be guaranteed. The main idea is to construct the request message, execute the request and then analyze and compare the result.

(1) Overall structure

When finish production application processing request, all involved in the call of the interface, the mq message sending such as buried point information is recorded to ES (given the ES is distributed, high expansion, high real-time search engine and data analysis, through its interface, can easily get buried point information), then make an mq message, Comparison tool to monitor the mq message to spend, according to the corresponding order information, production order data query and mock, then calls the application contrast, contrast tool after a certain time delay, according to the need to compare the content of contrast, will send ES ratio on the results, can according to the ES contrast results consistent rate buried point of view as well as the specific reason for the inconsistency.

Note: Production application: actual production application cluster

Comparison application: Our iterative version deploys clusters

Comparison tool: An application designed solely for running comparison

(2) Data burying point

Data purchase is the premise of comparison, including burying point of interface request, burying point of Q message, burying point of input request, and subsequent comparison tool reading data for comparison

(3) Data mock

The comparison application cannot actually operate DB or interact with upstream and downstream systems. All data needs to be mock, and the mock data is mainly the response data to call the downstream interface. The mock data can be written into Redis.

(4) Comparison configuration + data comparison

Comparison Configuration General configuration In the configuration center, you can configure and manage table fields based on actual dimensions. For example, some time fields can be configured to be ignored. Interface and MQ parameters, such as order number and delivery time, can also be configured to be ignored.

(5) Analysis of consistency of results

The comparison tool can send the comparison results to ES, through which we can filter the corresponding comparison results, consistency rate and reasons of inconsistency according to specific buried point actionType.

Four,

Online traffic contrast scheme is based on the basic business overall point, of a business process involved in the specific interface, mq message needs to have a comprehensive combing, it should be pointed out that, to really use real time contrast scheme, the premise of knowing in advance iterative risk we can release contrast application at any time, this don’t do limits should be placed on top. Our vision is that development can secure live code even without testing, and development itself can form a closed loop. Some advantages and disadvantages of this comparison scheme are as follows:

advantages

(1) Problems existing in code reconstruction and version iteration changes can be found in time and repaired in time. Potential problems can be exposed in advance without waiting for testing to be found after testing. Don’t rely too much on testing to find problems;

(2) Release regression testing resources to a certain extent;

(3) Ensure the quality of the whole RESEARCH and development process;

(4) Can improve the release frequency;

(5) Comparison applications do not need to set up a separate comparison database for comparison, reducing the cost of comparison;

(6) Comparison application and comparison tool as non-core application, change with the release, there is a certain flexibility;

(7) Comparison content flexible configuration;

disadvantages

(1) There is some level of intrusion into the code and a comparison MQ message needs to be sent

(2) For incremental business, there is no effective way to ensure code quality because there is no reference object for comparison. Only UT unit test, code review and other means can be used to assist.

The text/HUZHIMIN

Pay attention to the technology, do the most fashionable technology!