Explorer reports addition
We have added a new Explorer feature to reports, with a timeline scrubber and easy anomaly detection.
Guide on load testing real-time GraphQL subscriptions with LoadForge using Locust.
LoadForge can record your browser, graphically build tests, scan your site with a wizard and more. Sign up now to run your first test.
GraphQL subscriptions provide real-time data streams over WebSockets. LoadForge supports subscription load testing by leveraging Locust and the WebSocketUser from locust-plugins.
# locust.py
import json
from locust import between, task
from locust_plugins.users import WebSocketUser
class GraphqlSubsUser(WebSocketUser):
wait_time = between(1, 3)
host = "wss://api.yourdomain.com/graphql"
def on_start(self):
# Open WebSocket connection
self.connect("/graphql")
# Initialize the subscription
init_msg = {"type": "connection_init", "payload": {}}
self.send(json.dumps(init_msg))
self.receive()
# Start subscription
sub_msg = {
"id": "1",
"type": "start",
"payload": {"query": "subscription { newMessage { content sender } }"}
}
self.send(json.dumps(sub_msg))
@task
def listen(self):
# Receive a subscription event
event = self.receive()
data = json.loads(event)
print(data)
Notes:
pip install locust locust-plugins websockets if you wish to test locally.host and GraphQL query with your subscription endpoint.