locust-cloud 1.1.1__py3-none-any.whl → 1.2.1__py3-none-any.whl

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.
locust_cloud/cloud.py CHANGED
@@ -6,6 +6,7 @@ import os
6
6
  import sys
7
7
  import time
8
8
  import tomllib
9
+ from argparse import Namespace
9
10
  from collections import OrderedDict
10
11
  from datetime import UTC, datetime, timedelta
11
12
  from typing import IO, Any
@@ -82,6 +83,14 @@ parser.add_argument(
82
83
  help="The Python file or module that contains your test, e.g. 'my_test.py'. Defaults to 'locustfile.py'.",
83
84
  env_var="LOCUST_LOCUSTFILE",
84
85
  )
86
+ parser.add_argument(
87
+ "-u",
88
+ "--users",
89
+ type=int,
90
+ default=1,
91
+ help="Number of users to launch. This is the same as the regular Locust argument, but also decides how many workers to launch by default.",
92
+ env_var="LOCUST_USERS",
93
+ )
85
94
  parser.add_argument(
86
95
  "-r",
87
96
  "--requirements",
@@ -155,13 +164,16 @@ parser.add_argument(
155
164
  )
156
165
  parser.add_argument(
157
166
  "--workers",
158
- type=str,
167
+ type=int,
159
168
  help="Number of workers to use for the deployment",
160
169
  env_var="LOCUST_CLOUD_WORKERS",
161
170
  default=None,
162
171
  )
163
172
 
164
173
  options, locust_options = parser.parse_known_args()
174
+ options: Namespace
175
+ locust_options: list
176
+
165
177
  logging.basicConfig(
166
178
  format="[LOCUST-CLOUD] %(levelname)s: %(message)s",
167
179
  level=options.loglevel.upper(),
@@ -178,8 +190,7 @@ logging.getLogger("urllib3").setLevel(logging.INFO)
178
190
  def main() -> None:
179
191
  s3_bucket = f"{options.kube_cluster_name}-{options.kube_namespace}"
180
192
  deployed_pods: list[Any] = []
181
- worker_count = options.workers or math.ceil(locust_options.users / USERS_PER_WORKER)
182
- worker_count = worker_count if worker_count > 2 else 2
193
+ worker_count: int = max(options.workers or math.ceil(options.users / USERS_PER_WORKER), 2)
183
194
 
184
195
  try:
185
196
  if not (
@@ -190,7 +201,7 @@ def main() -> None:
190
201
  )
191
202
  sys.exit(1)
192
203
 
193
- logger.info(f"Logging you into Locust Cloud ({options.aws_region_name}, v{__version__})")
204
+ logger.info(f"Authenticating ({options.aws_region_name}, v{__version__})")
194
205
  logger.debug(f"Lambda url: {options.lambda_url}")
195
206
  credential_manager = CredentialManager(
196
207
  lambda_url=options.lambda_url,
@@ -252,6 +263,7 @@ def main() -> None:
252
263
  payload = {
253
264
  "locust_args": [
254
265
  {"name": "LOCUST_LOCUSTFILE", "value": locustfile_url},
266
+ {"name": "LOCUST_USERS", "value": str(options.users)},
255
267
  {"name": "LOCUST_REQUIREMENTS_URL", "value": requirements_url},
256
268
  {"name": "LOCUST_FLAGS", "value": " ".join(locust_options)},
257
269
  {"name": "LOCUST_WEB_HOST_DISPLAY_NAME", "value": "_____"},
@@ -268,6 +280,7 @@ def main() -> None:
268
280
  "AWS_SESSION_TOKEN": aws_session_token,
269
281
  }
270
282
  try:
283
+ # logger.info(payload) # might be useful when debugging sometimes
271
284
  response = requests.post(deploy_endpoint, json=payload, headers=headers)
272
285
  except requests.exceptions.RequestException as e:
273
286
  logger.error(f"Failed to deploy the load generators: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: locust-cloud
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: Locust Cloud
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: blessed==1.20.0
@@ -1,6 +1,6 @@
1
1
  locust_cloud/__init__.py,sha256=51wdjGT0nqS5dVuFVDMhthnPacrctteiCMrwRqaPaQg,1867
2
2
  locust_cloud/auth.py,sha256=2fcTIq0tYDckDsZZ7yFTHZn5nG7Ir1dlV1QIu_tp3JA,3164
3
- locust_cloud/cloud.py,sha256=dsWd66H2-xPX4A5f2lsXUzPaOaFFVQ6VXerNoLwDl4E,14660
3
+ locust_cloud/cloud.py,sha256=gEiP2Lq7iQbWYiuuDbLmMgv5CUTUrYJ1uRzAgFv2cHw,15062
4
4
  locust_cloud/constants.py,sha256=YGgIEnaOT9cAA8F8a8Z8lOmlI78D2fXiVpP0RF213MA,167
5
5
  locust_cloud/credential_manager.py,sha256=JbuS22RTGAmngVB9DFLxHIgaonCSImemMGvtWnxBZRE,5515
6
6
  locust_cloud/timescale/exporter.py,sha256=j1K-czMUdOLFt5Sop0PTF6TL52vYdngEEI5OEM3Xl60,11128
@@ -15,7 +15,7 @@ locust_cloud/webui/vite.config.ts,sha256=cqxPMkbwEA3H9mGGbuPulQUhIHCosUqm_1usxzs
15
15
  locust_cloud/webui/yarn.lock,sha256=OgV48S7IOMpqldFPL5MFG1fjP8HTcDlFSFzMuRCkGWU,216596
16
16
  locust_cloud/webui/dist/index.html,sha256=aWAK1eKa4qBfhMonHNf2sHC6iY9RoTzNdvFcc33Wtp4,664
17
17
  locust_cloud/webui/dist/assets/index-BG65KOq7.js,sha256=vKgju6VqTxkI5yFtyDr6zGtb3D7V_AcVCYPDm4SeJos,2795922
18
- locust_cloud-1.1.1.dist-info/METADATA,sha256=elp0Ed2GG711cfPDWQADDtRK0Rr5mINTOCHi7jr8YlE,2188
19
- locust_cloud-1.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
20
- locust_cloud-1.1.1.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
21
- locust_cloud-1.1.1.dist-info/RECORD,,
18
+ locust_cloud-1.2.1.dist-info/METADATA,sha256=1DFZwFeySGGILvXwuXHtg1rbrnUbv7BQ6_07uoRgAF4,2188
19
+ locust_cloud-1.2.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
20
+ locust_cloud-1.2.1.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
21
+ locust_cloud-1.2.1.dist-info/RECORD,,