首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在GitLab CI管道中使用蝗虫测试,用户永远不会产卵。

在GitLab CI管道中使用蝗虫测试,用户永远不会产卵。
EN

Stack Overflow用户
提问于 2022-10-04 22:01:48
回答 1查看 127关注 0票数 0

我试着使用GitLab CI运行蝗虫测试,但是,我遇到了一个用户实际上并不会产生的问题,即使已经显示了相应的消息。

.gitlab-ci.yml.的简化版本场景位于一个单独的文件中,正如@ this question中善意地建议的那样。另外,我尝试用测试将场景添加到同一个locustfile.py中,但是,它没有改变任何情况。

代码语言:javascript
运行
复制
 load_test:
   image: python:3.9-slim-buster
   before_script:
     - pip install virtualenv
     - virtualenv venv
     - source venv/bin/activate
     - pip install -r requirements.txt
     - locust -V
   script:
     - locust -H https://host -f locustfile.py,scenario.py --autostart --autoquit 0 --html locust_report.html

locustfile.py看起来像这样。我总共有10个用户,每个有独特的电子邮件,我登录他们一个一个在20秒。添加LOAD类和用户AUTH打印,以了解这些登录何时会在管道中发生(请参阅管道日志)。

代码语言:javascript
运行
复制
USER_EMAILS = [ ... emails ... ]
print(f"\nUSER EMAILS: {USER_EMAILS}")
 
 
class SocialLoad(TaskSet):
 
    print(f"\nLOAD CLASS") # for debugging
 
    def on_start(self):
        self.login()

    ...
    tasks
    ...

    def login():
        print(f"\nUSER AUTH")
        ...

GitLab 管道记录。看起来LOAD类和USER打印都是在之后发生的,生成了关于用户的所有消息,这对我来说很奇怪。当我在没有CI的情况下运行这个测试时,它们通常发生在产卵过程中。

代码语言:javascript
运行
复制
 [2022-10-04 20:14:24,657] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
 [2022-10-04 20:14:24,666] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Starting Locust 2.12.0
 [2022-10-04 20:14:24,666] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test starting. User count and spawn rate are ignored for this type of load test
 [2022-10-04 20:14:24,671] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape worker starting
 [2022-10-04 20:14:24,671] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test updating to 10 users at 0.50 spawn rate
 [2022-10-04 20:14:24,672] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Ramping to 10 users at a rate of 0.50 per second
 [2022-10-04 20:14:42,680] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: All users spawned: {"User": 10} (10 total users)
 [2022-10-04 20:15:24,722] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test stopping
 [2022-10-04 20:15:24,732] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: --run-time limit reached, stopping test
 [2022-10-04 20:15:24,732] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: --autoquit time reached, shutting down
 [2022-10-04 20:15:24,760] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: writing html report to file: locust_report.html
 [2022-10-04 20:15:24,761] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Shutting down (exit code 0)
 Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
 --------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
 --------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
          Aggregated                                                                         0     0(0.00%) |      0       0       0      0 |    0.00        0.00
 Response time percentiles (approximated)
 Type     Name                                                                                  50%    66%    75%    80%    90%    95%    98%    99%  99.9% 99.99%   100% # reqs
 --------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------
 --------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------
 USER EMAILS: [ ... emails ... ]
 SOCIAL LOAD
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH
 STARTED USER AUTH

结果是空的。此外,我还打印出了creted locust_report.html文件,该文件碰巧也是空的。

message :即使显示了All users spawned: {"User": 10} (10 total users)消息,看起来用户永远也不会生成。是的,有打印,这表明login()函数已经被调用了,但是登录本身(打印后的代码,这在代码段中没有)从未发生过。如果是这样的话,是否有可能使它们在测试运行时产生“正常”?

我认为根本原因是有关检索电子邮件步骤,因为当我运行另一个简单的测试,只有一个用户(不检索任何电子邮件),所有的工作顺利。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-07 10:56:11

它的根本原因是服务器端的VPN,它没有在它的白名单中包含必需的in。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73954025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档