AWS Commands - TestlumFramework/Testlum GitHub Wiki

๐ŸŒฉ๏ธ AWS Services Commands

Testlum supports a range of AWS services, including S3 and Lambda, to help you test cloud-based applications and workflows. This page covers how to interact with AWS services through Testlum commands.

Supported AWS Services

๐Ÿ› ๏ธ S3 Command

S3

๐Ÿ“– Overview

Description:
Amazon S3 (Simple Storage Service) is an object storage service providing industry-leading scalability, data availability, security, and performance. It is widely used for storing and managing files and backups in the cloud.

โš™๏ธ Command: <s3>

The <s3> tag allows interaction with S3 buckets and files. It supports actions such as creating/removing buckets, uploading/downloading files, and comparing files.

โš™๏ธ Parameters

Parameter Type Required Description
comment String โœ… Description of the S3 action
alias String โœ… Unique alias for the S3 integration in integration.xml
condition Boolean โŒ Optional condition to execute the test step
threshold Integer (ms) โŒ Maximum allowed execution time for the step (in milliseconds)

๐Ÿงฉ Bucket Commands

The bucket commands are used to manage S3 buckets.

Parameter Required Description
create โœ… Create a new S3 bucket
remove โœ… Remove an existing S3 bucket by name

๐Ÿงช Example Usage โ€” Bucket Commands

<s3 comment="s3 commands" alias="S3_0">
    <bucket comment="Create a new bucket">
        <create>bucket-one</create>
    </bucket>

    <bucket comment="Remove an existing bucket">
        <remove>bucket-one</remove>
    </bucket>
</s3>

๐Ÿงฉ File Commands

The file commands are used to interact with files in S3.

Parameter Required Description
bucket โœ… The S3 bucket containing the file
key โœ… The unique key for the file in the selected bucket
upload โœ… Upload a file from the scenario directory to S3
download โœ… Download a file from S3 and compare it with the expected file
remove โœ… Remove a file from the specified S3 bucket

๐Ÿงช Example Usage โ€” File Commands

<s3 comment="Upload, download, and remove files" alias="S3_0">
    <file comment="Upload file" bucket="bucket-one" key="/test/upload_1.json">
        <upload>upload_1.json</upload>
    </file>

    <file comment="Download file" bucket="bucket-one" key="/test/upload_1.json">
        <download>
            <file>expected_1.json</file>
        </download>
    </file>

    <file comment="Remove file" bucket="bucket-one" key="/test/upload_1.json">
        <remove/>
    </file>
</s3>

โœ… Tips:

  • Use key to uniquely identify a file in the S3 bucket.
  • Ensure your S3 bucket is properly configured and accessible.
  • For bulk operations, you can include multiple file operations inside one <s3> command.

โšก Lambda Command

Lambda

๐Ÿ“– Overview

Description:
With Testlum, you can easily test AWS Lambda functions. Lambda lets you run code in response to events without managing servers, and Testlum simplifies the testing process of your Lambda functions.

โš™๏ธ Command: <lambda>

The <lambda> command is used to invoke Lambda functions and manage their responses in your Testlum scenarios.

โš™๏ธ Parameters

Parameter Type Required Description
comment String โœ… Description of the Lambda function test
alias String โœ… Unique alias for the Lambda integration in integration.xml
functionName String โœ… The name of the Lambda function to invoke
condition Boolean โŒ Optional condition for executing the test step
threshold Integer (ms) โŒ Maximum allowed execution time for this step (in milliseconds)

๐Ÿงฉ Body Commands

The body parameter defines the content that will be passed to the Lambda function.

Parameter Required Description
from โŒ Specify the file containing the body of the request
raw โŒ Provide the raw content as a JSON string

๐Ÿงช Example Usage โ€” Body

<lambda comment="Invoke python function" alias="AWS" functionName="hello-world-python">
    <body>
        <from file="body_1.json"/>
    </body>
</lambda>

๐Ÿงฉ Response Commands

The response parameter defines how to handle the Lambda function's response.

Parameter Required Description
code โŒ Expected HTTP response code. Default is 200
file โŒ A file that contains the expected response
mode โŒ A mode for response comparison (lenient strict)
header โŒ Header name and data to validate in the response

๐Ÿงช Example Usage โ€” Response

<lambda comment="Invoke python function" alias="AWS" functionName="hello-world-python">
    <body>
        <raw>
            {
            "key1": "Hello Lambda",
            "key2": "value2",
            "key3": "value3"
            }
        </raw>
    </body>
    <response file="expected_2.json"/>
</lambda>

โœ… Tips:

  • Use the raw option to directly input JSON strings into the request body.
  • The file can be used for both the input and expected output to streamline testing.
  • Ensure the Lambda function is properly configured and accessible from your test environment.

Example Files

body_1.json

{
  "key1": "Hello Lambda",
  "key2": "value2",
  "key3": "value3"
}

expected_1.json

"Hello Lambda"
โš ๏ธ **GitHub.com Fallback** โš ๏ธ