syim
syim

Reputation: 501

Get files from S3 using Jython in Grinder test script

I have master/worker EC2 instances that I'm using for Grinder tests. I need to try out a load test that directly gets files from an S3 bucket, but I'm not sure how that would look in Jython for the Grinder test script.

Any ideas or tips? I've looked into it a little and saw that Python has the boto package for working with AWS - would that work in Jython as well?

(Edit - adding code and import errors for clarification.)

Python approach:
Did "pip install boto3"
Test script:

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
import boto3

# boto3 for Python
test1 = Test(1, "S3 request")
resource = boto3.resource('s3')

def accessS3():
    obj = resource.Object(<bucket>,<key>)

test1.record(accessS3)

class TestRunner:
    def __call__(self):
        accessS3()

The error for this is:

net.grinder.scriptengine.jython.JythonScriptExecutionException: : No module named boto3

Java approach:
Added aws-java-sdk-1.11.221 jar from .m2\repository\com\amazonaws\aws-java-sdk\1.11.221\ to CLASSPATH

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
import com.amazonaws.services.s3 as s3

# aws s3 for Java
test1 = Test(1, "S3 request")
s3Client = s3.AmazonS3ClientBuilder.defaultClient()
test1.record(s3Client)

class TestRunner:
    def __call__(self):
        result = s3Client.getObject(s3.model.getObjectRequest(<bucket>,<key>))

The error for this is:

net.grinder.scriptengine.jython.JythonScriptExecutionException: : No module named amazonaws

I'm also running things on a Windows computer, but I'm using Git Bash.

Upvotes: 0

Views: 597

Answers (1)

Ted
Ted

Reputation: 126

Given that you are using Jython, I'm not sure whether you want to execute the S3 request in java or python syntax.

However, I would suggest following along with the python guide at the link below.

http://docs.ceph.com/docs/jewel/radosgw/s3/python/

Upvotes: 0

Related Questions