简体   繁体   中英

Running Taurus BlazeMeter on AWS Lambda

I am trying to run a BlazeMeter Taurus script with a JMeter script inside via AWS Lambda. 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.

This is my 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. The same traceback as below appears if I uninstall bzt from my system and try use a local installation targeted in a certain directory.

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.

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. Feedback if AWS Fargate or EC2 would be better suited for this is also appreciated.

Depending on the size of the bzt package, the solutions are:

  • Use Lambda Docker recentfeature , and this way, what you run locally is what you get on Lambda.
  • Use Lambda layers (similar to Docker), this layer as the btz module in the python directory as described there
  • 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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