Add test_create_network_with_contrail
Change-Id: I0ac3d6e2ea8af91a4820241e8f5a6f1c80e71e86
This commit is contained in:
parent
59aec028a4
commit
4aa380b63c
|
@ -12,3 +12,4 @@ from vapor.fixtures.networks import * # noqa
|
|||
from vapor.fixtures.nodes import * # noqa
|
||||
from vapor.fixtures.policies import * # noqa
|
||||
from vapor.fixtures.security_groups import * # noqa
|
||||
from vapor.fixtures.subnets import * # noqa
|
||||
|
|
|
@ -154,3 +154,9 @@ def nodes_ips(os_faults_steps):
|
|||
node_ips_[fqdn] = node_result.payload['stdout_lines']
|
||||
|
||||
return node_ips_
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def default_project(contrail_api_client):
|
||||
proj_id = contrail_api_client.project_get_default_id()
|
||||
return contrail_api_client.project_read(id=proj_id)
|
||||
|
|
|
@ -27,4 +27,5 @@ def contrail_network(contrail_api_client):
|
|||
network_name, = utils.generate_ids()
|
||||
net = types.VirtualNetwork(network_name)
|
||||
contrail_api_client.virtual_network_create(net)
|
||||
return net
|
||||
yield net
|
||||
contrail_api_client.virtual_network_delete(id=net.uuid)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pycontrail.types as types
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def contrail_subnet(contrail_api_client, contrail_network):
|
||||
ipam_id = contrail_api_client.network_ipam_get_default_id()
|
||||
ipam = contrail_api_client.network_ipam_read(id=ipam_id)
|
||||
subnet_type = types.SubnetType(ip_prefix='10.0.0.0', ip_prefix_len=24)
|
||||
vn_sub = types.VnSubnetsType([types.IpamSubnetType(subnet=subnet_type)])
|
||||
contrail_network.add_network_ipam(ipam, vn_sub)
|
||||
contrail_api_client.virtual_network_update(contrail_network)
|
||||
|
||||
yield
|
||||
|
||||
contrail_network.del_network_ipam(ipam)
|
||||
contrail_api_client.virtual_network_update(contrail_network)
|
|
@ -0,0 +1,20 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
def get_server_networks(client, server_id):
|
||||
"""Return contrail network object on which server booted."""
|
||||
for iface in client.virtual_machine_interfaces_list(detail=True):
|
||||
for iface_ref in iface.get_virtual_machine_refs() or []:
|
||||
if iface_ref['uuid'] == server_id:
|
||||
for net_ref in iface.get_virtual_network_refs():
|
||||
yield client.virtual_network_read(id=net_ref['uuid'])
|
|
@ -33,6 +33,9 @@ DB_PURGE_TIMEOUT = 30 * 60
|
|||
# Time to wait service status to be changed
|
||||
SERVICE_STATUS_CHANGE_TIMEOUT = 60
|
||||
|
||||
# Time to wait until nova server will know about attached floating IP
|
||||
FLOATING_IP_BIND_TIMEOUT = 30
|
||||
|
||||
ROLE_CONTRAIL_CONTROLLER = 'contrail-controller'
|
||||
ROLE_CONTRAIL_ANALYTICS = 'contrail-analytics'
|
||||
ROLE_CONTRAIL_DB = 'contrail-db'
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
import itertools
|
||||
import time
|
||||
|
||||
from hamcrest import assert_that, has_length, has_items, has_entries
|
||||
from hamcrest import assert_that, has_length, has_items, has_entries, equal_to
|
||||
from stepler import config as stepler_config
|
||||
|
||||
from vapor.helpers import contrail_steps
|
||||
from vapor.helpers import nodes_steps
|
||||
from vapor import settings
|
||||
|
||||
|
||||
def test_no_connectivity_between_vms_in_different_tenants(
|
||||
|
@ -55,8 +57,9 @@ def test_no_connectivity_between_vms_in_different_tenants(
|
|||
stepler_config.SERVER_ATTR_HOST)
|
||||
|
||||
# Check that there is 2 interfaces on compute - one for each VM
|
||||
assert_that(after_interfaces[compute_fqdn] -
|
||||
before_interfaces[compute_fqdn], has_length(2))
|
||||
assert_that(
|
||||
after_interfaces[compute_fqdn] - before_interfaces[compute_fqdn],
|
||||
has_length(2))
|
||||
|
||||
# Check that networks are present in contrail
|
||||
contrail_networks = contrail_api_client.virtual_networks_list()
|
||||
|
@ -73,3 +76,48 @@ def test_no_connectivity_between_vms_in_different_tenants(
|
|||
id=resource.port['id'])
|
||||
networks_uuid.add(iface.get_virtual_network_refs()[0]['uuid'])
|
||||
assert_that(networks_uuid, has_length(2))
|
||||
|
||||
|
||||
def test_create_network_with_contrail(
|
||||
cirros_image, flavor, security_group, contrail_network,
|
||||
contrail_subnet, public_network, create_floating_ip,
|
||||
contrail_api_client, server_steps, port_steps):
|
||||
"""Check that OpenStack can operate with network created with Contrail.
|
||||
|
||||
Steps:
|
||||
#. Create new network with Contrail API
|
||||
#. Launch 2 instances on created network
|
||||
#. Check ping between instances
|
||||
#. Verify that instances are attached to created network in contrail
|
||||
"""
|
||||
servers = server_steps.create_servers(
|
||||
count=2,
|
||||
image=cirros_image,
|
||||
flavor=flavor,
|
||||
nics=[{
|
||||
'net-id': contrail_network.uuid
|
||||
}],
|
||||
security_groups=[security_group],
|
||||
username=stepler_config.CIRROS_USERNAME,
|
||||
password=stepler_config.CIRROS_PASSWORD)
|
||||
for server in servers:
|
||||
port = port_steps.get_port(
|
||||
device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,
|
||||
device_id=server.id)
|
||||
floating_ip = create_floating_ip(public_network, port=port)
|
||||
server_steps.check_server_ip(
|
||||
server,
|
||||
floating_ip['floating_ip_address'],
|
||||
timeout=settings.FLOATING_IP_BIND_TIMEOUT)
|
||||
|
||||
# Check ping between instances
|
||||
server_steps.check_ping_between_servers_via_floating(
|
||||
servers, ip_types=(stepler_config.FIXED_IP, ))
|
||||
|
||||
# Verify that instances are attached to created network in contrail
|
||||
networks = set()
|
||||
for server in servers:
|
||||
for net in contrail_steps.get_server_networks(contrail_api_client,
|
||||
server.id):
|
||||
networks.add(net.uuid)
|
||||
assert_that(networks, equal_to(set([contrail_network.uuid])))
|
||||
|
|
Loading…
Reference in New Issue