Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #209 from weaveworks/load-test-fix
Browse files Browse the repository at this point in the history
load test fixes
  • Loading branch information
Phil Winder committed Aug 2, 2016
2 parents ffb18d6 + e504e39 commit a0aafea
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions load-test/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from random import randint
import base64
import time
import uuid

counter = 0

Expand Down Expand Up @@ -33,21 +34,21 @@ def purchaseItem(self):
self.buy()
self.deleteCustomer()

@task
def addRemoveFromCart(self):
self.createCustomer()
self.login()
self.addItemToCart()
self.removeItemFromCart()
self.deleteCustomer()
# @task
# def addRemoveFromCart(self):
# self.createCustomer()
# self.login()
# self.addItemToCart()
# self.removeItemFromCart()
# self.deleteCustomer()

def removeItemFromCart(self):
self.client.delete("/cart/" + self.cart_id + "/items/" + self.item_id)

@task
# @task
def addItemToCart(self):
cart = self.client.get("/cart")

cart = self.client.get("/cart")
catalogue = self.client.get("/catalogue?size=100")
sizeResponse = self.client.get("/catalogue/size")
size = sizeResponse.json()["size"]
Expand All @@ -70,18 +71,19 @@ def createCustomer(self):
# TODO just use same address/card for all generated customers?
address = self.client.post("/addresses", json={"street": "my road", "number": "3", "country": "UK", "city": "London"})

self.address_id = address.json()["_links"]["self"]["href"][27:]
self.address_id = address.json()["_links"]["self"]["href"][26:]
card = self.client.post("/cards", json={"longNum": "5429804235432", "expires": "04/16", "ccv": "432"})

self.card_id = card.json()["_links"]["self"]["href"][23:]
self.card_id = card.json()["_links"]["self"]["href"][22:]
global counter
counter += 1
self.username = "test_user_" + str(counter)
self.username = "test_user_" + str(uuid.uuid4())

self.password = "test_password"
customer = self.client.post("/customers", json={"firstName": "testUser_" + str(counter), "lastName": "Last_Name", "username": self.username, "addresses": ["http://accounts/addresses/" + self.address_id], "cards": ["http://accounts/cards/" + self.card_id]})

self.cust_id = customer.json()["_links"]["self"]["href"][27:]
self.client.get("/register?username=" + "test_user_" + str(counter) + "&password=" + self.password)
self.client.get("/register?username=" + self.username + "&password=" + self.password)

def deleteCustomer(self):
self.client.delete("/customers/" + self.cust_id)
Expand Down

0 comments on commit a0aafea

Please sign in to comment.