Test port mac_address update

Adds api admin tests ``test_update_mac`` and ``test_regenerate_mac``.
Also enable the ``port-mac-address-regenerate`` extension in zuul
job.

Related-Bug: #1768690
Depends-On: I7d04beea4810718c3b745de8ea97897b1323267e
Change-Id: I285986c7a19c4804b3c8c3b0a2d2e3f895a46ff7
This commit is contained in:
Harald Jensås 2018-06-26 13:27:49 +02:00
parent 4794ceb2ef
commit 41c4392471
2 changed files with 61 additions and 1 deletions

View File

@ -16,7 +16,7 @@
tox_envlist: all
devstack_localrc:
TEMPEST_PLUGINS: /opt/stack/neutron-tempest-plugin
NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details"
NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-mac-address-regenerate,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details"
devstack_plugins:
neutron: git://git.openstack.org/openstack/neutron.git
neutron-tempest-plugin: git://git.openstack.org/openstack/neutron-tempest-plugin.git

View File

@ -0,0 +1,60 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# 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 netaddr
from tempest.common import utils
from tempest.lib import decorators
from neutron_tempest_plugin.api import base
class PortTestCasesAdmin(base.BaseAdminNetworkTest):
@classmethod
def resource_setup(cls):
super(PortTestCasesAdmin, cls).resource_setup()
cls.network = cls.create_network()
cls.create_subnet(cls.network)
@decorators.idempotent_id('dfe8cc79-18d9-4ae8-acef-3ec6bb719bb1')
def test_update_mac_address(self):
body = self.create_port(self.network)
current_mac = body['mac_address']
# Verify mac_address can be successfully updated.
body = self.admin_client.update_port(body['id'],
mac_address='12:34:56:78:be:6d')
new_mac = body['port']['mac_address']
self.assertNotEqual(current_mac, new_mac)
self.assertEqual('12:34:56:78:be:6d', new_mac)
# Verify that port update without specifying mac_address does not
# change the mac address.
body = self.admin_client.update_port(body['port']['id'],
description='Port Description')
self.assertEqual(new_mac, body['port']['mac_address'])
@decorators.idempotent_id('dfe8cc79-18d9-4ae8-acef-3ec6bb719cc2')
@utils.requires_ext(extension="port-mac-address-regenerate",
service="network")
def test_regenerate_mac_address(self):
body = self.create_port(self.network)
current_mac = body['mac_address']
body = self.admin_client.update_port(body['id'],
mac_address=None)
new_mac = body['port']['mac_address']
self.assertNotEqual(current_mac, new_mac)
self.assertTrue(netaddr.valid_mac(new_mac))