locust压webservice:python+locust+webservice


#coding=utf-8

from locust import HttpLocust,TaskSet,task,HttpUser
import requests
import json
import os
import suds.client
from suds.sax.text import Raw
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)



class zkcx_Test(TaskSet):

def on_start(self):
pass

  client = suds.client.Client('http://****:****/eif-server/webService/eifWebService?wsdl')
  print(client)


# --host=http://****:****/eif-server/webService/eifWebService?wsdl
  @task(1)
def res(self):

try:
option = Raw(
' ''

''
'ZZJ'
'ZZJ'

'
'

''

'H0001'
''

''
'ZZJ'
'
'

'
'

'
'
']]> '
  )

print(option)
result = self.client.service.acceptMessage(option)
print(result)
assert 'CA' in result
print('接口1调用成功{}'.format(result))

except Exception as msg:
print('webserice接口1调用失败%s' % (msg))



class Locust_Test(HttpUser):
tasks=[zkcx_Test]
host = 'http://****:****/eif-server/webService/eifWebService?wsdl'
  min_wait = 3000
  max_wait = 6000



if __name__ == '__main__':
import os
os.system("locust -f ****.py ")