亚马逊AWS官方博客

AREX on AWS: Automated Regression Testing Practice to Accelerate R&D Efficiency丨利用 AWS 部署 AREX:加速研发效能的自动化回归测试实践

英文版本 | 中文版本


In today’s rapidly iterating software development environment, ensuring that code changes do not introduce new defects is crucial. AREX, as a powerful automated regression testing tool, can help development teams quickly identify potential issues and improve software quality. This article will introduce how to easily deploy AREX on AWS to accelerate your R&D efficiency.

Introduction

AREX is an automated regression testing platform based on traffic recording and replay technology. It can capture real traffic from the production environment and accurately replay it in the test environment, thereby achieving comprehensive regression testing. The main advantages of AREX include:

  • No need to write test cases, significantly reducing testing costs
  • Based on real traffic, improving test coverage and accuracy
  • Automatic comparison of request responses, quickly locating issues
  • Support for multiple programming languages and frameworks

Record & Replay Logic Flow of AREX

Deploying AREX on AWS

AREX offers two deployment methods on AWS to cater to different user needs. This article will provide a detailed introduction to both methods, allowing you to choose the most suitable deployment approach based on your specific requirements:

  1. Using AREX Cloud
  2. Manually deploying the AREX Community Edition to AWS EC2

In the following sections, we will delve into each of these deployment methods, providing step-by-step instructions and important considerations to help you successfully deploy AREX on AWS. Regardless of which method you choose, we will offer clear guidance to ensure that you can fully utilize AREX’s capabilities.

AREX Cloud

To start using AREX, you need to first register for an AREX Cloud account. Visit the AREX official website and click the “Get Started” button to register.

Note: The console login user is different from the AREX user. Console users are used by enterprise organizations to purchase and manage the AREX platform.

After registration, new users need to create an organization using their company name and generate a unique AREX platform access link.

Organization administrators can go to the Dashboard page and click to download the latest version of the client, or visit the official website’s download page to download it themselves.

Users can download the client through the download link provided in the invitation email.

After the administrator creates an organization, organization members can access the previously generated unique link (https://demo.arextest.com) or log in through the local client.

For the first login, users need to enter their email address. After receiving the verification code in their email, they should click “Login” to complete the login process.

Manual Deployment to AWS EC2

Step 1: Prepare an EC2 for AREX deployment

Select Amazon Linux 2 AMI as the operating system. (Amazon Linux 2023 AMI has some applications that cannot be installed, so I choose a lower but stable version of the operating system)

If you are just trying it out, it is recommended that you choose a t3.large (2C8G) machine for the minimum configuration.

The Key pair can be created and used as you wish (for quick links to your EC2). You can also share this key when you create a Amazon DocumentDB later.

Storage Configuration selects 8G by default.

Step 2: Create Amazon DocumentDB Cluster

NOTE: When using Amazon DocumentDB, you need to deploy it in the same virtual private cloud (VPC) where the EC2 instance it is associated with resides to ensure that they can communicate with each other.

Create 2 instances of type db.t3.medium, 1 master and 1 slave on two machines. Engine version chooses 5.0.0.

After installation, configure the corresponding inbound rules to allow external network access via the connection string. Use mongo shell to verify that the connection string is available.

Run the show dbs command, and the figure above indicates that the Amazon DocumentDB was created successfully.

Step 3: Prepare an Amazon ElastiCache and Create a Redis Cluster

  • Search for Amazon ElastiCache in the AWS console and create a Redis cluster(Amazon ElastiCache must be in the same VPC as the EC2 created above).
  • Select the configuration and create a new cluster. You can disable cluster mode during the trial phase and modify the configuration as needed for official use.
  • Engine version is selected as 6.2, node type is selected as cache.t3.micro, and the number of replicas is set to zero.
  • Select Create New Subnet Group and select the same VPC ID as EC2 above.
  • To check if the connection to Amazon ElastiCache is successful, you can use redis-cli to connect to Amazon ElastiCache on EC2. If the connection fails, you can check the inbound rules of the corresponding security group and configure them according to your network situation.

Step 4: Install AREX through docker-compose

Installing AREX is very simple. You can install all the basic service components of AREX with just one command using Docker-Compose.

Here is a brief introduction to the working principle and various service components of AREX.

The working principle of AREX regression testing is to use AREX Java Agent to sample and record the data flow and request information of Java applications in the production environment, and send this information to the AREX Storage Service, which imports it into the database (mongoDB) for storage. When replay is required, the AREX Schedule Service will extract the recorded data of the tested application from the database through the Storage Service, and then send interface requests to the target verification service. At the same time, the Java Agent will mock the response of external dependencies recorded, instead of real data access, and convey it to the tested application. After the target service completes the request logic and returns the response message, the Schedule Service will compare the recorded response message with the replay response message to verify the correctness of the system logic, and sned the comparison result to the analysis service (Report Service), which generates a complete replay test report for testers to analyze the differences between recording and playback.

First, clone the AREX repository by git.

git clone --depth 1 https://github.com/arextest/deployments.git
cd deployments

Configure Amazon DocumentDB and Amazon ElastiCache

If you want to use Amazon DocumentDB as a database to replace the default MongoDB and use Amazon ElastiCache to replace the default Redis, you just need to modify the connection string in the docker-compose.yml configuration file. Replace all MongoDB connection strings with Amazon DocumentDB connection strings and all Redis connection strings with Amazon ElastiCache connection strings.

Step 5: Start AREX

After the configuration is complete, run docker-compose to start AREX.

docker-compose up -d

If you have not modified the port configuration, after the service is started, you can directly access the AREX frontend page by accessing port 8088

Recording & Replay on AREX

1. Collection

Entrypoint for interface testing

  • Test case management
  • API endpoint configuration
  • Request/response validation

2. Report

Management hub for Record & Replay sessions

  • Session overview and statistics
  • Detailed test results analysis

3. Traffic

Repository of historical recording data

  • Chronological listing of recorded interactions
  • Data export and archiving options

Record & Replay Quick Start

Setup Arex Agent

n order to use the traffic replay feature, the Agent needs to be loaded on the tested service in advance.

Execute the following command to clone and package the Agent code, or download it directly from https://github.com/arextest/arex-agent-java/releases.

git clone https://github.com/arextest/arex-agent-java.git 
mvn clean package

The corresponding jar package file will be generated under arex-agent-jar. Copy this folder to the root directory of drive D, and then run the following command locally to start the demo application. Replace x.x.x.x with the IP address of the previously installed Docker:

java -javaagent:D:\arex-agent-jar\arex-agent-0.1.0.jar
      -Darex.service.name=commit-test002
      -Darex.storage.service.host=x.x.x.x:8093
      -jar MyArexDemoService.jar

NOTE: You can also download it directly from https://github.com/arextest/arex-standalone/releases, which contains the corresponding jar file.

Once launched, the application will automatically appear in the replay application list in AREX.

After an application with AREX Agent loaded is released, it will automatically collect real user requests based on the set recording frequency and save them. These saved data are used as test cases for subsequent playback to verify whether new code changes have unintended consequences.

Application Setting

A series of settings can be made in the AppSetting for the target application. In this case, only the recording-related settings are used, as shown below:

You can set the recording time and frequency here.

Replay

After starting replay task in the replay menu (with the target replay environment set to the IP address and port number of the deployed test application), you will see the following execution records:

Select the replay task from the list, there will display a summary of the test results, showing the percentage of successful executions. The following is a list of one tested interfaces.

All the cases in this demonstration have failed, and clicking on DiffScenes will show the details of the failures:

The Record Details button allows you to see the data details of the recorded test case, and the Save button allows you to solidify the test case and save it in the Request Collection menu.

Conclusion

By deploying AREX on AWS, you can significantly enhance your development team’s efficiency. Automated regression testing not only saves substantial manpower and time costs but also improves software quality and reduces the risk of issues in the production environment. We encourage you to try AREX and experience how it can revolutionize your development process.

To learn more about AREX, please visit the AREX official documentation. If you encounter any issues during use, feel free to contact the AWS support team or AREX technical support.

Let’s work together to leverage the powerful capabilities of AWS and AREX to create a more efficient and reliable software development process!

本篇作者

Yang Jun

Amazon Web Services Senior Solutions Architect. Prior to joining AWS, primarily engaged in e-commerce and retail-related system development, possessing extensive experience in the retail industry and enterprise cloud migration practices.

Xia Ning

Amazon Web Services Solution Architect. Previously worked at HP Software and Agora.io, with over 10 years of experience in frontend and backend development. Has led the design of various software projects. Proficient in mobile internet, audio/video, and cloud computing related fields.

Danielle Zhu

Amazon Web Services Customer Solutions Manager (CSM), with years of experience in public cloud MSP service consulting and implementation, as well as software development and delivery project management. Currently supporting customers in the OTA (Online Travel Agency) and retail industries.