def validate_instance_dns(self=self): try: for instance in instances: if not re.search("internal", instance.private_dns_name): self.user.ec2.debug( "Did not find instance DNS enabled, skipping test") self.set_instances(instances) return instances self.log.debug( '\n' '# Test to see if Dynamic DNS has been configured \n' '# Per AWS standard, resolution should have private hostname or ' 'private IP as a valid response\n' '# Perform DNS resolution against public IP and public DNS name\n' '# Perform DNS resolution against private IP and private DNS name\n' '# Check to see if nslookup was able to resolve\n') assert isinstance(instance, EuInstance) install_bind_utils_on_instance(instance) self.log.debug( 'Check nslookup to resolve public DNS Name to local-ipv4 address' ) self.assertTrue( instance.found("nslookup " + instance.public_dns_name, instance.private_ip_address), "Incorrect DNS resolution for hostname.") self.log.debug('Check nslookup to resolve public-ipv4 ' 'address to public DNS name') if self.managed_network: self.assertTrue( instance.found("nslookup " + instance.ip_address, instance.public_dns_name), "Incorrect DNS resolution for public IP address") self.log.debug( 'Check nslookup to resolve private DNS Name to local-ipv4 address' ) if self.managed_network: self.assertTrue( instance.found( "nslookup " + instance.private_dns_name, instance.private_ip_address), "Incorrect DNS resolution for private hostname.") self.log.debug( 'Check nslookup to resolve local-ipv4 address to private DNS name' ) self.assertTrue( instance.found( "nslookup " + instance.private_ip_address, instance.private_dns_name), "Incorrect DNS resolution for private IP address") self.log.debug('Attempt to ping instance public_dns_name') self.assertTrue(ping(instance.public_dns_name)) return True except Exception, e: self.log.error('{0}\nValidate_instance_dns error:"{1}"'.format( get_traceback(), e)) return False
def test8_PrivateIPAddressing(self): """ This case was developed to test instances that are launched with private-addressing set to True. The tests executed are as follows: - run an instance with private-addressing set to True - allocate/associate/disassociate/release an Elastic IP to that instance - check to see if the instance went back to private addressing If any of these tests fail, the test case will error out; logging the results. """ if self.current_instances: for instance in self.current_instances: if instance.ip_address == instance.private_ip_address: self.user.ec2.debug("WARNING: System or Static mode detected, skipping " "PrivateIPAddressing") return self.current_instances self.user.ec2.terminate_instances(self.current_instances) self.set_instances(None) instances = self.run_image(private_addressing=True, auto_connect=False, **self.run_instance_params) for instance in instances: address = self.user.ec2.allocate_address() self.assertTrue(address, 'Unable to allocate address') self.user.ec2.associate_address(instance, address) self.log.info('Sleeping for 30 seconds to allow for association') time.sleep(30) instance.update() self.log.debug('Attempting to ping associated IP:"{0}"'.format(address.public_ip)) self.assertTrue(ping(instance.ip_address), "Could not ping instance with new IP") self.log.debug('Disassociating address:{0} from instance:{1}'.format(address.public_ip, instance.id)) address.disassociate() self.log.info('Sleeping for 30 seconds to allow for disassociation') time.sleep(30) instance.update() self.log.debug('Confirming disassociated IP:"{0}" is no longer in use' .format(address.public_ip)) def wait_for_ping(): return ping(address.public_ip, poll_count=1) try: wait_for_result(callback=wait_for_ping, result=False) except WaitForResultException as WE: self.log.error("Was able to ping address:'{0}' that should no long be associated " "with an instance".format(address.public_ip)) raise WE address.release() if instance.ip_address: if (instance.ip_address != "0.0.0.0" and instance.ip_address != instance.private_ip_address): raise RuntimeError("Instance:'{0}' received a new public IP:'{0}' " "after disassociate" .format(instance.id, instance.ip_address)) self.user.ec2.terminate_instances(instances) self.set_instances(instances) return instances
def test5_ElasticIps(self): """ This case was developed to test elastic IPs in Eucalyptus. This test case does not test instances that are launched using private-addressing option. The test case executes the following tests: - allocates an IP, associates the IP to the instance, then pings the instance. - disassociates the allocated IP, then pings the instance. - releases the allocated IP address If any of the tests fail, the test case will error out, logging the results. """ if not self.current_instances: instances = self.run_image(**self.run_instance_params) else: instances = self.current_instances for instance in instances: if instance.ip_address == instance.private_ip_address: self.log.warning( "WARNING: System or Static mode detected, skipping ElasticIps" ) return instances domain = None if instance.vpc_id: domain = 'vpc' # Set domain to 'vpc' for use with instance in a VPC self.address = self.user.ec2.allocate_address(domain=domain) self.assertTrue(self.address, 'Unable to allocate address') self.user.ec2.associate_address(instance, self.address) instance.update() self.assertTrue(ping(instance.ip_address), "Could not ping instance with new IP") self.user.ec2.disassociate_address_from_instance(instance) self.user.ec2.release_address(self.address) self.address = None assert isinstance(instance, EuInstance) time.sleep(5) instance.update() self.assertTrue(ping(instance.ip_address), "Could not ping after dissassociate") self.set_instances(instances) return instances
def test5_ElasticIps(self): """ This case was developed to test elastic IPs in Eucalyptus. This test case does not test instances that are launched using private-addressing option. The test case executes the following tests: - allocates an IP, associates the IP to the instance, then pings the instance. - disassociates the allocated IP, then pings the instance. - releases the allocated IP address If any of the tests fail, the test case will error out, logging the results. """ if not self.current_instances: instances = self.run_image(**self.run_instance_params) else: instances = self.current_instances for instance in instances: if instance.ip_address == instance.private_ip_address: self.log.warning("WARNING: System or Static mode detected, skipping ElasticIps") return instances domain = None if instance.vpc_id: domain = 'vpc' # Set domain to 'vpc' for use with instance in a VPC self.address = self.user.ec2.allocate_address(domain=domain) self.assertTrue(self.address, 'Unable to allocate address') self.user.ec2.associate_address(instance, self.address) instance.update() self.assertTrue(ping(instance.ip_address),"Could not ping instance with new IP") self.user.ec2.disassociate_address_from_instance(instance) self.user.ec2.release_address(self.address) self.address = None assert isinstance(instance, EuInstance) time.sleep(5) instance.update() self.assertTrue(ping(instance.ip_address), "Could not ping after dissassociate") self.set_instances(instances) return instances
def validate_instance_dns(self=self): try: for instance in instances: if not re.search("internal", instance.private_dns_name): self.user.ec2.debug("Did not find instance DNS enabled, skipping test") self.set_instances(instances) return instances self.log.debug('\n' '# Test to see if Dynamic DNS has been configured \n' '# Per AWS standard, resolution should have private hostname or ' 'private IP as a valid response\n' '# Perform DNS resolution against public IP and public DNS name\n' '# Perform DNS resolution against private IP and private DNS name\n' '# Check to see if nslookup was able to resolve\n') assert isinstance(instance, EuInstance) install_bind_utils_on_instance(instance) self.log.debug('Check nslookup to resolve public DNS Name to local-ipv4 address') self.assertTrue( instance.found("nslookup " + instance.public_dns_name, instance.private_ip_address), "Incorrect DNS resolution for hostname.") self.log.debug('Check nslookup to resolve public-ipv4 ' 'address to public DNS name') if self.managed_network: self.assertTrue(instance.found("nslookup " + instance.ip_address, instance.public_dns_name), "Incorrect DNS resolution for public IP address") self.log.debug('Check nslookup to resolve private DNS Name to local-ipv4 address') if self.managed_network: self.assertTrue(instance.found("nslookup " + instance.private_dns_name, instance.private_ip_address), "Incorrect DNS resolution for private hostname.") self.log.debug('Check nslookup to resolve local-ipv4 address to private DNS name') self.assertTrue(instance.found("nslookup " + instance.private_ip_address, instance.private_dns_name), "Incorrect DNS resolution for private IP address") self.log.debug('Attempt to ping instance public_dns_name') self.assertTrue(ping(instance.public_dns_name)) return True except Exception, e: self.log.error('{0}\nValidate_instance_dns error:"{1}"'.format(get_traceback(), e)) return False
def wait_for_ping(): return ping(address.public_ip, poll_count=1)
def test8_PrivateIPAddressing(self): """ This case was developed to test instances that are launched with private-addressing set to True. The tests executed are as follows: - run an instance with private-addressing set to True - allocate/associate/disassociate/release an Elastic IP to that instance - check to see if the instance went back to private addressing If any of these tests fail, the test case will error out; logging the results. """ if self.current_instances: for instance in self.current_instances: if instance.ip_address == instance.private_ip_address: self.user.ec2.debug( "WARNING: System or Static mode detected, skipping " "PrivateIPAddressing") return self.current_instances self.user.ec2.terminate_instances(self.current_instances) self.set_instances(None) instances = self.run_image(private_addressing=True, auto_connect=False, **self.run_instance_params) for instance in instances: address = self.user.ec2.allocate_address() self.assertTrue(address, 'Unable to allocate address') self.user.ec2.associate_address(instance, address) self.log.info('Sleeping for 30 seconds to allow for association') time.sleep(30) instance.update() self.log.debug('Attempting to ping associated IP:"{0}"'.format( address.public_ip)) self.assertTrue(ping(instance.ip_address), "Could not ping instance with new IP") self.log.debug( 'Disassociating address:{0} from instance:{1}'.format( address.public_ip, instance.id)) address.disassociate() self.log.info( 'Sleeping for 30 seconds to allow for disassociation') time.sleep(30) instance.update() self.log.debug( 'Confirming disassociated IP:"{0}" is no longer in use'.format( address.public_ip)) def wait_for_ping(): return ping(address.public_ip, poll_count=1) try: wait_for_result(callback=wait_for_ping, result=False) except WaitForResultException as WE: self.log.error( "Was able to ping address:'{0}' that should no long be associated " "with an instance".format(address.public_ip)) raise WE address.release() if instance.ip_address: if (instance.ip_address != "0.0.0.0" and instance.ip_address != instance.private_ip_address): raise RuntimeError( "Instance:'{0}' received a new public IP:'{0}' " "after disassociate".format(instance.id, instance.ip_address)) self.user.ec2.terminate_instances(instances) self.set_instances(instances) return instances