tmp.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import json
  2. import unittest
  3. import requests
  4. def print_json_pretty(obj):
  5. print(json.dumps(obj, indent=4, ensure_ascii=False))
  6. def print_json_plain(obj):
  7. print(json.dumps(obj, ensure_ascii=False))
  8. def req(url, json_dict):
  9. res = requests.post(url, json=json_dict, headers={
  10. "cookie": "lang=zh-CN; MJSESSIONID=YmQ1YTAyOTktMjBiMy00MmZhLWJmMmUtNjQyODJmYjU0ODM4; satoken-server=d6e42d1a-2372-4746-a032-f5690ff6fbbc"})
  11. print_json_plain(json_dict)
  12. print_json_pretty(res.json())
  13. class MyTest(unittest.TestCase):
  14. def test1(self):
  15. json_dict = {
  16. "name": "wwW",
  17. "type": "MYSQL",
  18. "description": "dolor dolor tempor",
  19. "ip": "eip-mysql-2.qa.mlamp.cn",
  20. "port": 3306,
  21. "index_name": "",
  22. "db_name": "hao_rec_pro",
  23. "userName": "hao_rec",
  24. "passwd": "Hao_rec@123456"
  25. }
  26. req("http://127.0.0.1:8500/ui/datasource/newDataSource", json_dict)
  27. # 测试死锁
  28. def test2(self):
  29. req(1, '粉底液', '祛痘')
  30. req(1, '眼霜', '修护')
  31. # 测试兜底策略
  32. def test3(self):
  33. req(1, '', '')
  34. def test4(self):
  35. data = {"name": "p_00x32cx6bo7_count", "data": [
  36. {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
  37. "action_value": "exposure"},
  38. {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
  39. "action_value": "exposure"},
  40. {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
  41. "action_value": "exposure"},
  42. {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
  43. "action_value": "exposure"}]}
  44. url = "http://10.20.2.200:31669/api/hao_rec/about_log/log_counter"
  45. for x in range(100):
  46. res = requests.post(url, json=data)
  47. print(res.text)