li-clutter-org / loadimpact-sdk-python Goto Github PK
View Code? Open in Web Editor NEWLoad Impact SDK for Python
Home Page: http://developers.loadimpact.com/sdk/
License: Apache License 2.0
Load Impact SDK for Python
Home Page: http://developers.loadimpact.com/sdk/
License: Apache License 2.0
I'm working on a LUA script to run in a Load Impact test, and have been editing within the web interface. However, the time it takes to validate a script slows down the development process drastically. Is it possible to edit my script locally and test it via Load Impact, or locally with a similar environment?
Hi guys,
I might have discovered a small inconsistency within the Load Impact API. When updating a UserScenario it expects the field "data_stores" to be a json array of integers, but returns an array of objects on get requests.
When I fetch my user scenario from the api and want to update the load_script
user_scenario = UserScenario.get(client, USER_SCENARIO_ID)
user_scenario.load_script = "fancy script"
user_scenario.update()
I get the following validation error:
{"message":"Validation failed","errors":{"data_stores":"data stores needs to be a list with \\"id\\" integers"}}
So I checked the payload delivered by loadimpact and found that the field data_stores is not an array of integers:
{'created': datetime.datetime(2014, 6, 18, 13, 41, 46, tzinfo=<loadimpact.utils.UTC object at 0x109fc7c10>),
'data_stores': [{u'id': 1003310}],
'id': 1755045,
'load_script': u'fancy script',
'name': u'fancy-name',
'script_type': 'lua',
'updated': datetime.datetime(2014, 6, 20, 15, 26, 58, tzinfo=<loadimpact.utils.UTC object at 0x109fe5950>)}
Now, when I reset the data-store before the update, it works:
user_scenario = UserScenario.get(client, USER_SCENARIO_ID)
user_scenario.load_script = "fancy script"
user_scenario.data_stores = [DATA_STORE_ID]
user_scenario.update()
Kind regards,
Marcus
Python 2.7:
My code:
client.create_data_store({
'name': datastore_name,
'separator': 'comma',
'delimeter': 'double',
'fromline': 0
}, StringIO("test,test,test"))
Output (auth snipped):
send: 'POST /v2/data-stores HTTP/1.1\r\nHost: api.loadimpact.com\r\nContent-Length: 528\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nuser-agent: LoadImpactPythonSDK/1.1.3 (python 2.7.6; requests 2.7.0)\r\nConnection: keep-alive\r\nContent-Type: multipart/form-data; boundary=9d85bfe775eb4da6a4b39643d9b62963\r\nAuthorization: Basic {PRIVATE AUTH DATA}=\r\n\r\n--9d85bfe775eb4da6a4b39643d9b62963\r\nContent-Disposition: form-data; name="fromline"\r\n\r\n0\r\n--9d85bfe775eb4da6a4b39643d9b62963\r\nContent-Disposition: form-data; name="separator"\r\n\r\ncomma\r\n--9d85bfe775eb4da6a4b39643d9b62963\r\nContent-Disposition: form-data; name="name"\r\n\r\nSearches\r\n--9d85bfe775eb4da6a4b39643d9b62963\r\nContent-Disposition: form-data; name="delimeter"\r\n\r\ndouble\r\n--9d85bfe775eb4da6a4b39643d9b62963\r\nContent-Disposition: form-data; name="file"; filename="file"\r\n\r\ntest,test,test\r\n--9d85bfe775eb4da6a4b39643d9b62963--\r\n'
reply: 'HTTP/1.1 400 BAD REQUEST\r\n'
header: Allow: GET, POST, DELETE, HEAD, OPTIONS
header: Content-Type: application/json
header: Date: Mon, 14 Sep 2015 16:20:25 GMT
header: Server: nginx
header: Vary: Accept
header: X-Frame-Options: SAMEORIGIN
header: Content-Length: 115
header: Connection: keep-alive
Performing the same request using the curl command suggested on the docs page works successfully.
Your new test configuration example is not working: https://github.com/loadimpact/loadimpact-sdk-python#create-a-new-test-configuration.
I am getting:
File "assignment.py", line 122, in load.createTestConfiguration() File "assignment.py", line 104, in createTestConfiguration "loadzone": LoadZone.RACKSPACE_UK_LONDON File "/Library/Python/2.7/site-packages/loadimpact/clients.py", line 104, in create_test_config return TestConfig.create(self, data) File "/Library/Python/2.7/site-packages/loadimpact/resources.py", line 111, in create file_object=file_object) File "/Library/Python/2.7/site-packages/loadimpact/clients.py", line 51, in wrapper return func(*args, **kwargs) File "/Library/Python/2.7/site-packages/loadimpact/clients.py", line 193, in post return self._check_response(response) File "/Library/Python/2.7/site-packages/loadimpact/clients.py", line 235, in _check_response raise ClientError(msg, response=response) loadimpact.exceptions.ClientError: Validation failed (https://api.loadimpact.com/v2/test-configs)
I suspected that is not working because of subscription.
So i try to put duraion 60 and duration 1 since it is not clear what is duration on your api minutes or seconds?
How can I check why validation is failing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.