Using Elastic IPs for Cloud Testing
Applies to: TestComplete 7 - 10
This article explains the use of different addresses of a cloud computer (which is called an instance) and describes how to use elastic IPs to solve the problem related to address changing after restarting cloud computers.
For related technical articles on cloud testing, please see the Other Articles About Cloud Testing section.
Instance Addresses in Cloud Testing
Each computer in a cloud has the internal IP, external IP, private DNS and public DNS addresses associated with it – these addresses play the same role as the corresponding addresses of an ordinary physical PC. They can be used to transfer data among computers in a cloud or to organize distributed testing and other communications.
Computers in a cloud are called instances. Instances launched from an Amazon Machine Image (AMI) of the EBS Images type can later be stopped and then started again. After restarting an instance, its internal IP, external IP, private DNS and public DNS addresses all change. So, if you use these addresses in your automated tests, these tests will stop working when the instance is stopped.
To solve the problem, you can make use of a special Amazon EC2 service, which is called Elastic IP. Elastic IP allows allocating external IPs and associating them with your instances. At that, such IP addresses can later be disassociated from some instances and then associated with other instances.
When stopping an instance, its association with the elastic IP is lost. However, you can associate this elastic IP with any other running instance you have. Thus, when you start the stopped instance again, you can associate it with the same elastic IP. This can be done using not only the AWS Management Console, but also the AWS Command Line Tools and the AWS SDK. Thus, the instance will have the constant IP, and you will not have to correct the addresses in your test project.
As of January, 2014, the cost of using an elastic IP was as follows:
- the elastic IP is free if it is associated with an instance;
- $ 0.005 per hour if the IP is not associated with an instance;
- $ 0.005 per hour per additional Elastic IP address associated with a running instance.
- $ 0.10 for every re-association of the address if the number of re-associations exceeds 100 per month.
- $ 0.01 per 1 GB of data transferred in any direction.
If you have an allocated elastic IP and do not plan to use it in the future, you can release the address not to pay for it.
Viewing Instance Addresses in the AWS Management Console
Let’s see how we can find out each of the instance addresses. Open the AWS Management Console. For that, go to the Amazon EC2 service’s http://aws.amazon.com/ec2 page and click Sign Up For Amazon EC2:
Figure 1. The Amazon EC2 service page
On the page that appears, specify your e-mail and password and sign in to Amazon EC2. After you have logged into the system, click the AWS Management Console link. The following web page will be
Figure 2. The AWS Management Console
We will need a running instance. If you have no running instances, you can launch a new one. To launch it, you need to create a key pair and configure security groups if you have not done this before. We will launch an instance in the US East region from an AMI with the ami-ba22c0d3 ID. The AMI is an image of a computer with the i386 architecture and the Microsoft Windows Server 2003 R2 operating system. The step-by-step procedure of launching an instance from such an AMI is described in the Cloud Testing With TestComplete article.
Go to the Instances page in the AWS Management Console. For that, select INSTANCES > Instances in the Navigation panel. On this page, you can view the list of launched instances. By default, the page is customized so that it displays public DNS names and elastic IPs for all of the instances. If you want to view advanced settings for an instance, select the instance by enabling its check box:
Figure 3. The public DNS, private DNS and elastic IP addresses for the instance
In this way, you can learn the public DNS, the private DNS and the elastic IP of your instance. To find out the internal IP, click Show/Hide on the Instances page:
Figure 4. The button invoking the Show/Hide Columns dialog
The Show/Hide Columns dialog window will appear. Use this dialog to choose which properties will be shown in the list of launched instances. Let us check only the instance ID, status and all the instance addresses the dialog provides:
Figure 5. Customizing the instances list to display instance IDs, statuses and addresses
Click Close. The My Instances page will look like this:
Figure 6. The My Instances page after customizing the instances list’s columns to be displayed
Now, you can see your instance’s internal IP in the Private IP column.
There is no special column for the external IP – the public DNS column contains it. In our example, the 18.104.22.168 external IP corresponds to the instance having the ec2-75-101-240-121.compute-1.amazonaws.com public DNS.
Using Elastic IPs in Cloud Testing
As we’ve already mentioned above, after restarting an instance, the internal IP, external IP, private DNS and public DNS addresses change. So, if you use these addresses in the testing process, you will have to either correct your tests to specify new addresses after restarting instances, or develop your own automatic system which will do that.
The simplest way to organize your distributed tests is to use Elastic IPs. You will need to allocate elastic IPs and associate them with the appropriate instances. Nevertheless, after restarting, you will need to re-associate the instances with the elastic IPs that they were associated with before being stopped. However, this can be easily done by using the AWS Management Console, the AWS Command Line Tools and the AWS SDK. Further, we will explain how to do this using the AWS Management Console. Note that the AWS Command Line Tools and the AWS SDK makes this process more automated, as compared to the manual approach of using the AWS Management Console. For example, you can use one .bat file to launch the needed commands from the AWS Command Line Tools to associate all of the instances at once, and in the AWS Management Console, you will need to make associations for each individual instance.
Allocating and Associating Elastic IPs for Cloud Testing
Let’s associate the instance we have launched with the elastic IP. In general, associating an elastic IP with an instance involves two steps:
- Allocating an elastic IP.
- Associating the elastic IP with an instance.
1. Allocating an Elastic IP
To allocate a new elastic IP, go to the Addresses page by selecting NETWORKING & SECURITY > Elastic IPs in the Navigation panel and then click Allocate New Address:
Figure 7. Allocating a new elastic IP
A confirmation window for the elastic IP allocation appears:
Figure 8. Confirming the association of the new elastic IP
Click Yes, Allocate - the new elastic IP will be allocated.
2. Associating the Elastic IP with an Instance
Now, let’s associate the allocated elastic IP with the instance. To do this, select the elastic IP (by enabling its check box) and click Associate:
Figure 9. Associating the elastic IP with the instance
The Associate Address dialog will be displayed. The dialog’s Instance ID combo box contains the IDs of the running instances (the list does not contain the stopped instances’ IDs). Choose the ID of the instance you want to associate the address with from the list and click Associate Address:
Figure 10. Selecting the instance to be associated with the elastic IP
The elastic IP will be associated with the instance:
Figure 11. The elastic IP has been associated with the instance
After that, the instance’s external IP and public DNS will change, but the internal IP and private DNS will stay unchanged:
Figure 12. Instance properties before and after the elastic IP is associated with the instance
Disassociating and Releasing Elastic IPs for Cloud Testing
In a number of cases, you may need to disassociate elastic IPs. For example, you will need to do this to re-associate an IP (first, the elastic IP is disassociated from one instance and then associated with another). Re-associating IPs can be convenient, for example, if you need to test a web application by using TestComplete in several different environments. In this case, you will have several instances with the needed environments and the web application and a single test which uses the elastic IP to address a test instance. To test the application in all environments, you just need to re-associate the elastic IP with the above mentioned test instances several times and launch the test. You can also associate individual elastic IPs with each test instance, but in the above mentioned example, you will have a single elastic IP instead of several ones, so using this resource will cost less.
The procedure of deleting the association between an elastic IP and an instance involves two steps, one of which is obligatory, and the other one is optional:
- Disassociating the elastic IP from an instance.
- Releasing the elastic IP.
Important: you need to perform step 2 only if you are not going to use this IP any longer.
Let’s disassociate the elastic IP from the instance we have just associated it with and then release this address.
1. Disassociating an Elastic IP From an Instance
Go to the Addresses page – for that, select NETWORKING & SECURITY > Elastic IPs in the Navigation panel. After that, select the needed associations between elastic IPs and instances (by enabling their check boxes) and click Disassociate Address:
Figure 13. Disassociating the elastic IP from the instance
The Disassociate Addresses dialog window appears – here, you will need to confirm that you want to disassociate the address:
Figure 14. Confirming the disassociation of the elastic IP from the instance
Click Yes, Disassociate – the address will be disassociated:
Figure 15. The elastic IP has been disassociated from the instance
Once the IP and public DNS have been disassociated, they are no longer associated with the instance, and later, new external addresses will be allocated to it:
Figure 16. Allocating new external addresses after disassociating the elastic IP
2. Releasing the Elastic IP
To release elastic IPs, you need to select the needed elastic IPs (by enabling their check boxes) and click Release Address:
Figure 17. Releasing the elastic IP
A confirmation window for releasing the addresses appears:
Figure 18. Confirming the address releasing
Click Yes, Release – the address will be released. Once it is released, you cannot use it any longer and don’t need to pay for it anymore.
In this article, we have discussed different addresses associated with instances and explained how the problem related to address changes after restarting instances can be solved with elastic IPs. We hope that this information will help you properly organize your cloud testing environment.
Other Articles About Cloud Testing