In daily work, it is necessary to call and test the Dubbo interface. Before, it was through script request. In order to achieve universality, a small testing tool platform was built, and the flow playback function will be added later to support pressure testing scenarios.
The platform uses Django REST Framework +VUE to separate the front end from the back end. The front end uses an open source project on the Internet. If necessary, please refer to github.com/PanJiaChen/…
Project start
Start background project
Git pull master TestPlatform github.com/627886474/T…
Modify your mysql configuration in Settings
Enter your Zookeeper address in config.ini
Then download the relevant dependency packages
pip install -r package.txt
1
Copy the code
Generate database tables
python manage.py makemigrations
python manage.py migrate
Copy the code
Finally, start the background service
python manage.py runserver
Copy the code
The service started successfully, and the front-end project is started
Start front-end projects
Git pulled the master code testplatform-web
Github.com/627886474/T… Go to the home directory
npm install
npm run dev
Copy the code
Interface demo
Registered users, mobile phone numbers and email addresses cannot be repeated
After successful registration, log in to the account and go to the background management page
Enter the Dubbo interface service call menu and fill in the related parameters. Please refer to the last description for input parameters of different Dubbo interfaces
When the request is complete, there is a record of the request that can be “filled in with one click.” This makes it easier for you to use someone else’s request parameters instead of concatenating your own
Request parameters:
There are four parameters:
Example request:
The methods in the service are:
Object addStudent(UserAO user)
{
"service_name":"com.zl.ITestService",
"dubbo_method":"add",
"params_type":"class",
"params":{
"class":"com.zl.entity.ao.UserAO",
"school":[
"1",
"2"
],
"name":"zl",
"tuofa":"true"
}
}
Copy the code
The methods in the service are:
Object getStudent(Integer ID, List name), arguments need to be wrapped in []
{
"service_name": "com.zl.ITestService",
"dubbo_method": "add",
"params_type":"others",
"params": [
123,
[
"zl"
]
]
}
Copy the code
Enumeration class request:
Object getStudent(Integer itemId, StudentEnum studentEnum);
Enumeration of the class name of the class: com. Zl. Item. The entity. StudentEnum
The enumeration class to use: GOOD_STUDENT, in the following format:
{
"service_name": "com.zl.ITestService",
"dubbo_method": "add",
"params_type":"others",
"params": [
123,{"name": "GOOD_STUDENT", "class": "com.zl.item.entity.StudentEnum "}
]
}
Copy the code
Common exceptions:
1. Request parameters are abnormal
If the parameter entered in the request Dubbo interface is incorrect, the error “No such method” will be reported. Please check whether the parameter is normal
2. Boolean data for input arguments
In JSON, just use {” data “:true}, but in Python requests, use” true “with double quotes
If you have any other questions, please leave a comment
Project address: github.com/627886474/T…