Article Directory
1. Introduction
1. What is diffy
From the official website
As a proxy, diffy forwards the received request to each running service, and collects the return value of each service for comparison
2. Working principle
2.1 Concept understanding
- diffy is the proxy in the picture, responsible for receiving requests
Requests can come from manual requests, automated testing, and online traffic
- Candidate, promary, and secondary in the figure represent three services
- candidate: The service to be returned, such as a refactored service
- primary: The service consistent with the online version
- secondary: Consistent with the primary service
2.2 Working principle
- After diffy receives the request, it forwards to the above 3 services respectively;
- Among them, the two service code versions of primary and secondary are consistent with the online, and secondary is used to reduce noise, such as time stamps, dates and other dynamically changing values, which need to be excluded;
- After removing the noise, compare the candidate and the primary, it will be different, so that the tester can compare
Two, actual combat
1 Deploy the service under test
Local environment demonstration, service is differentiated by port number
- Deployment primary, port number 9990
- Deploy secondary, port number 9991
- Deploy candidate, port number 9992
2 Start diffy (use docker mode)
docker run -d --name diffy-test \
-p 8880:8880 -p 8881:8881 -p 8888:8888 \
diffy/diffy \
-candidate=localhost:9992 \
-master.primary=localhost:9990 \
-master.secondary=localhost:9991 \
-responseMode='primary' \
-service.protocol=http \
-serviceName="Tier-Service" \
-proxy.port=:8880 \
-admin.port=:8881 \
-http.port=:8888 \
-rootUrl=localhost:8888 \
-summary.email='' "\
-summary.delay="5"
Parameter Description
- -p 8880:8880 is the port for receiving requests as a proxy, and all requests access this port
- -p 8881:8881 manages the diffy service visualization page
- -p 8888:8888 View the result web page
Remarks
-allowHttpSideEffects=true display POST, PUT, DELETE, for security, it will not be displayed by default
-service.protocol=https run through https protocol
-https.port=123 default 443, can be configured manually
3 Perform the test
http://localhost:8880/interface path
4 View results
diffy result: http://localhost:8888
diffy service management: http://localhost:8881/admin
Three, stepping on the pit record
The first time I got the docker start command from twitter's github address, and reported an error.
Solution:
Refer to the docker startup command in opendiffy, there will be a -summary.email parameter after it, and the startup is successful after adding it
Four, reference materials
-
twitter's github address
https://github.com/twitter-archive/diffy
-
github address of opendiffy
https://github.com/opendiffy/diffy
Opendiffy is now being maintained, so opendiffy can be used as the main reference