fix: update locust files for current locust version
This commit is contained in:
parent
fccaff8885
commit
73ea4bc017
2 changed files with 49 additions and 55 deletions
|
@ -32,4 +32,4 @@ if test $STATUSCODE -ne 200; then
|
|||
fi
|
||||
|
||||
# else, run loadgen
|
||||
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1
|
||||
locust --host="http://${FRONTEND_ADDR}" --headless --users "${USERS:-10}" 2>&1
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import random
|
||||
from locust import HttpLocust, TaskSet, between
|
||||
from locust import HttpUser, between, task
|
||||
|
||||
products = [
|
||||
'0PUK6V6EV0',
|
||||
|
@ -26,31 +26,40 @@ products = [
|
|||
'9SIQT8TOJO',
|
||||
'L9ECAV7KIM',
|
||||
'LS4PSXUNUM',
|
||||
'OLJCESPC7Z']
|
||||
'OLJCESPC7Z'
|
||||
]
|
||||
|
||||
def index(l):
|
||||
class MyUser(HttpUser):
|
||||
wait_time = between(5, 15)
|
||||
|
||||
@task(1)
|
||||
def index(l):
|
||||
l.client.get("/")
|
||||
|
||||
def setCurrency(l):
|
||||
@task(2)
|
||||
def setCurrency(l):
|
||||
currencies = ['EUR', 'USD', 'JPY', 'CAD']
|
||||
l.client.post("/setCurrency",
|
||||
{'currency_code': random.choice(currencies)})
|
||||
|
||||
def browseProduct(l):
|
||||
@task(10)
|
||||
def browseProduct(l):
|
||||
l.client.get("/product/" + random.choice(products))
|
||||
|
||||
def viewCart(l):
|
||||
@task(3)
|
||||
def viewCart(l):
|
||||
l.client.get("/cart")
|
||||
|
||||
def addToCart(l):
|
||||
@task(2)
|
||||
def addToCart(l):
|
||||
product = random.choice(products)
|
||||
l.client.get("/product/" + product)
|
||||
l.client.post("/cart", {
|
||||
'product_id': product,
|
||||
'quantity': random.choice([1,2,3,4,5,10])})
|
||||
|
||||
def checkout(l):
|
||||
addToCart(l)
|
||||
@task(1)
|
||||
def checkout(l):
|
||||
l.client.post("/cart/checkout", {
|
||||
'email': 'someone@example.com',
|
||||
'street_address': '1600 Amphitheatre Parkway',
|
||||
|
@ -64,18 +73,3 @@ def checkout(l):
|
|||
'credit_card_cvv': '672',
|
||||
})
|
||||
|
||||
class UserBehavior(TaskSet):
|
||||
|
||||
def on_start(self):
|
||||
index(self)
|
||||
|
||||
tasks = {index: 1,
|
||||
setCurrency: 2,
|
||||
browseProduct: 10,
|
||||
addToCart: 2,
|
||||
viewCart: 3,
|
||||
checkout: 1}
|
||||
|
||||
class WebsiteUser(HttpLocust):
|
||||
task_set = UserBehavior
|
||||
wait_time = between(1, 10)
|
||||
|
|
Loading…
Add table
Reference in a new issue