X

This site uses cookies and by using the site you are consenting to this. We utilize cookies to optimize our brand’s web presence and website experience. To learn more about cookies, click here to read our privacy statement.

Conduct Remote Test Execution with AWS EC2 VMs

Author: Yury Lerner Posted In: AWS, Cloud, DevOps, Testing

Finding ways to run tests remotely vs. on local machine is not always an easy task. There are several options to perform remote test execution, including:

  • Allocating a set of VMs, which will need to be maintained by either test engineer or a desktop team
  • Paying for a service such as Sauce Labs, which allows you to connect to their cloud environment to run tests
  • Leveraging AWS services by establishing a AWS EC2 environment

Using the experience of AWS EC2 from one of my recent projects, let’s look at how to set up your remote test execution within minutes with unparalleled flexibility of on-demand configurations to fulfill your testing needs.

What is EC2?

Imagine being able to stand up a dozen VMs within minutes with different operating systems with all the latest updates and browser configurations on demand.  Better yet, say you also use Azure DevOps (ADO) as a part of your setup for pipelines to manage deployments.

EC2 is an AWS cloud service that allows you to create virtual machines with the configuration of your choice. The number of machines you stand up largely depends on your subscription, but the possibilities are nearly endless.

As Amazon describes it: “Amazon Elastic Compute Cloud (Amazon EC2) offers the broadest and deepest compute platform, with over 500 instances and choice of the latest processor, storage, networking, operating system, and purchase model to help you best match the needs of your workload. We are the first major cloud provider that supports Intel, AMD, and Arm processors, the only cloud with on-demand EC2 Mac instances, and the only cloud with 400 Gbps Ethernet networking. We offer the best price performance for machine learning training, as well as the lowest cost per inference instances in the cloud“.

We know that price is always a key consideration, and Amazon’s pricing structure uses a very flexible model that can be based on your usage. There are several pricing tiers and even free options available specifically for EC2.

Setting up Azure Pools with EC2

Once you log into EC2 world, you can manually pick the OS you want to use for your first VM along with the storage size, processing power, etc. After completion, should you need more than one machine with the same configuration, EC2 provides cloning options that you can modify for each new VM. In the matter of minutes, you have a considerable number of VMs to login to and continue configuring for your specific needs.

To RDP into the VMs, you will need to generate a set of credentials to physically get inside the machine. I chose Chrome along with Visual Studio, then downloaded and configured my agents. In my case, I was using self-hosted Windows agents within Azure pipelines for deployment, but there are many options available for Linux, macOS, and others.

After quick verification on the ADO side, I was able to see all my machines show up in their assigned pools according to my configuration.

To speed up the process

Alternatively, if you are in the situation where you have to standup and tear down your VMs with each regression run, you can setup your ADO pipeline(s) with additional tasks to speed up the process. For instance, to run UI tests, you will need to install the appropriate browser and in the case of .Net, Visual Studio as well on the target machine. Then, ADO provides specific tasks that will help you do that on demand. I used “PowerShell on target machines task”, but feel free to explore other options:

 

Here’s an example of some of the must-have tasks to execute tests on chrome from my test project:

 

Below are examples of Chrome and Visual Studio Installation scripts I used:

Now that your pipeline is setup, you are ready to point it to any VM pool you’ve set up with EC2.

While there are several options of remote test execution, I find EC2 is one of the easiest and one of the most flexible ways to go. With a few clicks you can stand up a machine, RDP to it, configure and you’re ready to run some tests. You can always take your setup to the next level by standing up EC2s on demand as I mentioned earlier. This will take a little more prep work, but this is a good start.