Applies to: TestComplete 7-10
This article explains the advantages of using Amazon Machine Images (AMIs) to prepare a proper test environment for cloud testing and explains how to create AMIs with the appropriate configurations.
For related technical articles on cloud testing, please see the Other Articles About Cloud Testing section.
Why Use Amazon Machine Images for Cloud Testing?
An Amazon Machine Image (AMI) is an image of a cloud computer launched using the Amazon EC2 service. Such an image combines hardware characteristics of a machine with data stored on the hard disk (installed programs, data files, etc.).
When you launch a computer in a cloud (called instances), you choose an AMI from which it will be launched. Amazon allows you to create your own custom AMIs.
Creating and using AMIs simplifies the preparations for cloud testing:
AMIs allow saving time and effort when creating a cloud testing environment: you can prepare AMIs with different sets of operating systems and software and then use them to launch instances that don’t have to be configured anymore, just do it once and start testing.
AMIs allow you to easily increase the number of test machines in a cloud: if you need a lot of machines with the same operating systems and software, you can use AMIs to launch any number of instances at once (for example, you can prepare images having TestExecute and the HTTP Load Testing Remote Agent for deploying distributed and load tests to launch the required number of instances with these tests).
The use of AMIs provides equal conditions for test runs. Before each run, you can create instances from a “clean” AMI so that previous test results don’t affect the current test run.
AMIs improve the test environment’s reliability: if you have an instance running, and it stops working for some reason (infected by a virus, was accidentally terminated, etc.), you can quickly launch an identical instance from an AMI prepared earlier.
You may pre-configure one or several AMIs for your cloud testing and then use them to launch all or most of your test instances. For example, you can install the following software on an AMI:
TestComplete or TestExecute to execute tests in a cloud.
An FTP server to upload the needed tests for TestComplete and TestExecute.
An HTTP server to properly configure the instances via the web interface.
So, when launching an instance, you will not have to install the software on them.
Using custom AMIs is especially convenient when you need to launch a large number of computers configured the same way.
Amazon offers two types of AMIs: Instance-store Images and EBS Images. These types differ in the way Amazon stores instances’ hard disk data between runs (for details, see the Cloud Testing With TestComplete article). In this article, we will deal with EBS Images AMIs.To create an AMI, you need to launch an instance, install the required software on it and configure it. After that, you can create the AMI. Once the AMI is no longer needed, you can delete it so you no longer have to pay for storage. We will discuss these processes more specifically later on.
Creating an Amazon Machine Image for Cloud Testing
The general procedure of creating an AMI is as follows:
Launching an instance.
Preparing the instance (installing the required software on the instance and configuring it).
Creating an AMI.
Two important notes:
While creating an AMI, you cannot work with the instance, it is unavailable.
The instructions on creating an AMI provided in this article can be applied only to instances launched from EBS Images.
1. Launching an Instance for Cloud Testing
To launch an instance, open the AWS Management Console. To do that, go to the http://aws.amazon.com/ec2 page of the Amazon EC2 service and click Sign Up For Amazon EC2:
Figure 1 - The Amazon EC2 service’s web page
Specify your e-mail and password. After logging into Amazon EC2, click the AWS Management Console link.
The following web page is displayed:
Figure 2 - AWS Management Console
To launch an instance, you first need to create a key pair and configure security groups. We will launch an instance from an AMI with the ami-ba22c0d3 identifier – it is an AMI of the EBS Images type, which is an image of a computer having the i386 architecture and the Microsoft Windows Server 2003 R2 operating system. A detailed description of the process of launching this type of instance is provided in the Cloud Testing With TestComplete article.
2. Configuring the Instance for Cloud Testing
After the instance is launched, you can connect to it using the Remote Desktop Connection application, which is a component of most Windows operating systems. After that, you can install TestComplete, the tested application and other necessary software on the instance, copy your test project to it and configure the cloud testing environment accordingly. You can find more information about connecting to an instance via the Remote Desktop Connection and installing TestComplete on it in the Cloud Testing With TestComplete article.
3. Creating an Image for Cloud Testing
To create an image, open the AWS Management Console’s page for managing the Amazon EC2 service. The page is opened by default when opening the AWS Management Console. However, if you have switched to another service, click Amazon EC2 in the top left corner of the web page to return to the Amazon EC2 settings.
Then switch to the Instances page by selecting INSTANCES > Instances in the Navigation panel. Enable the check box of the instance that you will use to create the AMI and select Actions | Create Image from the menu:
Figure 3 - Creating an AMI
The Create Image dialog will appear. Here, you need to specify the name and description of the image being created:
Figure 4 - Specifying the name and description of the new AMI
Enter the needed values and click Create This Image. The system will start creating the image. Now, switch to the Amazon Machine Images page. For that, select IMAGES > AMIs in the Navigation panel. Here, you will see that the new image is being prepared - this process will take time so be patient:
Figure 5 - The process of creating the new image
Note that the Name column displayed in the image above is hidden by default. To add columns to the table, click Show/Hide.
While creating an AMI, a snapshot of the instance’s hard disk is also created. To view the snapshot’s properties and control them, open the EBS Snapshots page by selecting ELASTIC BLOCK STORE > Snapshots in the Navigation panel. The Snapshot ID field shows the identifier of the created snapshot. This value is necessary when deleting the AMI (we will discuss this later):
Figure 6 - A snapshot of the instance’s hard disk
Using an AMI to Launch Instances for Cloud Testing
As soon as the image is ready, you can use it to launch new instances. To do that, select IMAGES > AMIs in the Navigation panel - the Amazon Machine Images page will appear.
Select the needed image (by enabling the check box) on this web page and click Launch or Spot Request:
Figure 7 - Launching instances by using a pre-configured image
After clicking Launch or Spot Request, the Request Instances Wizard appears. It will guide you through the process of launching the instance. Follow the instructions the wizard provides.
When testing in a cloud, you may need to launch several instances using the same image. To do that, you need to specify the needed number of instances on launch. For example, let’s launch two more instances based on the created AMI. Click Launch and specify the required number of instances on the INSTANCE DETAILS page of the Request Instances Wizard:
Figure 8 - The INSTANCE DETAILS page of the Request Instances Wizard
Important: If you want all new instances to be located in the same availability zone as the instance from which the image was created, specify the relevant availability zone in the Availability Zone field on the INSTANCE DETAILS page. In our case, it is us-east-1d as shown in the image above, because the instance that the image was created from belongs to this availability zone. When you should use different availability zones will be discussed in future articles.
Note: if you simultaneously launch several instances without selecting any particular availability zone, (that is, “No Preference” is specified in the Availability Zone field), all new instances will be launched in the same availability zone.
After launching the instances, you can go to the My Instances page in the AWS Management Console to see the list of launched instances. For that, select INSTANCES > Instances in the Navigation panel. Altogether, we have three launched instances in our case: we created an image from the first one and later launched two more instances.
Figure 9 - Launched instances
Deleting an AMI for Cloud Testing
The procedure of deleting an AMI involves two steps:
Deregistering the AMI;
Deleting the snapshot associated with the AMI.
1. Deregistering an AMI for Cloud Testing
To deregister an AMI, follow the instructions below:
Go to the Amazon Machine Images page – select IMAGES > AMIs in the AWS Management Console. On this page, enable the check box of the needed AMI.
Save the ID of the snapshot associated with the AMI (in our case, it is snap-23366d4a) – you will need it in the next step.
Click Action | Deregister:
Figure 10 - Deregistering an AMI
2. Deleting the Snapshot Associated With the AMI for Cloud Testing
To delete the snapshot associated with the AMI, follow the instructions below:
In the AWS Management Console, go to the EBS Snapshots page – for that, select ELASTIC BLOCK STORE > Snapshots in the Navigation panel.
Then, select the snapshot (by enabling the check box) having the ID you saved in the previous step.
Figure 11 - Deleting the snapshot associated with the deregistered AMI
After that, your AMI will be completely deleted.
In this article, we have pointed out that images of computers launched in Amazon’s cloud can be used to simplify deployment of a cloud testing environment and to improve its reliability. Also, we have explained how to create and delete images and how to launch the needed number of instances from them. We hope, this information will assist you in organizing your cloud testing.
Other Articles About Cloud Testing