acme_fitness_demo icon indicating copy to clipboard operation
acme_fitness_demo copied to clipboard

[traffic-generator] `KeyError: 'token'` error occurs when running load generator

Open gyohuangxin opened this issue 3 years ago • 0 comments

A KeyError: 'token' error occurs when I try to run locust load generator.

huangxin@huangxin:~/acme_fitness_demo/traffic-generator$ locust --host=http://10.239.154.176
[2021-10-26 21:38:54,918] huangxin/WARNING/locust.main: System open file limit '1024' is below minimum setting '10000'. It's not high enough for load testing, and the OS didn't allow locust to increase it by itself. See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit for more info.
[2021-10-26 21:38:54,918] huangxin/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2021-10-26 21:38:54,931] huangxin/INFO/locust.main: Starting Locust 2.4.1
[2021-10-26 21:39:02,001] huangxin/INFO/locust.runners: Ramping to 1 users at a rate of 1.00 per second
[2021-10-26 21:39:02,001] huangxin/INFO/locust.runners: All users spawned: {"WebSiteUser": 1} (1 total users)
[2021-10-26 21:39:02,012] huangxin/ERROR/locust.user.task: 'token'
Traceback (most recent call last):
  File "/home/huangxin/.local/lib/python3.8/site-packages/locust/user/task.py", line 296, in run
    self.execute_next_task()
  File "/home/huangxin/.local/lib/python3.8/site-packages/locust/user/task.py", line 321, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "/home/huangxin/.local/lib/python3.8/site-packages/locust/user/task.py", line 330, in execute_task
    task(self).run()
  File "/home/huangxin/.local/lib/python3.8/site-packages/locust/user/task.py", line 281, in run
    self.on_start()
  File "/home/huangxin/acme_fitness_demo/traffic-generator/locustfile.py", line 101, in on_start
    self.login()
  File "/home/huangxin/acme_fitness_demo/traffic-generator/locustfile.py", line 118, in login
    self.user.userid = body["token"]
KeyError: 'token'

And I tried to print the body's data, there is no "token" key in it, only "access_token" and "refresh_token" can be found.

{'access_token': 'eyJhbGciOiJIUzI1NiIsImtpZCI6InNpZ25pbl8xIiwidHlwIjoiSldUIn0.eyJVc2VybmFtZSI6InBob2ViZSIsImV4cCI6MTYzNTI1OTI5NSwic3ViIjoiNjE3MmViYjM1YTNkM2RhZGFlZjA0YzAxIn0.VDSR0_v7vjef7vS7FOVcNKf5sHjpDGHIg-vm_qwp3Cc', 'refresh_token': 'eyJhbGciOiJIUzI1NiIsImtpZCI6InNpZ25pbl8yIiwidHlwIjoiSldUIn0.eyJleHAiOjE2MzUyNjY0OTUsInN1YiI6IjYxNzJlYmIzNWEzZDNkYWRhZWYwNGMwMSJ9.oMoTzumdEZlO4Ozszm0ZbFnhbvav6Zj_u1f_Zps0luk', 'status': 200}

gyohuangxin avatar Oct 26 '21 05:10 gyohuangxin