Skip to content

Commit

Permalink
test: fix typo in test.load.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gaudinnicolas committed Jul 5, 2024
1 parent 3bbe1b3 commit 898a29e
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .d4g-tools/bin/taipy/test.load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from locust import HttpUser, between, task


class HomeTest(HttpUser):
host = "https://carbonbombs-git-loadtesting-carbonbombs.vercel.app"

headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
"Accept": "*/*",
"Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate, br",
"Referer": "https://carbonbombs-git-loadtesting-carbonbombs.vercel.app/map",
"Content-Type": "text/plain;charset=UTF-8",
"Origin": "https://carbonbombs-git-loadtesting-carbonbombs.vercel.app",
"Connection": "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"TE": "trailers",
}

# Set the time to wait between two requests for one user
wait_time = between(1, 5)

def on_start(self):
"""
On start we clear the API cache
"""
pass

@task
def index(self):
self.client.get("/")

@task
def map(self):
self.client.get("/map")
payload = {
"query": "MATCH (p:carbon_bomb) WITH collect(properties(p)) as bombs RETURN bombs"
}
with self.client.post(
"/api/neo4j",
json=payload,
catch_response=True,
headers=self.headers,
) as response:
if response.status_code != 200:
response.failure(
f"map - Response code not 200 : {response.status_code} {response}"
)

@task
def filter_map(self):
payload = {
"query": 'MATCH (p:carbon_bomb)-[:OPERATES]-(c:company) WHERE c.name IN ["TotalEnergies SE"] WITH collect(properties(p)) as bombs RETURN bombs'
}

with self.client.post(
"/api/neo4j",
json=payload,
catch_response=True,
headers=self.headers,
) as response:
if response.status_code != 200:
response.failure(
f"filter_map - Response code not 200 : {response.status_code}"
)

0 comments on commit 898a29e

Please sign in to comment.