In this tutorial, I will guide you through all the necessary steps for creating an AWS cloud test automation lab. Setting up such a lab that is in the cloud can have various advantages:
- Scalability – Testing in the cloud allows you to increase the computing resources according to your needs.
- Cost – You pay for what you use, and that’s it. You can customize your resources and add/remove them as needed.
- Time – As long as your machines are running in the cloud, you can execute tests non-stop. The machines never sleep!
- Freedom – You can choose your favorite operating system, no need for a physical machine.
In this case, we are going to create the lab using Amazon Web Services (AWS), but of course you could choose any other cloud provider you’d like to as well. Then, I will show you how to easily run your automated tests and jobs in the cloud using TestProject test automation platform. In this tutorial, we will focus on web tests.
So, how will our lab look like? We are going to create two virtual machines: Linux and Windows (you can create as many VMs as you’d like), using Amazon Elastic Compute Cloud (EC2). Amazon EC2 is the Amazon Web Service we used in this tutorial to create and run virtual machines in the cloud. From now on, we will call these virtual machines ‘instances’.
Let’s get started and create our remote cloud-based execution environment for our test automation!
Prerequisites
- You need to have a TestProject account. Don’t worry, it’s FREE.
- You need to have an Amazon Web Services (AWS) account.
Tutorial Overview
- Create a Windows Virtual Machine:
- Create a Linux Virtual Machine:
- Run your test automation in AWS cloud with TestProject
- Conclusion
Create Windows VM
Step 1: Launch the instance
Follow this simple AWS tutorial on how to create a Windows VM in the cloud: How to launch a Windows VM on AWS. Once you’ll finish with this tutorial, you will have a Windows VM ready to launch.
Step 2: Download and install web browsers
If you have successfully followed the launch tutorial in step 1 above, you should now be connected to your Windows EC2 instance. Now, we need to install web browsers to test our web applications. Click on one of the links in the instance’s desktop:
Navigate to these links, download and install the web browsers: Google Chrome, Mozilla Firefox, Microsoft Edge.
Step 3: Download and Install TestProject’s Agent
After we’ve installed the above web browsers, let’s download and install TestProject’s Agent in order to run our automated tests in the cloud.
Download the Windows agent from here and follow the installation instructions.
Once the agent installation is complete, we need to register the agent. Navigate to TestProject’s Agents page and click on “Register Agent”:
Give your agent a name and click “Save”:
Click on “Register”:
After the registration process is complete, verify that your new agent’s status is “Idle”:
Now that we’ve completed all the steps above, we have an EC2 Windows machine with TestProject’s agent installed and registered. You can now go ahead and create your web tests using TestProject.
Create Linux VM
Step 1: Launch the instance
We are going to create and launch a Linux VM. This process is a bit different from Windows: the connection to the instance is done by SSH and it doesn’t come with GUI- only a terminal.
Navigate to AWS EC2 home page and click on “Launch Instance”:
In the Amazon Machine Image options, select: Ubuntu Server 16.04 LTS (HVM), SSD Volume Type:
In the Instance Type options, select “t2.micro” (You can choose any type you want, but in our example, we’ll go with the free tier option). Then, click on: “Review and Launch”:
Verify your selections and click “Launch”:
Now, we need to create a new Key Pair. Select the “Create a new key pair” option:
Give you Key pair a name:
Click “Download Key Pair”. It will download your new key as a .pem file:
Click “Launch Instances”:
Click on “View Instances”:
Wait until your instance’s state becomes “running”:
Click on “Connect”:
A new pop-up window will open. Now we need to connect to our instance. In this tutorial, we will do it with an SSH client software called: PuTTY:
Step 2: Connect to the instance with PuTTY
Here you will find a link for downloading PuTTY and a step-by-step tutorial on how to connect to your instance.
Step 3: Add security group to the instance
In order to be able to connect to the instance from different sources, we need to add a new security group that will allow access to it. Navigate to AWS EC2 home page and at the left side of the page, under “NETWORK & SECURITY”, click on “Security Groups”:
Click on “Create Security Group”:
Give your security group a name, a description and leave VPC as default. Then, click on “Add Rule”:
Copy the exact details in the below screenshot. Then, click on “Create”:
On the left side of the screen, under “NETWORK & SECURITY”, click on “Network Interfaces”:
Select the row with your specific Instance ID:
Right click on the selected row and click on “Change Security Groups”:
Select your new security group from the list and click “Save”:
Step 4: Add GUI to our instance
In this step, we will configure the instance so that we’ll have a GUI.
In the terminal, type this command:
sudo apt-get update
Once the update is completed, type this command:
sudo apt-get install lxde
When the installation of LXDE is completed, type this command:
sudo apt-get install tightvncserver
Then, type this command:
tightvncserver :1
You will now be asked to choose a password. In this example, we’ll go with a simple: abc123. Then you will need to choose whether you want to enter a view-only password. Select ‘No’.
Type this command:
tightvncserver -kill :1
Now type this command:
nano ~/.vnc/xstartup
Add this command in a new row below the “-solid grey” line:
lxterminal & /usr/bin/lxsession -s LXDE &
Make sure that it looks like this:
Click CTRL+X , then ‘Y’ and then ENTER. You will then return to the terminal.
Type this command in the terminal:
sudo apt-get update
Once the update is completed, type this command in the terminal:
sudo apt-get dist-update
Now we need to reboot the instance. Type:
sudo reboot
Click “OK”, exit PuTTY and re-connect after a few moments. Once your instance is connected again, type this command in the terminal:
tightvncserver :1
Now, you need to download “VNC Viewer” (notice: you should download it on your PC, not in the AWS instance) and install it. Once the VNC Viewer is installed, enter your instance’s public IP address and add “:1”. Then click ENTER to connect to your instance:
Click “Continue”:
Enter the password you selected before (in this example we chose: abc123):
Click “Yes” in the pop-up window. Now you should be able to see the desktop of the instance:
Now that we successfully added GUI to our instance, we need to install web browsers: Chrome and Firefox. That way, you would be able to perform tests on each of these web browsers. You can find the pre-installed web browser here:
Step 5: Download and Install TestProject’s Agent
Now that we have GUI, it’s much easier to download and install the TestProject agent that will allow us to run our automated tests in the cloud. Download the TestProject Linux agent from here. After the download of the agent is completed, type in the terminal:
cd Downloads
Inside the Downloads directory, you’ll find the agent installation file (TestProjectAgent_x64.sh). We need to give it execution permission. Type in the terminal:
chmod +x TestProjectAgent_x64.sh
Now we can finally install the agent. Type in the terminal:
./TestProjectAgent_x64.sh
and follow the installation instructions. At the end of the installation, you will be asked to start the application. Select “Yes”. Now that our agent is installed and running, we need to register it. Navigate to the Agents page and click on “Register Agent”:
Enter the instance’s public IP address, give your agent a name, click “Save” and then “Register”:
After the registration process is complete, verify that your new agent’s status is “Idle”:
Now that we’ve completed all the steps above, we have an EC2 Linux machine with TestProject’s agent installed and registered. You can now go ahead and create your web tests using TestProject.!
Run your test automation in AWS cloud with TestProject
By this stage of the tutorial, we have two EC2 instances: Linux & Windows, and both have a TestProject Agent installed on them. Let’s go ahead and see how we can execute tests and jobs remotely on those machines using TestProject. You can easily create your Web tests or Mobile tests and execute them as jobs on your remote agents in the cloud. Let’s create a new job in TestProject’s platform:
Give your job a name and description. Then click “Next”:
Select the “Web” option, then select your Windows agent (that you’ve downloaded and installed in the cloud in step 3 above) and click “Next” (in this case, we chose our windows instance agent, but of course we could have also chosen the Linux instance agent as well):
Select the web browsers on which you want to execute the tests:
Select a time to run your job (on demand/one time/recurrent) and click “Finish”:
Now we can add our tests to the job and then click on “Run”:
After our job is complete, we’ll receive extensive reports of success ratios for each web browser target and we’ll get in-depth insights on each test in our job with details on every single step:
We’ve now seen the process of creating a job and executing it. As you probably noticed, we used the agent installed on the EC2 Windows instance. That way, we can orchestrate our job executions from our local machine and determine whether or not to run them using any of our cloud instances or local agents. We can even schedule jobs to run in the future and turn off our local machine, the jobs will still be able to run in the cloud. You can expand this scenario to multiple EC2 instances, operating systems and jobs.
Conclusion
In this article, we’ve experimented with AWS EC2 VM instances. We’ve created two instances: Linux and Windows, and installed a TestProject agent on each one of them. We can now use the cloud advantages (scalability, cost, time, etc.) to schedule jobs and run them on these instances whenever we’d like to. As long as these instances are running, we can always execute tests on them remotely.
Happy Testing!
Feel free to leave your comments below ➡
How I can setup my java opensdk project for cloud execution on AWS?
Amazing tutorial, thanks.The step `sudo apt-get dist-update` is incorrect. It is `sudo apt-get dist-upgrade`
Also, the agent now shows up in the Agents page but the processor and RAM information is incorrect?