summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Deryabin <dderyabin@mirantis.com>2017-02-07 11:44:01 +0300
committerDenis Deryabin <dderyabin@mirantis.com>2017-03-01 22:38:14 +0300
commit53de7df81fab17de4d52589d528ee00bba247751 (patch)
tree9d60a96630245749ada5e41693b5e4f14cbd1aa9
parentcfbe98059ceb6a37cb61dc541102100546b21124 (diff)
add test_update_vm_ip
add test_vm_associated_2vn Change-Id: Ib1b5f003c63762da55ca6d7e08f7c39631a3abe6
Notes
Notes (review): Verified+1: Plugins CI <plugins.ci@mirantis.com> Code-Review+2: okosse <okosse@mirantis.com> Workflow+1: okosse <okosse@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 07 Mar 2017 12:52:19 +0000 Reviewed-on: https://review.openstack.org/430124 Project: openstack/fuel-plugin-contrail Branch: refs/heads/master
-rw-r--r--plugin_test/vapor/vapor/tests/common/test_base.py60
1 files changed, 59 insertions, 1 deletions
diff --git a/plugin_test/vapor/vapor/tests/common/test_base.py b/plugin_test/vapor/vapor/tests/common/test_base.py
index 8c65447..13a4ddf 100644
--- a/plugin_test/vapor/vapor/tests/common/test_base.py
+++ b/plugin_test/vapor/vapor/tests/common/test_base.py
@@ -11,7 +11,7 @@
11# under the License. 11# under the License.
12 12
13import sys 13import sys
14 14from ipaddress import ip_address, ip_network
15from hamcrest import (assert_that, calling, raises, contains_string, has_item, 15from hamcrest import (assert_that, calling, raises, contains_string, has_item,
16 has_entry, is_not, empty, equal_to, all_of) # noqa H301 16 has_entry, is_not, empty, equal_to, all_of) # noqa H301
17from neutronclient.common import exceptions as neutron_exceptions 17from neutronclient.common import exceptions as neutron_exceptions
@@ -26,6 +26,7 @@ from vapor.helpers import agent_steps
26from vapor.helpers import asserts 26from vapor.helpers import asserts
27from vapor.helpers import contrail_status, policy, connectivity 27from vapor.helpers import contrail_status, policy, connectivity
28from vapor import settings 28from vapor import settings
29from vapor.helpers import contrail_status, nodes_steps
29 30
30 31
31def test_network_deleting_with_server(network, server, contrail_api_client): 32def test_network_deleting_with_server(network, server, contrail_api_client):
@@ -535,3 +536,60 @@ def test_policy_between_vns_diff_proj(different_tenants_resources,
535 server_floating_ip['floating_ip_address'], 536 server_floating_ip['floating_ip_address'],
536 server_ssh, 537 server_ssh,
537 timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT) 538 timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT)
539
540
541def test_vm_associated_2vn(cirros_image, flavor, security_group,
542 contrail_2_networks, server_steps):
543 """Test to validate a VM associated with two VNs.
544 Test steps:
545 1. Create 2 VNs.
546 2. Launch a VM such that it has address from both the VNs.
547 Pass criteria:
548 VM should get both the IPs.
549 """
550 server = server_steps.create_servers(
551 image=cirros_image,
552 flavor=flavor,
553 networks=contrail_2_networks.networks,
554 security_groups=[security_group])[0]
555 server_ips = server_steps.get_ips(server)
556 nets = {net['name'] for net in contrail_2_networks.networks}
557 server_nets = {ip['net'] for addr, ip in server_ips.items()}
558 server_ips = {ip_address(addr) for addr, ip in server_ips.items()}
559 cidrs = {ip_network(subnet['cidr'])
560 for subnet in contrail_2_networks.subnets}
561 assert_that(nets, equal_to(server_nets))
562 # Check each CIDR for each IP
563 ips_in_cidr = {ip for ip in server_ips for cidr in cidrs if ip in cidr}
564 assert_that(server_ips, equal_to(ips_in_cidr))
565
566
567def test_update_vm_ip(server, subnet, port_steps, server_steps):
568 """Test to validate that updating the IP address of the VM fails.
569 Test steps:
570 1. Create a VM in a VN.
571 2. Try to update the IP of the VM.
572 Pass criteria:
573 Modification of fixed IP will not be allowed.
574 Proper error should be observed.
575 """
576 server_fixed_ip = server_steps.get_fixed_ip(server)
577 # Find new IP address from server's network
578 server_fixed_ip_new = ''
579 for net_ip in ip_network(subnet['cidr']).hosts():
580 if str(net_ip) != server_fixed_ip:
581 server_fixed_ip_new = str(net_ip)
582 break
583
584 server_port = port_steps.get_port(
585 device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,
586 device_id=server.id)
587 port_dict = {
588 'fixed_ips': [{'subnet_id': subnet['id'],
589 'ip_address': server_fixed_ip_new}]
590 }
591 assert_that(
592 calling(port_steps.update).with_args(server_port,
593 check=False,
594 **port_dict),
595 raises(neutron_exceptions.BadRequest))