stac-api-load-testing 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jonathan Healy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: stac_api_load_testing
3
+ Version: 0.2.0
4
+ Summary: Load testing for stac compliant apis
5
+ Home-page: https://github.com/Healy-Hyperspatial/stac-api-load-testing
6
+ Author: Jonathan Healy
7
+ Author-email: jonathan.d.healy@gmail.com
8
+ License: MIT
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: click>=7.1.2
13
+ Requires-Dist: locust
14
+ Requires-Dist: setuptools
15
+ Requires-Dist: Cython
16
+ Requires-Dist: bzt
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest; extra == "test"
19
+
20
+ # stac-api-load-testing
21
+ Taurus and Locust load testing tools for stac-api backends.
22
+
23
+ ![Alt text](readme_files/taurus-pgstac.png?raw=true "stac-fastapi-pgstac")
24
+
25
+
26
+ ## Run stac-fastapi backends locally (elasticsearch|opensearch|pgstac|mongo)
27
+ ```$ docker-compose up elasticsearch```
28
+ ```$ docker-compose up app-elasticsearch```
29
+
30
+ ## Install locally for development
31
+ ```$ pip install -e .```
32
+
33
+ ## Install from PyPI
34
+ ```$ pip install stac-api-load-testing```
35
+
36
+ ```
37
+ Usage: stac-api-load-testing [OPTIONS]
38
+
39
+ Entry point for the stac-api-load-testing CLI tool.
40
+
41
+ This tool facilitates data ingestion, Locust load testing, and Taurus
42
+ performance testing against a specified STAC API endpoint.
43
+
44
+ Args:
45
+ ingest (bool): If True, ingest sample data into the specified STAC API.
46
+ locust (bool): If True, execute Locust load tests against the
47
+ specified STAC API.
48
+ taurus (bool): If True, perform Taurus performance
49
+ testing with custom settings against the specified STAC API.
50
+ concurrency (int): Specifies the number of concurrent users for Taurus testing. Default is 10.
51
+ ramp_up (str): Specifies the ramp-up period for Taurus testing, in Taurus notation (e.g., '1m' for 1 minute). Default is '1m'.
52
+ iterations (int): Specifies the number of iterations each virtual user will
53
+ execute in Taurus testing. Default is 100.
54
+ api_address (str): The base URL of the STAC API to be tested.
55
+
56
+ Options:
57
+ -i, --ingest Ingest sample data into the STAC API.
58
+ -l, --locust Run Locust load tests against the STAC API.
59
+ -t, --taurus Run the Taurus wrapper for performance testing
60
+ against the STAC API.
61
+ -c, --concurrency INTEGER Number of concurrent users for Taurus option.
62
+ -r, --ramp-up TEXT Ramp-up time for Taurus option.
63
+ -n, --iterations INTEGER Number of iterations for Taurus option.
64
+ -a, --api-address TEXT Specify the STAC API URL to test against.
65
+ --version Show the version and exit.
66
+ --help Show this message and exit.
67
+ ```
68
+
69
+ ## Ingest test data - http://localhost:8084 is just an example url
70
+ ```$ stac-api-load-testing --ingest --api-address http://localhost:8084```
71
+
72
+ ## Run Locust Load Testing Ouside of Taurus Wrapper
73
+ ```$ stac-api-load-testing --locust --api-address http://localhost:8084```
74
+ - go to ```http://localhost:8089``` and start with desired settings
75
+
76
+ ## Inside of Taurus Wrapper
77
+ ```$ stac-api-load-testing --taurus --api-address http://localhost:8084```
78
+
79
+ ## Debugging Locust tasks using a single simulated user
80
+ ```$ python stac_api_load_testing/config_files/locustfile.py```
@@ -0,0 +1,61 @@
1
+ # stac-api-load-testing
2
+ Taurus and Locust load testing tools for stac-api backends.
3
+
4
+ ![Alt text](readme_files/taurus-pgstac.png?raw=true "stac-fastapi-pgstac")
5
+
6
+
7
+ ## Run stac-fastapi backends locally (elasticsearch|opensearch|pgstac|mongo)
8
+ ```$ docker-compose up elasticsearch```
9
+ ```$ docker-compose up app-elasticsearch```
10
+
11
+ ## Install locally for development
12
+ ```$ pip install -e .```
13
+
14
+ ## Install from PyPI
15
+ ```$ pip install stac-api-load-testing```
16
+
17
+ ```
18
+ Usage: stac-api-load-testing [OPTIONS]
19
+
20
+ Entry point for the stac-api-load-testing CLI tool.
21
+
22
+ This tool facilitates data ingestion, Locust load testing, and Taurus
23
+ performance testing against a specified STAC API endpoint.
24
+
25
+ Args:
26
+ ingest (bool): If True, ingest sample data into the specified STAC API.
27
+ locust (bool): If True, execute Locust load tests against the
28
+ specified STAC API.
29
+ taurus (bool): If True, perform Taurus performance
30
+ testing with custom settings against the specified STAC API.
31
+ concurrency (int): Specifies the number of concurrent users for Taurus testing. Default is 10.
32
+ ramp_up (str): Specifies the ramp-up period for Taurus testing, in Taurus notation (e.g., '1m' for 1 minute). Default is '1m'.
33
+ iterations (int): Specifies the number of iterations each virtual user will
34
+ execute in Taurus testing. Default is 100.
35
+ api_address (str): The base URL of the STAC API to be tested.
36
+
37
+ Options:
38
+ -i, --ingest Ingest sample data into the STAC API.
39
+ -l, --locust Run Locust load tests against the STAC API.
40
+ -t, --taurus Run the Taurus wrapper for performance testing
41
+ against the STAC API.
42
+ -c, --concurrency INTEGER Number of concurrent users for Taurus option.
43
+ -r, --ramp-up TEXT Ramp-up time for Taurus option.
44
+ -n, --iterations INTEGER Number of iterations for Taurus option.
45
+ -a, --api-address TEXT Specify the STAC API URL to test against.
46
+ --version Show the version and exit.
47
+ --help Show this message and exit.
48
+ ```
49
+
50
+ ## Ingest test data - http://localhost:8084 is just an example url
51
+ ```$ stac-api-load-testing --ingest --api-address http://localhost:8084```
52
+
53
+ ## Run Locust Load Testing Ouside of Taurus Wrapper
54
+ ```$ stac-api-load-testing --locust --api-address http://localhost:8084```
55
+ - go to ```http://localhost:8089``` and start with desired settings
56
+
57
+ ## Inside of Taurus Wrapper
58
+ ```$ stac-api-load-testing --taurus --api-address http://localhost:8084```
59
+
60
+ ## Debugging Locust tasks using a single simulated user
61
+ ```$ python stac_api_load_testing/config_files/locustfile.py```
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,35 @@
1
+ """stac-api-load-testing setup.py."""
2
+ from setuptools import setup
3
+
4
+ __version__ = "0.2.0"
5
+
6
+ with open("README.md", "r") as fh:
7
+ long_description = fh.read()
8
+
9
+ setup(
10
+ name="stac_api_load_testing",
11
+ version=__version__,
12
+ description="Load testing for stac compliant apis",
13
+ url="https://github.com/Healy-Hyperspatial/stac-api-load-testing",
14
+ include_package_data=True,
15
+ install_requires=[
16
+ "click>=7.1.2",
17
+ "locust",
18
+ "setuptools",
19
+ "Cython",
20
+ "bzt",
21
+ ],
22
+ packages=["stac_api_load_testing"],
23
+ entry_points={
24
+ "console_scripts": ["stac-api-load-testing=stac_api_load_testing.cli:main"]
25
+ },
26
+ author="Jonathan Healy",
27
+ author_email="jonathan.d.healy@gmail.com",
28
+ license="MIT",
29
+ long_description=long_description,
30
+ long_description_content_type="text/markdown",
31
+ python_requires=">=3.7",
32
+ extras_require={
33
+ "test": ["pytest"],
34
+ },
35
+ )
@@ -0,0 +1,143 @@
1
+ """stac-api-load-testing cli tool."""
2
+ import os
3
+ import re
4
+ import subprocess
5
+
6
+ import click
7
+ import pkg_resources # type: ignore
8
+ import yaml # type: ignore
9
+
10
+ from .data_loader import data_loader
11
+
12
+
13
+ def generate_taurus_config(api_url: str, concurrency: int, ramp_up, iterations) -> str:
14
+ """
15
+ Generate a custom Taurus configuration file based on the specified settings.
16
+
17
+ Args:
18
+ api_url (str): The base URL for the STAC API to be tested.
19
+ concurrency (int): The number of concurrent users to simulate.
20
+ ramp_up (str): The duration over which to ramp up the load test.
21
+ iterations (int): The total number of iterations to perform.
22
+
23
+ Returns:
24
+ str: The path to the generated Taurus configuration file.
25
+ """
26
+ template_path = pkg_resources.resource_filename(
27
+ __name__, "config_files/taurus_locust.yml"
28
+ )
29
+ locustfile_path = pkg_resources.resource_filename(
30
+ __name__, "config_files/locustfile.py"
31
+ )
32
+
33
+ safe_api_url = re.sub(r"[^a-zA-Z0-9]+", "_", api_url)
34
+ output_path = f"taurus_config_{safe_api_url}.yml"
35
+
36
+ try:
37
+ with open(template_path, "r") as file:
38
+ config = yaml.safe_load(file)
39
+
40
+ # Setting the script path directly to where `locustfile.py` is expected to be within the package
41
+ config["execution"][0]["concurrency"] = concurrency
42
+ config["execution"][0]["ramp-up"] = ramp_up
43
+ config["execution"][0]["iterations"] = iterations
44
+ config["scenarios"]["default"]["script"] = locustfile_path
45
+ config["scenarios"]["default"]["default-address"] = api_url
46
+
47
+ with open(output_path, "w") as file:
48
+ yaml.safe_dump(config, file)
49
+
50
+ return output_path
51
+ except Exception as e:
52
+ print(f"Error creating Taurus configuration file: {e}")
53
+ return None
54
+
55
+
56
+ @click.command()
57
+ @click.option(
58
+ "-i", "--ingest", is_flag=True, help="Ingest sample data into the STAC API."
59
+ )
60
+ @click.option(
61
+ "-l", "--locust", is_flag=True, help="Run Locust load tests against the STAC API."
62
+ )
63
+ @click.option(
64
+ "-t",
65
+ "--taurus",
66
+ is_flag=True,
67
+ help="Run the Taurus wrapper for performance testing against the STAC API.",
68
+ )
69
+ @click.option(
70
+ "-c",
71
+ "--concurrency",
72
+ default=10,
73
+ help="Number of concurrent users for Taurus option.",
74
+ type=int,
75
+ )
76
+ @click.option("-r", "--ramp-up", default="1m", help="Ramp-up time for Taurus option.")
77
+ @click.option(
78
+ "-n",
79
+ "--iterations",
80
+ default=100,
81
+ help="Number of iterations for Taurus option.",
82
+ type=int,
83
+ ) # Changed the flag to -n to avoid conflict
84
+ @click.option(
85
+ "-a",
86
+ "--api-address",
87
+ default="http://localhost:8080",
88
+ help="Specify the STAC API URL to test against.",
89
+ )
90
+ @click.version_option(version="0.2.0")
91
+ def main(
92
+ ingest: bool,
93
+ locust: bool,
94
+ taurus: bool,
95
+ api_address: str,
96
+ concurrency: int,
97
+ ramp_up: str,
98
+ iterations: int,
99
+ ):
100
+ """
101
+ Entry point for the stac-api-load-testing CLI tool.
102
+
103
+ This tool facilitates data ingestion, Locust load testing, and Taurus performance testing
104
+ against a specified STAC API endpoint.
105
+
106
+ Args:
107
+ ingest (bool): If True, ingest sample data into the specified STAC API.
108
+ locust (bool): If True, execute Locust load tests against the specified STAC API.
109
+ taurus (bool): If True, perform Taurus performance testing with custom settings against the specified STAC API.
110
+ concurrency (int): Specifies the number of concurrent users for Taurus testing. Default is 10.
111
+ ramp_up (str): Specifies the ramp-up period for Taurus testing, in Taurus notation (e.g., '1m' for 1 minute). Default is '1m'.
112
+ iterations (int): Specifies the number of iterations each virtual user will execute in Taurus testing. Default is 100.
113
+ api_address (str): The base URL of the STAC API to be tested.
114
+ """
115
+ os.environ["LOCUST_HOST"] = api_address
116
+
117
+ if ingest:
118
+ # Load data into the STAC API
119
+ data_loader.load_items(stac_api_base_url=api_address)
120
+ elif locust:
121
+ # Execute Locust load tests
122
+ locust_file_path = pkg_resources.resource_filename(
123
+ __name__, "config_files/locustfile.py"
124
+ )
125
+ subprocess.run(
126
+ ["locust", "--locustfile", locust_file_path, "--host", api_address],
127
+ check=True,
128
+ )
129
+ elif taurus:
130
+ # Generate and run a custom Taurus configuration for performance testing
131
+ config_file_path = generate_taurus_config(
132
+ api_address, concurrency, ramp_up, iterations
133
+ )
134
+ if config_file_path:
135
+ try:
136
+ subprocess.run(["bzt", config_file_path], check=True)
137
+ finally:
138
+ if os.path.exists(config_file_path):
139
+ os.remove(config_file_path) # Cleanup after running
140
+
141
+
142
+ if __name__ == "__main__":
143
+ main()
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: stac_api_load_testing
3
+ Version: 0.2.0
4
+ Summary: Load testing for stac compliant apis
5
+ Home-page: https://github.com/Healy-Hyperspatial/stac-api-load-testing
6
+ Author: Jonathan Healy
7
+ Author-email: jonathan.d.healy@gmail.com
8
+ License: MIT
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: click>=7.1.2
13
+ Requires-Dist: locust
14
+ Requires-Dist: setuptools
15
+ Requires-Dist: Cython
16
+ Requires-Dist: bzt
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest; extra == "test"
19
+
20
+ # stac-api-load-testing
21
+ Taurus and Locust load testing tools for stac-api backends.
22
+
23
+ ![Alt text](readme_files/taurus-pgstac.png?raw=true "stac-fastapi-pgstac")
24
+
25
+
26
+ ## Run stac-fastapi backends locally (elasticsearch|opensearch|pgstac|mongo)
27
+ ```$ docker-compose up elasticsearch```
28
+ ```$ docker-compose up app-elasticsearch```
29
+
30
+ ## Install locally for development
31
+ ```$ pip install -e .```
32
+
33
+ ## Install from PyPI
34
+ ```$ pip install stac-api-load-testing```
35
+
36
+ ```
37
+ Usage: stac-api-load-testing [OPTIONS]
38
+
39
+ Entry point for the stac-api-load-testing CLI tool.
40
+
41
+ This tool facilitates data ingestion, Locust load testing, and Taurus
42
+ performance testing against a specified STAC API endpoint.
43
+
44
+ Args:
45
+ ingest (bool): If True, ingest sample data into the specified STAC API.
46
+ locust (bool): If True, execute Locust load tests against the
47
+ specified STAC API.
48
+ taurus (bool): If True, perform Taurus performance
49
+ testing with custom settings against the specified STAC API.
50
+ concurrency (int): Specifies the number of concurrent users for Taurus testing. Default is 10.
51
+ ramp_up (str): Specifies the ramp-up period for Taurus testing, in Taurus notation (e.g., '1m' for 1 minute). Default is '1m'.
52
+ iterations (int): Specifies the number of iterations each virtual user will
53
+ execute in Taurus testing. Default is 100.
54
+ api_address (str): The base URL of the STAC API to be tested.
55
+
56
+ Options:
57
+ -i, --ingest Ingest sample data into the STAC API.
58
+ -l, --locust Run Locust load tests against the STAC API.
59
+ -t, --taurus Run the Taurus wrapper for performance testing
60
+ against the STAC API.
61
+ -c, --concurrency INTEGER Number of concurrent users for Taurus option.
62
+ -r, --ramp-up TEXT Ramp-up time for Taurus option.
63
+ -n, --iterations INTEGER Number of iterations for Taurus option.
64
+ -a, --api-address TEXT Specify the STAC API URL to test against.
65
+ --version Show the version and exit.
66
+ --help Show this message and exit.
67
+ ```
68
+
69
+ ## Ingest test data - http://localhost:8084 is just an example url
70
+ ```$ stac-api-load-testing --ingest --api-address http://localhost:8084```
71
+
72
+ ## Run Locust Load Testing Ouside of Taurus Wrapper
73
+ ```$ stac-api-load-testing --locust --api-address http://localhost:8084```
74
+ - go to ```http://localhost:8089``` and start with desired settings
75
+
76
+ ## Inside of Taurus Wrapper
77
+ ```$ stac-api-load-testing --taurus --api-address http://localhost:8084```
78
+
79
+ ## Debugging Locust tasks using a single simulated user
80
+ ```$ python stac_api_load_testing/config_files/locustfile.py```
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ stac_api_load_testing/cli.py
5
+ stac_api_load_testing.egg-info/PKG-INFO
6
+ stac_api_load_testing.egg-info/SOURCES.txt
7
+ stac_api_load_testing.egg-info/dependency_links.txt
8
+ stac_api_load_testing.egg-info/entry_points.txt
9
+ stac_api_load_testing.egg-info/requires.txt
10
+ stac_api_load_testing.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ stac-api-load-testing = stac_api_load_testing.cli:main
@@ -0,0 +1,8 @@
1
+ click>=7.1.2
2
+ locust
3
+ setuptools
4
+ Cython
5
+ bzt
6
+
7
+ [test]
8
+ pytest
@@ -0,0 +1 @@
1
+ stac_api_load_testing