Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Adding basic load test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Feb 28, 2024
1 parent f05b5ea commit 8ca6f99
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ build
*.ipr
*.iws
build-idea/
out/
out/

venv/
__pycache__/
24 changes: 24 additions & 0 deletions load-test/load-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
from locust import HttpUser, between, task

class OpenSearchUBIClient(HttpUser):
wait_time = between(1, 2)

@task
def event_task(self):
headers = {
"Content-Type": "application/json"
}
data = {
"type": "instant-search",
"keywords": "khgkj",
"timestamp": "1705596607509",
"url": "file:///C:/jason/_dev/search/OpenSearch/src/search-collector/demo/order.html",
"ref": "",
"lang": "en-US",
"session": "npckcy4",
"channel": "demo-channel",
"query": ""
}

self.client.post("/_plugins/ubi/mystore", headers=headers, json=data)
1 change: 1 addition & 0 deletions load-test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
locust==2.23.1
17 changes: 17 additions & 0 deletions load-test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

# Delete the store if it exists.
curl -X DELETE http://localhost:9200/_plugins/ubi/mystore

# Create the store
curl -X PUT http://localhost:9200/_plugins/ubi/mystore

# Insert events
locust -f load-test.py --headless -u 1 -r 1 --run-time 10s --host http://localhost:9200

# Let events index.
sleep 2

# Get count of indexed events.
EVENTS=`curl -s http://localhost:9200/.mystore_events/_count | jq .count`
echo "Found $EVENTS indexed"

0 comments on commit 8ca6f99

Please sign in to comment.