Create a Mock Service for AWS Testing

BlazeMeter includes a set of pre-built Transactions for testing AWS S3 cloud storage operations in your application. To find these Transactions, select the AWS S3 Sample service on the Asset Catalog page:

AWS S3 sample service

This tutorial describes how to use these Transactions to create a Mock Service to test key S3 operations in your application. We'll use Templates to group positive and negative scenarios from the Service, from which we can then dynamically provision Mock Services for each scenario as needed:

  1. Click the Mock Services page on the Service Virtualization tab:
  2. Click the Add button next to Mock Service Templates.
  3. Name the Template "AWS S3 - Positive Scenarios", select the AWS S3 Sample service, and give the Template a meaningful description as pictured:
    example aws service template
    When you select the AWS S3 Sample Service, the left pane of the Template populates with all of the transactions in that Service. Expand each Transaction to view details, for example:
    the AWS Store Object transaction
    Each pre-built Transaction contains a clear description so you understand what the request will do.
    If you need to know more details about the Request or Response, find the Transaction on the Transactions page.
  4. Move the following Transactions to the right pane:
    • Return object metadata (ok response)
    • Delete object (ok response)
    • Store object (ok response)
    • Retrieve object (ok response)
      AWS transactions added to the positive scenario template
  5. Click Save.
    The Template is created.
  6. Click Add again to create the Template for negative scenarios.
  7. Name the Template "AWS S3 - Negative Scenarios", select the AWS S3 Sample Service, and give the Template a meaningful description as pictured:
    sample aws template negative scenario
    When you select the AWS S3 Sample service, the left pane of the Template populates with all of the Transactions in that service.
  8. Move the following Transactions to the right pane:
    • Delete object (AccessDenied error)
    • Retrieve object (NoSuchBucket error)
    • Store object (OperationAborted error)
      AWS transactions added to the template of the negative scenario
  9. Click Save.
    The Template is created. Because we created Templates for these transactions, there are multiple ways you can leverage the Templates to become mock services. Let's cover one way for each Template.
  10. Click Create Mock Service to the right of the AWS S3 - Positive Scenarios Template.
  11. Name the Mock Service "AWS S3 - PUT and DELETE", leave the AWS S3 Sample service selected, and give the Mock Service a meaningful description as pictured:
    aws example positive scenario Mock Service
  12. Remove the Return and Retrieve object transactions from the right pane.
    Mock Service with some transactions removed
    As specified in the description, you only want to test a PUT and DELETE with this Mock Service. The Template presented all positive scenarios, and from those you chose the Transactions required for this particular test.
  13. Click Save.
  14. Click Run Mock Service.
    The Mock Service is running and available to use for testing.
    the running AWS put and delete mock service
  15. Redirect the application under test to use the endpoint for the Mock Service instead of the live service.
    You can write and run a test or tests that uses the report.json object defined in the Transactions to test S3 functionality using the Mock Service.
    Now, let's create a Mock Service that a tester can use for negative testing when defining a test.
  16. Click the Add button next to Mock Services.
  17. Name the Mock Service AWS Testing, add no Transactions, and click Save.
  18. Click Run Mock Service.
    The AWS Testing Mock Service is running and available. Now, when a tester needs a Mock Service to test AWS S3, they can reference the Mock Service and an associated Template within the test.
    the running aws mock service.PNG
  19. Create a test in BlazeMeter, or update an existing test. Access the Configuration screen.
  20. Enable the Mock Services configuration.
  21. Click Add, and select the Mock Service you created and the Template that contains the negative testing scenarios:
    a mock service that was added to a test definition
    The Mock Service is now built into the test and will include all of the Transactions in the negative testing Template.
  22. Copy the endpoint and redirect the application under test to use the Mock Service endpoint in place of the live service before running the test.