Comments (3)
Hi @sribatchu,
it always seem to ignore the LoadTestShape and just uses the num_users and spawn_rate from the event payload
Hmmm, I see.
I've just thought about it and even if we do manage to find and use the LoadTestShape
class, it still won't work because it counts the time since the load test started. This will never work on Lambda in its current implementation as the counter would be restarted for every lambda invocation.
The only way it could theoretically work is if invokust saved the start time externally and then counted the time using this external record. This would require a custom LoadTestShape
class just for invokust though. PRs welcome 🙂
from invokust.
There's no reason why not
from invokust.
when running it as lambda, it always seem to ignore the LoadTestShape
and just uses the num_users
and spawn_rate
from the event payload. If I don't pass num_users
or spawn_rate
as part of my event payload, I get Locust exception Exception('configuration error, attribute not set: num_users')
lambda.py
def lambda_handler(event, context=None):
try:
if event:
settings = create_settings(**event)
else:
settings = create_settings(from_environment=True)
loadtest = LocustLoadTest(settings)
loadtest.run()
except Exception as e:
logging.error("Locust exception {0}".format(repr(e)))
else:
locust_stats = loadtest.stats()
lambda_runtime_info = get_lambda_runtime_info(context)
loadtest_results = locust_stats.copy()
loadtest_results.update(lambda_runtime_info)
json_results = json.dumps(loadtest_results)
logging.info(json_results)
return json_results
locustfile.py
class LoadTest(HttpUser):
wait_time = between(0, 1)
@task
def query(self):
self.client.get("/api")
class StagesShapeWithCustomUsers(LoadTestShape):
stages = [
{"duration": 10, "users": 100, "spawn_rate": 10, "user_classes": [LoadTest]},
{"duration": 20, "users": 150, "spawn_rate": 10, "user_classes": [LoadTest]},
{"duration": 30, "users": 200, "spawn_rate": 10, "user_classes": [LoadTest]}
]
def tick(self):
run_time = self.get_run_time()
for stage in self.stages:
if run_time < stage["duration"]:
try:
tick_data = (stage["users"], stage["spawn_rate"], stage["user_classes"])
except KeyError:
tick_data = (stage["users"], stage["spawn_rate"])
return tick_data
return None
from invokust.
Related Issues (20)
- Error invoking lambda following quickstart HOT 3
- Semantic versioning HOT 2
- version 0.75 missing for Pypi HOT 3
- AWS deployment fails HOT 8
- Handle environment variables with `LambdaLoadTest` on Locust HOT 4
- Ability to deploy Lambda through AWS-CDK instead of using local script HOT 1
- Locust exception ImportError("cannot import name 'User'",) HOT 6
- Unable to use invokust. locust version == 1.3.0, locustio==0.13.5, invokust==0.73 HOT 6
- gevent error when attempting to invoke lambda HOT 3
- Does add_listener work? HOT 3
- No results when using LambdaLoadTest HOT 2
- segmentation fault (core dumped) HOT 4
- Can you output CSV or HTML reports?
- AWS Lambda deployment with function layer
- Negative execution time
- Use invokust with odoo HOT 3
- no option to save the load test report HOT 1
- Logging Configuration HOT 3
- AttributeError: 'StatsError' object has no attribute 'to_dict' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invokust.