-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_post.py
83 lines (68 loc) · 2.55 KB
/
test_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import requests
import socket # 导入 socket 模块
import time
import json
import pprint
s = socket.socket() # 创建 socket 对象
host = socket.gethostname() # 获取本地主机名
port = 12345 # 设置端口
# # 0. 蹲饼器心跳测试
# instance_id = 'lwt-01'
# url = 'http://0.0.0.0:{}/heartbeat?instance_id={}'.format(port, instance_id)
# res = requests.get(url)
# print(res.content)
# # 1. 后端要求更新配置测试
# url = 'http://0.0.0.0:{}/schedular-update-config'.format(port)
# input_data = {'platform': 'weibo'}
# res = requests.post(url, json=input_data)
# print(res.content)
# 2. 蹲饼器心跳测试
headers = {'instance_id': 'lwt-01', 'instance_url': "http://127.0.0.1:8004"}
url = 'http://0.0.0.0:{}/heartbeat'.format(port)
res = requests.get(url, headers=headers)
print(res.content)
#
# headers = {'instance_id': 'lwt-02'}
# url = 'http://0.0.0.0:{}/heartbeat'.format(port)
# res = requests.get(url, headers=headers)
# print(res.content)
#
headers = {'instance_id': 'lwt-02', 'instance_url': "http://127.0.0.1:8002"}
url = 'http://0.0.0.0:{}/heartbeat'.format(port)
res = requests.get(url, headers=headers)
print(res.content)
#
# headers = {'instance_id': 'lwt-03', 'instance_url': "http://127.0.0.1:8003"}
# url = 'http://0.0.0.0:{}/heartbeat'.format(port)
# res = requests.get(url, headers=headers)
# print(res.content)
#
# headers = {'instance_id': 'lwt-04', 'instance_url': "http://127.0.0.1:8004"}
# url = 'http://0.0.0.0:{}/heartbeat'.format(port)
# res = requests.get(url, headers=headers)
# print(res.content)
time.sleep(3)
# 3. 报告蹲饼器对某平台异常测试
headers = {'instance_id': 'lwt-02'}
url = 'http://0.0.0.0:{}/report'.format(port)
input_data = {'type': 'unavailable_platform', 'value': 'weibo'}
res = requests.post(url, json=input_data, headers=headers)
print(res.content)
# 4. 蹲饼器获取配置测试
# headers = {'instance_id': 'lwt-02'}
# url = 'http://0.0.0.0:{}/fetcher-get-config'.format(port)
# res = requests.get(url, headers=headers)
# print('测试蹲饼器获取配置:')
# pprint.pprint(json.loads(res.content))
#
# headers = {'instance_id': 'lwt-03'}
# url = 'http://0.0.0.0:{}/fetcher-get-config'.format(port)
# res = requests.get(url, headers=headers)
# print('测试蹲饼器获取配置:')
# pprint.pprint(json.loads(res.content))
# 5. mook蹲饼器获取配置测试
print('测试standalone蹲饼器获取配置:')
url = 'http://0.0.0.0:{}/standalone-fetcher-get-config'.format(port)
input_data = {'datasource_id_list': [28, 25]}
res = requests.post(url, json=input_data)
pprint.pprint(json.loads(res.content))