Bridge API Cases Automated

Change-Id: I6fb1931413dbae09570b7026a2b4ed00e2f020b2
This commit is contained in:
Nilesh Lokhande 2019-07-16 10:35:36 +00:00
parent b997e4f72f
commit c135bdf23a
1 changed files with 658 additions and 3 deletions

View File

@ -487,6 +487,384 @@ class L2GatewayConnectionTest(L2GatewayBase):
"network id is not same as expected in "
"create l2gw connection response")
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8406f64")
def test_l2_gateway_two_connections_create_delete_one(self):
"""
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW create.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_2 = {"dname": device_name, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_2}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
l2gwc_id2 = l2gwc_rsp2[constants.L2GWC]["id"]
# Delete l2gw.
rsp = self.delete_l2gw_connection(l2gwc_id2)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8408f64")
def test_l2_gateway_two_connections_create_delete_two(self):
"""
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW create.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_2 = {"dname": device_name, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_2}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
l2gwc_id = l2gwc_rsp[constants.L2GWC]["id"]
# Delete l2gw.
rsp = self.delete_l2gw_connection(l2gwc_id)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
l2gwc_id2 = l2gwc_rsp2[constants.L2GWC]["id"]
# Delete l2gw.
rsp2 = self.delete_l2gw_connection(l2gwc_id2)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8406ff4")
def test_l2_gateway_two_connections_create_different_bridge_profile(self):
"""
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[1][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_2}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param["l2_gateway_id"],
l2gwc_rsp[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param["network_id"],
l2gwc_rsp[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param2["l2_gateway_id"],
l2gwc_rsp2[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param2["network_id"],
l2gwc_rsp2[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8436ff4")
def test_l2_gateway_two_connections_create_diff_bridge_profile_vlan(self):
"""
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
network_l2gateway = self.create_topology_network("network_l2gateway")
# cidr must be presented & in IPNetwork structure.
self.CIDR = netaddr.IPNetwork('192.168.2.0/24')
self.create_topology_subnet(
"subnet1_l2gateway", network_l2gateway, cidr=self.CIDR,
mask_bits=int(self.SUBNET_1_MASK))
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[1][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param["l2_gateway_id"],
l2gwc_rsp[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param["network_id"],
l2gwc_rsp[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param2["l2_gateway_id"],
l2gwc_rsp2[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param2["network_id"],
l2gwc_rsp2[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8a06ff4")
def test_l2_gateway_two_connections_create_diff_bridge_profile_del1(self):
"""
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[1][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_2}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param["l2_gateway_id"],
l2gwc_rsp[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param["network_id"],
l2gwc_rsp[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param2["l2_gateway_id"],
l2gwc_rsp2[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param2["network_id"],
l2gwc_rsp2[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
l2gwc_id2 = l2gwc_rsp2[constants.L2GWC]["id"]
# Delete l2gw.
rsp2 = self.delete_l2gw_connection(l2gwc_id2)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b8a06ff5")
def test_l2_gateway_two_connections_create_diff_bridge_profile_del2(self):
"""
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[1][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_2}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param["l2_gateway_id"],
l2gwc_rsp[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param["network_id"],
l2gwc_rsp[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertEqual(l2gwc_param2["l2_gateway_id"],
l2gwc_rsp2[constants.L2GWC]["l2_gateway_id"],
"l2gw id is not same as expected in "
"create l2gw connection response")
self.assertEqual(l2gwc_param2["network_id"],
l2gwc_rsp2[constants.L2GWC]["network_id"],
"network id is not same as expected in "
"create l2gw connection response")
l2gwc_id = l2gwc_rsp[constants.L2GWC]["id"]
# Delete l2gw.
rsp = self.delete_l2gw_connection(l2gwc_id)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
l2gwc_id2 = l2gwc_rsp2[constants.L2GWC]["id"]
# Delete l2gw.
rsp2 = self.delete_l2gw_connection(l2gwc_id2)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("7db4f6c9-18c5-4a99-93c1-68bc2ecb48a7")
def test_l2_gateway_connection_create_with_multiple_vlans(self):
@ -567,6 +945,105 @@ class L2GatewayConnectionTest(L2GatewayBase):
"segmentation id is not same as expected in "
"create l2gw connection response")
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("de70d6a2-d454-4a09-b66b-8f39be67b635")
def test_l2_gateway_connection_with_seg_id_recreate(self):
"""
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW connection create.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
l2gwc_id = l2gwc_rsp[constants.L2GWC]["id"]
# Delete l2gw.
rsp = self.delete_l2gw_connection(l2gwc_id)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("de70d6a2-d454-4a09-b66b-8f39be64b635")
def test_l2_gateway_connection_with_seg_id_recreate_diff_profile(self):
"""
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW connection create.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
l2gwc_id = l2gwc_rsp[constants.L2GWC]["id"]
# Delete l2gw.
rsp = self.delete_l2gw_connection(l2gwc_id)
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_204,
rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_204})
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[1][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp2 = self.create_l2gw_connection(l2gwc_param2)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp2.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("819d9b50-9159-48d0-be2a-493ec686534c")
def test_l2_gateway_connection_show(self):
@ -836,13 +1313,13 @@ class L2GatewayConnectionNegative(L2GatewayBase):
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]}
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"]}
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
@ -852,6 +1329,46 @@ class L2GatewayConnectionNegative(L2GatewayBase):
self.assertRaises(lib_exc.Conflict, self.create_l2gw_connection,
l2gwc_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("488faaae-180a-4c48-8b7a-44c3a2433692")
def test_recreate_l2_gateway_connection_diff_profile(self):
"""
Recreate l2 gateway connection using same parameters.
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
device_name2, interface_name = cluster_info[1][0], transport_zone
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
l2gwc_rsp = self.create_l2gw_connection(l2gwc_param)
# Assert if create fails.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_201,
l2gwc_rsp.response["status"],
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
self.assertRaises(lib_exc.Conflict, self.create_l2gw_connection,
l2gwc_param2)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("14606e74-4f65-402e-ae50-a0adcd877a83")
def test_create_l2gwc_with_nonexist_l2gw(self):
@ -925,6 +1442,103 @@ class L2GatewayConnectionNegative(L2GatewayBase):
self.assertRaises(lib_exc.BadRequest, self.create_l2gw, l2gw_name,
l2gw_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("27c7c64f-511f-421e-8b62-dfed143fa00b")
def test_create_l2gw_with_without_seg_id(self):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info("Testing l2_gateway_create api with segmentation ID")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": ""}
self.assertRaises(lib_exc.BadRequest, self.create_l2gw_connection,
l2gwc_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("27c7c64f-511f-421e-8b62-dfed143fc40b")
def test_create_l2gw_with_without_seg_option(self):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info("Testing l2_gateway_create api with segmentation ID")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"]}
self.assertRaises(lib_exc.BadRequest, self.create_l2gw_connection,
l2gwc_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("27c7c64f-511f-421e-8b62-dfed143fc401")
def test_create_l2gw_with_without_network_id(self):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info("Testing l2_gateway_create api with segmentation ID")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id": "", "segmentation_id": self.VLAN_1}
self.assertRaises(lib_exc.NotFound, self.create_l2gw_connection,
l2gwc_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("27c7c64f-511f-421e-8b62-dfed143fc441")
def test_create_l2gw_with_without_gateway(self):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info("Testing l2_gateway_create api with segmentation ID")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": "",
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
self.assertRaises(lib_exc.NotFound, self.create_l2gw_connection,
l2gwc_param)
@decorators.skip_because(bug="1640033")
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("000cc597-bcea-4539-af07-bd70357e8d82")
@ -946,3 +1560,44 @@ class L2GatewayConnectionNegative(L2GatewayBase):
l2gw_param = [device_1]
self.assertRaises(lib_exc.BadRequest, self.create_l2gw, l2gw_name,
l2gw_param)
@decorators.attr(type="nsxv3")
@decorators.idempotent_id("81edfb9e-4722-4565-939c-6593b84362f4")
def test_l2_gateway_two_connections_create_same_vlan(self):
"""
"""
LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info()
else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1]
l2gw_rsp, _ = self.create_l2gw(l2gw_name, l2gw_param)
l2gwc_param = {"l2_gateway_id": l2gw_rsp[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
self.create_l2gw_connection(l2gwc_param)
network_l2gateway = self.create_topology_network("network_l2gateway")
# cidr must be presented & in IPNetwork structure.
self.CIDR = netaddr.IPNetwork('192.168.2.0/24')
self.create_topology_subnet(
"subnet1_l2gateway", network_l2gateway, cidr=self.CIDR,
mask_bits=int(self.SUBNET_1_MASK))
l2gw_name2 = data_utils.rand_name(constants.L2GW)
device_name2, interface_name = cluster_info[0][0], transport_zone
device_2 = {"dname": device_name2, "iname": interface_name}
l2gw_param2 = [device_2]
l2gw_rsp2, _ = self.create_l2gw(l2gw_name2, l2gw_param2)
l2gwc_param2 = {"l2_gateway_id": l2gw_rsp2[constants.L2GW]["id"],
"network_id":
self.topology_networks["network_l2gateway"]["id"],
"segmentation_id": self.VLAN_1}
self.assertRaises(lib_exc.BadRequest, self.create_l2gw_connection,
l2gwc_param2)