vmware-nsx-tempest-plugin/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_nsx_networks.py

87 lines
3.9 KiB
Python

# 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 time
from tempest.api.network import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from vmware_nsx_tempest_plugin.common import constants
from vmware_nsx_tempest_plugin.services import nsxp_client
from vmware_nsx_tempest_plugin.services import nsxv3_client
CONF = config.CONF
class NSXv3NetworksTest(base.BaseNetworkTest):
"""Tests the following operations in the Neutron API:
- Create network
- Update network
- Delete network
After the neutron API call, we also need to make sure the corresponding
resource has been created/updated/deleted from NSX backend.
"""
@classmethod
def resource_setup(cls):
super(NSXv3NetworksTest, cls).resource_setup()
cls.nsx = nsxv3_client.NSXV3Client(CONF.nsxv3.nsx_manager,
CONF.nsxv3.nsx_user,
CONF.nsxv3.nsx_password)
cls.nsxp = nsxp_client.NSXPClient(CONF.nsxv3.nsx_manager,
CONF.nsxv3.nsx_user,
CONF.nsxv3.nsx_password)
@decorators.attr(type='nsxv3')
@decorators.idempotent_id('63085723-23ae-4109-ac86-69f895097957')
def test_create_update_delete_nsx_network(self):
# Create a network
name = data_utils.rand_name('network-')
network = self.create_network(network_name=name)
net_id = network['id']
if CONF.network.backend == 'nsxp':
time.sleep(constants.NSXP_BACKEND_SMALL_TIME_INTERVAL)
nsxp_network = self.nsxp.get_logical_switch(network['name'],
network['id'])
self.assertEqual('ACTIVE', network['status'])
self.assertIsNotNone(nsxp_network)
nsx_network = self.nsx.get_logical_switch(network['name'],
network['id'])
self.assertEqual('ACTIVE', network['status'])
self.assertIsNotNone(nsx_network)
# Verify network update
new_name = "New_network"
body = self.networks_client.update_network(net_id, name=new_name)
updated_net = body['network']
if CONF.network.backend == 'nsxp':
time.sleep(constants.NSXP_BACKEND_SMALL_TIME_INTERVAL)
nsxp_network = self.nsxp.get_logical_switch(updated_net['name'],
updated_net['id'])
self.assertEqual(updated_net['name'], new_name)
self.assertIsNotNone(nsxp_network)
nsx_network = self.nsx.get_logical_switch(updated_net['name'],
updated_net['id'])
self.assertEqual(updated_net['name'], new_name)
self.assertIsNotNone(nsx_network)
# Verify delete network
self.networks_client.delete_network(updated_net['id'])
if CONF.network.backend == 'nsxp':
time.sleep(constants.NSXP_BACKEND_SMALL_TIME_INTERVAL)
nsxp_network = self.nsxp.get_logical_switch(updated_net['name'],
updated_net['id'])
self.assertIsNone(nsxp_network)
nsx_network = self.nsx.get_logical_switch(updated_net['name'],
updated_net['id'])
self.assertIsNone(nsx_network)