# coding:utf-8 import sys reload(sys) sys.setdefaultencoding('utf8') import time from locust import HttpLocust,TaskSet,task import json class UserBehavior(TaskSet): def on_start(self): pass @task(1) def index2(self): data = {"userName":"ccc","botName":"hxw2303632","botId":"undefined" ,"conditionList":[ {"active":True,"conditionName":u"xihuan","relationHead":"#visitorname","relationTail":"?","relationName":u"relation-find-xihuan","question":u"你玩多久了?", "repeatList":[{"repeatString":u"#visitorname喜欢玩[]",u"repeatKeywords":u"+dota+王者荣耀"}, {"repeatString":u"#visitorname喜欢玩[]",u"repeatKeywords":u"+手游+休闲游戏+你管我"}] }, {"active":False ,"conditionName":u"buxihuan","relationHead":"#visitorname","relationTail":"?","relationName":u"relation-find-xihuan","question":u"你管我玩多久了?", "repeatList":[{"repeatString":u"#visitorname不喜欢玩[]",u"repeatKeywords":str(time.time())}] } ]} self.client.post('/saveAction',data=None,json=data) ''' @task(1) def index(self): data = {"botName":"hxw2303632""userName":"hxw","configList":[ {"nextStep":"there","reply":"say some thing","currentPremiseList":[{"actionName":"ask","keywords":"+xihuan+dota"}], "historyPremiseList":[{"actionName":"","keywords":""}] }, {"nextStep":"there","reply":"say some thing","currentPremiseList":[{"actionName":"ask","keywords":"+xihuan+dota"}], "historyPremiseList":[{"actionName":"","keywords":""}] } ]} self.client.post('/saveBackgroundConfig',data=None,json=data) ''' class WebsiteUser(HttpLocust): task_set = UserBehavior host = "http://192.168.1.178:1111" min_wait = 1000 max_wait = 1000