简体   繁体   English

在 AWS Lambda 上运行 Taurus BlazeMeter

[英]Running Taurus BlazeMeter on AWS Lambda

I am trying to run a BlazeMeter Taurus script with a JMeter script inside via AWS Lambda.我正在尝试通过 AWS Lambda 在内部运行带有 JMeter 脚本的 BlazeMeter Taurus 脚本。 I'm hoping that there is a way to run bzt via a local installation in /tmp/bzt instead of looking for a bzt installation on the system which doesn't really exist since its lambda.我希望有一种方法可以通过/tmp/bzt中的本地安装运行 bzt,而不是在系统上寻找自 lambda 以来并不存在的 bzt 安装。

This is my lambda_handler.py :这是我的lambda_handler.py

import subprocess
import json


def run_taurus_test(event, context):
    
    subprocess.call(['mkdir', '/tmp/bzt/'])
    subprocess.call(['pip', 'install', '--target', '/tmp/bzt/', 'bzt'])
    
    # subprocess.call('ls /tmp/bzt/bin'.split())

    subprocess.call(['/tmp/bzt/bin/bzt', 'tests/taurus_test.yaml'])

    return {
        'statusCode': 200,
        'body': json.dumps('Executing Taurus Test hopefully!')
    }

The taurus_test.yaml runs as expected when testing on my computer with bzt installed via pip normally, so I know the issue isn't with the test script. taurus_test.yaml在通过 pip 通常安装 bzt 的计算机上进行测试时按预期运行,所以我知道问题不在于测试脚本。 The same traceback as below appears if I uninstall bzt from my system and try use a local installation targeted in a certain directory.如果我从系统中卸载 bzt 并尝试使用以某个目录为目标的本地安装,则会出现与以下相同的回溯。

This is the traceback in the execution results:这是执行结果中的回溯:

Traceback (most recent call last):
File "/tmp/bzt/bin/bzt", line 5, in <module>
from bzt.cli import main
ModuleNotFoundError: No module named 'bzt'

It's technically failing in /tmp/bzt/bin/bzt which is the executable that's failing, and I think it is because it's not using the local/targeted installation.从技术上讲,它在/tmp/bzt/bin/bzt中失败,这是失败的可执行文件,我认为这是因为它没有使用本地/目标安装。

So, I'm hoping there is a way to tell bzt to use keep using the targeted installation in /tmp/bzt instead of calling the executable there and then trying to pass it on to an installation that doesn't exist elsewhere.所以,我希望有一种方法可以告诉 bzt 使用/tmp/bzt中的目标安装,而不是在那里调用可执行文件,然后尝试将其传递给其他地方不存在的安装。 Feedback if AWS Fargate or EC2 would be better suited for this is also appreciated.如果 AWS Fargate 或 EC2 更适合于此,我们也非常感谢您提供反馈。

Depending on the size of the bzt package, the solutions are:根据bzt package的大小,解决方案是:

  • Use Lambda Docker recentfeature , and this way, what you run locally is what you get on Lambda.使用 Lambda Docker 最近的功能,这样,你在本地运行的就是你在 Lambda 上得到的。
  • Use Lambda layers (similar to Docker), this layer as the btz module in the python directory as described there使用 Lambda 层(类似于 Docker),该层作为python目录btz模块,如此处所述
  • When you package your Lambda, instead of uploading a simple Python file, create a ZIP file containing both: /path/to/zip_root/lambda_handler.py and pip install --target /path/to/zip_root When you package your Lambda, instead of uploading a simple Python file, create a ZIP file containing both: /path/to/zip_root/lambda_handler.py and pip install --target /path/to/zip_root

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM