Home > OS >  Customizing Locust input params
Customizing Locust input params

Time:09-17

So I have locust running in a distributed set up on k8s. Currently I am kicking off load tests via the UI. In my current set up, the master and worker processes are running already and are waiting for me to kick off the load test via the UI. I am looking to add some input customization for my locust set up. I just want to accept some more params like endpoint weights and such. This then should attach to the already existing locust process and kick off a load test with the proper configuration. I know locust supports extending UI to see more of the load test output, but I couldn't find anything that would extend/customize the input form.

enter image description here

[EDIT]

I am trying to use custom arguments and it doesn't seem to be working. Here is my code

class CusLoadTest(HttpUser):

      @events.init_command_line_parser.add_listener
      def _(parser):
         parser.add_argument("--user-count", type=str, env_var="USER_COUNT", default="1000", help="1000")

      def __init__(self, parent):
          super(CusLoadTest, self).__init__(parent)

      def __check_environment(self):
         self.user_count = int(self.environment.parsed_options.user_count)
         logger.info("Using {}".format(self.user_count))

      def on_start(self):
          self.__check_environment()

The logger always prints 1000 users and ignores anything I pass into the web UI. Not sure what is happening.

CodePudding user response:

Locust has supported adding custom parameters on the command line for a while, but the ability to set those arguments in the Web UI (and forward them to workers in distributed runs) was added just recently (in 2.2.0)

See https://docs.locust.io/en/latest/extending-locust.html#custom-arguments for a full documentation.

If you have some custom settings you don't want to show in the UI, you'll need the latest prerelease build (as that feature is not yet in a release). 2.2.2.dev30 is the most recent one.

  • Related