Merge "add test_update_vm_ip add test_vm_associated_2vn"
This commit is contained in:
commit
9e798791e5
|
@ -11,7 +11,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from ipaddress import ip_address, ip_network
|
||||||
from hamcrest import (assert_that, calling, raises, contains_string, has_item,
|
from hamcrest import (assert_that, calling, raises, contains_string, has_item,
|
||||||
has_entry, is_not, empty, equal_to, all_of) # noqa H301
|
has_entry, is_not, empty, equal_to, all_of) # noqa H301
|
||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
|
@ -26,6 +26,7 @@ from vapor.helpers import agent_steps
|
||||||
from vapor.helpers import asserts
|
from vapor.helpers import asserts
|
||||||
from vapor.helpers import contrail_status, policy, connectivity
|
from vapor.helpers import contrail_status, policy, connectivity
|
||||||
from vapor import settings
|
from vapor import settings
|
||||||
|
from vapor.helpers import contrail_status, nodes_steps
|
||||||
|
|
||||||
|
|
||||||
def test_network_deleting_with_server(network, server, contrail_api_client):
|
def test_network_deleting_with_server(network, server, contrail_api_client):
|
||||||
|
@ -535,3 +536,60 @@ def test_policy_between_vns_diff_proj(different_tenants_resources,
|
||||||
server_floating_ip['floating_ip_address'],
|
server_floating_ip['floating_ip_address'],
|
||||||
server_ssh,
|
server_ssh,
|
||||||
timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT)
|
timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
|
def test_vm_associated_2vn(cirros_image, flavor, security_group,
|
||||||
|
contrail_2_networks, server_steps):
|
||||||
|
"""Test to validate a VM associated with two VNs.
|
||||||
|
Test steps:
|
||||||
|
1. Create 2 VNs.
|
||||||
|
2. Launch a VM such that it has address from both the VNs.
|
||||||
|
Pass criteria:
|
||||||
|
VM should get both the IPs.
|
||||||
|
"""
|
||||||
|
server = server_steps.create_servers(
|
||||||
|
image=cirros_image,
|
||||||
|
flavor=flavor,
|
||||||
|
networks=contrail_2_networks.networks,
|
||||||
|
security_groups=[security_group])[0]
|
||||||
|
server_ips = server_steps.get_ips(server)
|
||||||
|
nets = {net['name'] for net in contrail_2_networks.networks}
|
||||||
|
server_nets = {ip['net'] for addr, ip in server_ips.items()}
|
||||||
|
server_ips = {ip_address(addr) for addr, ip in server_ips.items()}
|
||||||
|
cidrs = {ip_network(subnet['cidr'])
|
||||||
|
for subnet in contrail_2_networks.subnets}
|
||||||
|
assert_that(nets, equal_to(server_nets))
|
||||||
|
# Check each CIDR for each IP
|
||||||
|
ips_in_cidr = {ip for ip in server_ips for cidr in cidrs if ip in cidr}
|
||||||
|
assert_that(server_ips, equal_to(ips_in_cidr))
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_vm_ip(server, subnet, port_steps, server_steps):
|
||||||
|
"""Test to validate that updating the IP address of the VM fails.
|
||||||
|
Test steps:
|
||||||
|
1. Create a VM in a VN.
|
||||||
|
2. Try to update the IP of the VM.
|
||||||
|
Pass criteria:
|
||||||
|
Modification of fixed IP will not be allowed.
|
||||||
|
Proper error should be observed.
|
||||||
|
"""
|
||||||
|
server_fixed_ip = server_steps.get_fixed_ip(server)
|
||||||
|
# Find new IP address from server's network
|
||||||
|
server_fixed_ip_new = ''
|
||||||
|
for net_ip in ip_network(subnet['cidr']).hosts():
|
||||||
|
if str(net_ip) != server_fixed_ip:
|
||||||
|
server_fixed_ip_new = str(net_ip)
|
||||||
|
break
|
||||||
|
|
||||||
|
server_port = port_steps.get_port(
|
||||||
|
device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,
|
||||||
|
device_id=server.id)
|
||||||
|
port_dict = {
|
||||||
|
'fixed_ips': [{'subnet_id': subnet['id'],
|
||||||
|
'ip_address': server_fixed_ip_new}]
|
||||||
|
}
|
||||||
|
assert_that(
|
||||||
|
calling(port_steps.update).with_args(server_port,
|
||||||
|
check=False,
|
||||||
|
**port_dict),
|
||||||
|
raises(neutron_exceptions.BadRequest))
|
||||||
|
|
Loading…
Reference in New Issue