Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't define unique characteristics for each locust #775

Closed
luojxxx opened this issue Apr 14, 2018 · 1 comment
Closed

Can't define unique characteristics for each locust #775

luojxxx opened this issue Apr 14, 2018 · 1 comment

Comments

@luojxxx
Copy link

luojxxx commented Apr 14, 2018

Description of issue / feature request

I would like to simulate a group of GPS tracked animals by using init within the BehaviorClass to instantiate a Animal class which will iterate through GPS coordinates upon every method call that will be POSTed to the API.

Expected behavior

I expected to be able to use def init(self): to instantiate an DeviceTracker class object with a get_position_update method that returns the GPS coordinates (method acts like a generator that's looped on itself).

Actual behavior

TypeError: init() takes 1 positional argument but 2 were given

Environment settings (for bug reports)

  • OS: Mac OS 10.13.3
  • Python version: 3.5.3
  • Locust version: 0.8.1

Steps to reproduce (for bug reports)

class TrackerBehavior(TaskSet):
  def __init__(self):
    self.tracker = DeviceTracker(
      selected_device_id, 
      selected_animal_id, 
      selected_path, 
      selected_starting_point
      )

  @task(1)
  def update_position(self):
    self.client.post("/api/v1/position_tracking", self.tracker.get_position_update())
@luojxxx
Copy link
Author

luojxxx commented Apr 14, 2018

Figured it out. Needed to instantiate the DeviceTracker using the on_start method, and then the DeviceTracker class itself needs to select or randomly select the particular animal to simulate.

class TrackerBehavior(TaskSet):
  def on_start(self):
    self.locust.tracker = DeviceTracker()

  @task(1)
  def update_position(self):
    self.client.post("/api/v1/position_tracking", self.locust.tracker.get_position_update())

@luojxxx luojxxx closed this as completed Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant