locust-cloud 1.5.1__py3-none-any.whl → 1.5.3__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
@@ -173,6 +173,13 @@ parser.add_argument(
173
173
  action="store_true",
174
174
  help="Delete a running cluster. Useful if locust-cloud was killed/disconnected or if there was an error.",
175
175
  )
176
+ parser.add_argument(
177
+ "--image-tag",
178
+ type=str,
179
+ env_var="LOCUST_CLOUD_IMAGE_TAG",
180
+ default="latest",
181
+ help=configargparse.SUPPRESS, # overrides the locust-cloud docker image tag. for internal use
182
+ )
176
183
 
177
184
  options, locust_options = parser.parse_known_args()
178
185
  options: Namespace
@@ -195,7 +202,12 @@ def main() -> None:
195
202
  s3_bucket = f"{options.kube_cluster_name}-{options.kube_namespace}"
196
203
  deployed_pods: list[Any] = []
197
204
  worker_count: int = max(options.workers or math.ceil(options.users / USERS_PER_WORKER), 2)
198
-
205
+ if options.users > 10000:
206
+ logger.error("You asked for more than 10000 Users, that isn't allowed.")
207
+ sys.exit(1)
208
+ if worker_count > 20:
209
+ logger.error("You asked for more than 20 workers, that isn't allowed.")
210
+ sys.exit(1)
199
211
  try:
200
212
  if not (
201
213
  (options.username and options.password) or (options.aws_access_key_id and options.aws_secret_access_key)
@@ -289,6 +301,7 @@ def main() -> None:
289
301
  *locust_env_variables,
290
302
  ],
291
303
  "worker_count": worker_count,
304
+ "image_tag": options.image_tag,
292
305
  }
293
306
  headers = {
294
307
  "Authorization": f"Bearer {cognito_client_id_token}",
@@ -99,13 +99,15 @@ class Exporter:
99
99
  def write_samples_to_db(self, samples):
100
100
  try:
101
101
  with self.pool.connection() as conn:
102
- conn.cursor().executemany(
103
- """
104
- INSERT INTO requests (time,run_id,greenlet_id,loadgen,name,request_type,response_time,success,response_length,exception,pid,url,context)
105
- VALUES (%(time)s, %(run_id)s, %(greenlet_id)s, %(loadgen)s, %(name)s, %(request_type)s, %(response_time)s, %(success)s, %(response_length)s, %(exception)s, %(pid)s, %(url)s, %(context)s)
106
- """,
107
- samples,
108
- )
102
+ conn: psycopg.connection.Connection
103
+ with conn.cursor() as cur:
104
+ cur.executemany(
105
+ """
106
+ INSERT INTO requests (time,run_id,greenlet_id,loadgen,name,request_type,response_time,success,response_length,exception,pid,url,context)
107
+ VALUES (%(time)s, %(run_id)s, %(greenlet_id)s, %(loadgen)s, %(name)s, %(request_type)s, %(response_time)s, %(success)s, %(response_length)s, %(exception)s, %(pid)s, %(url)s, %(context)s)
108
+ """,
109
+ samples,
110
+ )
109
111
  except psycopg.Error as error:
110
112
  logging.error("Failed to write samples to Postgresql timescale database: " + repr(error))
111
113