Skip to content

Commit ef8cb1b

Browse files
committed
Added README
1 parent 3ea156c commit ef8cb1b

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

neptune-locust/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Locust Users for Amazon Neptune database
2+
3+
[Locust](https://locust.io/) is a powerful open source load testing tool that allows users to create rich and complex load testing scenarios that can be distributed.
4+
5+
The [User](https://docs.locust.io/en/stable/writing-a-locustfile.html#user-class) class in Locust represents a user/scenario for a test run. While Locust provides base classes for HTTP based traffic it relies on third party libraries to support other protocols.
6+
7+
This library helps you to performance tests on Amazon Neptune using Locust by providing rich User classes for testing using the [Amazon Boto3 SDK](https://boto3.amazonaws.com/), [Gremlin Python](https://pypi.org/project/gremlinpython/), and [Amazon Neptune Bolt](https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-opencypher-bolt.html).
8+
9+
## Installation
10+
11+
### Prerequisites
12+
13+
* Python 3.12 or greater
14+
15+
To install the package you can use the following command:
16+
17+
`pip install <URL to Desired Github Release>`
18+
19+
20+
## Usage
21+
22+
These instructions are not meant as a complete tutorial on how to construct and build Locust tests.
23+
To understand the specifics of how to run Locust tests please refer to the Locust [Documentation](https://docs.locust.io/en/stable/what-is-locust.html).
24+
25+
26+
Each of the `User` classes implements the standard interface with a `query()` method to run using the different protocols.
27+
28+
* `NeptuneUser` - This is a Locust `User` class that uses the boto3 SDK to run either openCypher or Gremlin queries against both Neptune Analytics and Neptune Database instances
29+
* `GremlinDriverUser` - This is a Locust `User` class that uses the TinkerPop Gremlin Python driver and a web socket connection to Neptune Database
30+
* `Bolt` - This is a Locust `User` class that uses the bolt driver and a web socket connection to Neptune Database
31+
32+
Both the `NeptuneUser` and `GremlinDriverUser` classes will automatically create the underlying drivers required for both IAM and non-IAM authenticated requests. The `NeptuneUser` class will handle this without any changes required to your code. The `GremlinDriverUser` requires that you set an environment variable `USE_IAM` to `"true"` to enable signing of these requests.
33+
34+
The `BoltUser` requires that you create the `Driver` external to the class, such as using the `on_start` [Event Hook](https://docs.locust.io/en/stable/extending-locust.html) which is then passed to the `connect(driver)` method. In addition to the `User` classes above we have also provided a `NeptuneBoltAuthToken` class which can be used in conjunction with the bolt driver to add SigV4 authorization headers to bolt requests as are required by IAM enabled clusters. An example of how to achieve this is shown below.
35+
36+
```
37+
driver = GraphDatabase.driver(self.host, auth=NeptuneBoltAuthToken(self.host), encrypted=True)
38+
self.connect(driver)
39+
```
40+
41+
## Examples
42+
43+
Within this repository, there are [example locustfiles](https://docs.locust.io/en/stable/what-is-locust.htm) located in the `/examples` folder showing how to use each of the 3 User Classes.

neptune-locust/examples/gremlindriver_locustfile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class Example_GremlinDriver(GremlinDriverUser):
99
# You can set the host explicitly here if you want to do this for debugging
1010
# host = "wss://<INSERT CLUSTER:PORT URL HERE>"
1111

12+
# Uncomment this if you want to use IAM auth
13+
# def on_start(self):
14+
# os.environ["USE_IAM"] = "true"
15+
1216
@task
1317
def task(self):
1418
resp = self.query(self.g.inject(1), name=self.__class__.__name__)

neptune-locust/pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ classifiers = [
1616
]
1717
license = "Apache 2"
1818
license-files = ["LICEN[CS]E*"]
19-
19+
dependencies = [
20+
"locust>=2.32.4",
21+
"boto3>=1.35.78",
22+
"gremlinpython>=3.7.3",
23+
"neo4j>=5.27.0"
24+
]
2025

2126
[build-system]
2227
requires = ["poetry-core"]

0 commit comments

Comments
 (0)