Merge "Distinguish a preliminary address association test"
This commit is contained in:
commit
60783f4f8c
|
@ -267,6 +267,8 @@ class AddressTest(base.EC2TestCase):
|
|||
VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
|
||||
self.prepare_route(vpc_id, gw_id)
|
||||
|
||||
data = self.client.associate_address(InstanceId=instance_id,
|
||||
AllocationId=alloc_id)
|
||||
assoc_id = data['AssociationId']
|
||||
|
@ -329,7 +331,7 @@ class AddressTest(base.EC2TestCase):
|
|||
time.sleep(2)
|
||||
|
||||
data = self.client.describe_addresses(*[], **{})
|
||||
self.assertIsNone(data['Addresses'][0].get('InstanceId'))
|
||||
self.assertFalse(data['Addresses'][0].get('InstanceId'))
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
|
@ -393,3 +395,26 @@ class AddressTest(base.EC2TestCase):
|
|||
|
||||
data = self.client.release_address(PublicIp=ip)
|
||||
self.cancelResourceCleanUp(clean_a)
|
||||
|
||||
@base.skip_without_vpc()
|
||||
def test_preliminary_associate_address(self):
|
||||
# NOTE(ft): AWS can associate an address to a subnet IP if the subnet
|
||||
# has no internet access
|
||||
vpc_id, subnet_id = self.create_vpc_and_subnet('10.3.0.0/20')
|
||||
self.create_and_attach_internet_gateway(vpc_id)
|
||||
data = self.client.allocate_address(Domain='vpc')
|
||||
alloc_id = data['AllocationId']
|
||||
self.addResourceCleanUp(self.client.release_address,
|
||||
AllocationId=alloc_id)
|
||||
|
||||
data = self.client.create_network_interface(SubnetId=subnet_id)
|
||||
ni_id = data['NetworkInterface']['NetworkInterfaceId']
|
||||
self.addResourceCleanUp(self.client.delete_network_interface,
|
||||
NetworkInterfaceId=ni_id)
|
||||
self.get_network_interface_waiter().wait_available(ni_id)
|
||||
|
||||
data = self.client.associate_address(
|
||||
AllocationId=alloc_id, NetworkInterfaceId=ni_id)
|
||||
assoc_id = data['AssociationId']
|
||||
self.addResourceCleanUp(self.client.disassociate_address,
|
||||
AssociationId=assoc_id)
|
||||
|
|
|
@ -570,3 +570,28 @@ class EC2TestCase(base.BaseTestCase):
|
|||
self.addResourceCleanUp(self.client.delete_subnet, SubnetId=subnet_id)
|
||||
|
||||
return vpc_id, subnet_id
|
||||
|
||||
def prepare_route(self, vpc_id, gw_id):
|
||||
data = self.client.describe_route_tables(
|
||||
Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
|
||||
self.assertEqual(1, len(data['RouteTables']))
|
||||
|
||||
kwargs = {
|
||||
'DestinationCidrBlock': '0.0.0.0/0',
|
||||
'RouteTableId': data['RouteTables'][0]['RouteTableId'],
|
||||
'GatewayId': gw_id
|
||||
}
|
||||
self.client.create_route(*[], **kwargs)
|
||||
|
||||
def create_and_attach_internet_gateway(self, vpc_id):
|
||||
data = self.client.create_internet_gateway()
|
||||
gw_id = data['InternetGateway']['InternetGatewayId']
|
||||
self.addResourceCleanUp(self.client.delete_internet_gateway,
|
||||
InternetGatewayId=gw_id)
|
||||
data = self.client.attach_internet_gateway(VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
self.addResourceCleanUp(self.client.detach_internet_gateway,
|
||||
VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
|
||||
return gw_id
|
||||
|
|
|
@ -120,18 +120,6 @@ class BaseScenarioTest(base.EC2TestCase):
|
|||
}
|
||||
self.client.authorize_security_group_ingress(*[], **kwargs)
|
||||
|
||||
def prepare_route(self, vpc_id, gw_id):
|
||||
data = self.client.describe_route_tables(
|
||||
Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
|
||||
self.assertEqual(1, len(data['RouteTables']))
|
||||
|
||||
kwargs = {
|
||||
'DestinationCidrBlock': '0.0.0.0/0',
|
||||
'RouteTableId': data['RouteTables'][0]['RouteTableId'],
|
||||
'GatewayId': gw_id
|
||||
}
|
||||
self.client.create_route(*[], **kwargs)
|
||||
|
||||
def create_network_interface(self, subnet_id):
|
||||
data = self.client.create_network_interface(SubnetId=subnet_id)
|
||||
ni_id = data['NetworkInterface']['NetworkInterfaceId']
|
||||
|
@ -140,16 +128,3 @@ class BaseScenarioTest(base.EC2TestCase):
|
|||
self.get_network_interface_waiter().wait_available(ni_id)
|
||||
|
||||
return ni_id
|
||||
|
||||
def create_and_attach_internet_gateway(self, vpc_id):
|
||||
data = self.client.create_internet_gateway()
|
||||
gw_id = data['InternetGateway']['InternetGatewayId']
|
||||
self.addResourceCleanUp(self.client.delete_internet_gateway,
|
||||
InternetGatewayId=gw_id)
|
||||
data = self.client.attach_internet_gateway(VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
self.addResourceCleanUp(self.client.detach_internet_gateway,
|
||||
VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
|
||||
return gw_id
|
||||
|
|
|
@ -33,7 +33,8 @@ class VpcAddressTest(scenario_base.BaseScenarioTest):
|
|||
def test_auto_diassociate_address(self):
|
||||
vpc_id, subnet_id = self.create_vpc_and_subnet('10.3.0.0/20')
|
||||
ni_id1 = self.create_network_interface(subnet_id)
|
||||
self.create_and_attach_internet_gateway(vpc_id)
|
||||
gw_id = self.create_and_attach_internet_gateway(vpc_id)
|
||||
self.prepare_route(vpc_id, gw_id)
|
||||
alloc_id1, public_ip1 = self.allocate_address(True)
|
||||
alloc_id2, _ = self.allocate_address(True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue