|
|
|
@ -21,6 +21,7 @@ from tempest_lib.common.utils import data_utils
|
|
|
|
|
from networking_l2gw.tests.api import base_l2gw
|
|
|
|
|
from networking_l2gw.tests.tempest import config
|
|
|
|
|
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
CONF = config.CONF
|
|
|
|
|
|
|
|
|
@ -108,3 +109,107 @@ class L2GatewayExtensionTestJSON(base.BaseAdminNetworkTest):
|
|
|
|
|
self.assertEqual(l2_gw_id, l2_gw_conn['l2_gateway_id'])
|
|
|
|
|
# List L2Gateway Connections
|
|
|
|
|
self.admin_client.list_l2_gateway_connections()
|
|
|
|
|
|
|
|
|
|
def test_create_l2gw_conn_with_segid_when_l2gw_created_without_segid(self):
|
|
|
|
|
# Create an L2Gateway
|
|
|
|
|
gw_name = data_utils.rand_name('l2gw')
|
|
|
|
|
devices = base_l2gw.get_l2gw_body(CONF.network.l2gw_switch)["devices"]
|
|
|
|
|
if devices[0]['interfaces'][0]['segmentation_id']:
|
|
|
|
|
seg_id = devices[0]['interfaces'][0]['segmentation_id'][0]
|
|
|
|
|
devices[0]['interfaces'][0].pop('segmentation_id')
|
|
|
|
|
body = self.admin_client.create_l2_gateway(
|
|
|
|
|
name=gw_name, devices=devices)
|
|
|
|
|
l2_gateway = body['l2_gateway']
|
|
|
|
|
l2_gw_id = l2_gateway['id']
|
|
|
|
|
self.addCleanup(self.admin_client.delete_l2_gateway, l2_gw_id)
|
|
|
|
|
# Create a network
|
|
|
|
|
name = data_utils.rand_name('network')
|
|
|
|
|
net_body = self.admin_client.create_network(name=name)
|
|
|
|
|
net_id = net_body['network']['id']
|
|
|
|
|
self.addCleanup(self.admin_client.delete_network, net_id)
|
|
|
|
|
# Create an L2Gateway Connection
|
|
|
|
|
l2_gw_conn_body = self.admin_client.create_l2_gateway_connection(
|
|
|
|
|
l2_gateway_id=l2_gw_id, network_id=net_id,
|
|
|
|
|
segmentation_id=seg_id)
|
|
|
|
|
l2_gw_conn_id = l2_gw_conn_body['l2_gateway_connection']['id']
|
|
|
|
|
l2_gw_seg_id = l2_gw_conn_body['l2_gateway_connection'][
|
|
|
|
|
'segmentation_id']
|
|
|
|
|
self.addCleanup(self.admin_client.delete_l2_gateway_connection,
|
|
|
|
|
l2_gw_conn_id)
|
|
|
|
|
# Show details of created L2 Gateway connection
|
|
|
|
|
show_body = self.admin_client.show_l2_gateway_connection(
|
|
|
|
|
l2_gw_conn_id)
|
|
|
|
|
l2_gw_conn = show_body['l2_gateway_connection']
|
|
|
|
|
self.assertEqual(net_id, l2_gw_conn['network_id'])
|
|
|
|
|
self.assertEqual(l2_gw_id, l2_gw_conn['l2_gateway_id'])
|
|
|
|
|
self.assertEqual(str(l2_gw_seg_id),
|
|
|
|
|
str(l2_gw_conn['segmentation_id']))
|
|
|
|
|
|
|
|
|
|
def test_create_update_l2gw_with_multiple_devices(self):
|
|
|
|
|
# Generating name for multi-device L2Gateway
|
|
|
|
|
gw_name = data_utils.rand_name('l2gw')
|
|
|
|
|
# Generating a list consisting 3 random segmentation_ids
|
|
|
|
|
seg_id = random.sample(range(2, 4095), 3)
|
|
|
|
|
# Generating 3 device and interface names
|
|
|
|
|
dev_name1 = data_utils.rand_name('device_name')
|
|
|
|
|
interface_name1 = data_utils.rand_name('interface')
|
|
|
|
|
dev_name2 = data_utils.rand_name('device_name')
|
|
|
|
|
interface_name2 = data_utils.rand_name('interface')
|
|
|
|
|
dev_name3 = data_utils.rand_name('device_name')
|
|
|
|
|
interface_name3 = data_utils.rand_name('interface')
|
|
|
|
|
device_name_list = [dev_name1, dev_name2, dev_name3]
|
|
|
|
|
interface_name_list = [
|
|
|
|
|
interface_name1, interface_name2, interface_name3]
|
|
|
|
|
# Forming the device for multi-device L2Gateway
|
|
|
|
|
devices_list = [{"device_name": device_name_list[0], "interfaces":[{
|
|
|
|
|
"name": interface_name_list[0]}],
|
|
|
|
|
"segmentation_id": str(seg_id[0])}, {
|
|
|
|
|
"device_name": device_name_list[1], "interfaces":[{
|
|
|
|
|
"name": interface_name_list[1]}],
|
|
|
|
|
"segmentation_id": str(seg_id[1])}, {
|
|
|
|
|
"device_name": device_name_list[2], "interfaces":[{
|
|
|
|
|
"name": interface_name_list[2]}],
|
|
|
|
|
"segmentation_id": str(seg_id[2])}]
|
|
|
|
|
# Create the multi-device L2gateway
|
|
|
|
|
body = self.admin_client.create_l2_gateway(
|
|
|
|
|
name=gw_name, devices=devices_list)
|
|
|
|
|
l2_gateway = body['l2_gateway']
|
|
|
|
|
l2_gw_id = l2_gateway['id']
|
|
|
|
|
self.addCleanup(self.admin_client.delete_l2_gateway, l2_gw_id)
|
|
|
|
|
# Check the created multi-device L2Gateway
|
|
|
|
|
device_list = range(3)
|
|
|
|
|
interface_list = range(3)
|
|
|
|
|
show_body = self.admin_client.show_l2_gateway(l2_gw_id)
|
|
|
|
|
self.assertEqual(gw_name, show_body['l2_gateway']['name'])
|
|
|
|
|
self.assertEqual(l2_gateway['id'], show_body['l2_gateway']['id'])
|
|
|
|
|
for i in range(3):
|
|
|
|
|
device_list[i] = show_body['l2_gateway']['devices'][i][
|
|
|
|
|
'device_name']
|
|
|
|
|
interface_list[i] = show_body['l2_gateway']['devices'][i][
|
|
|
|
|
'interfaces'][0]['name']
|
|
|
|
|
for j in [0, 1, 2]:
|
|
|
|
|
self.assertIn(device_name_list[j], device_list)
|
|
|
|
|
self.assertIn(interface_name_list[j], interface_list)
|
|
|
|
|
# Update the gateway device name
|
|
|
|
|
device_list_updated = range(3)
|
|
|
|
|
interface_list_updated = range(3)
|
|
|
|
|
device_updated = [{"device_name": device_name_list[0], "interfaces":[{
|
|
|
|
|
"name": "intNameNew"}]}]
|
|
|
|
|
interface_name_list = [
|
|
|
|
|
interface_name_list[2], interface_name_list[1], "intNameNew"]
|
|
|
|
|
body = self.admin_client.update_l2_gateway(
|
|
|
|
|
l2_gateway['id'], devices=device_updated)
|
|
|
|
|
show_body_updated = self.admin_client.show_l2_gateway(
|
|
|
|
|
l2_gateway['id'])
|
|
|
|
|
# Check updating of multi-device L2gateway
|
|
|
|
|
self.assertEqual(gw_name, show_body_updated['l2_gateway']['name'])
|
|
|
|
|
self.assertEqual(l2_gateway['id'],
|
|
|
|
|
show_body_updated['l2_gateway']['id'])
|
|
|
|
|
for k in range(3):
|
|
|
|
|
device_list_updated[k] = show_body_updated['l2_gateway'][
|
|
|
|
|
'devices'][k]['device_name']
|
|
|
|
|
interface_list_updated[k] = show_body_updated['l2_gateway'][
|
|
|
|
|
'devices'][k]['interfaces'][0]['name']
|
|
|
|
|
for l in range(3):
|
|
|
|
|
self.assertIn(device_name_list[l], device_list_updated)
|
|
|
|
|
self.assertIn(interface_name_list[l], interface_list_updated)
|
|
|
|
|