blob: 0b2f4c62ca001bba2b46b3e13bfa6c32c9dee97c [file] [log] [blame]
Rami Vaknin76bc8bd2013-02-17 16:18:27 +02001# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020016import netaddr
Matthew Treinishc49fcbe2015-02-05 23:37:34 -050017from tempest_lib import decorators
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020018
Sean Dague1937d092013-05-17 16:36:38 -040019from tempest.api.compute import base
JordanP68c3f032013-06-25 18:50:49 +020020from tempest import config
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053021from tempest import test
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020022
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000023CONF = config.CONF
24
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020025
ivan-zhuf2b00502013-10-18 10:06:52 +080026class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020027
28 @classmethod
Emily Hugenbruche7991d92014-12-12 16:53:36 +000029 def setup_credentials(cls):
Salvatore Orlando5a337242014-01-15 22:49:22 +000030 # This test needs a network and a subnet
31 cls.set_network_resources(network=True, subnet=True)
Emily Hugenbruche7991d92014-12-12 16:53:36 +000032 super(VirtualInterfacesTestJSON, cls).setup_credentials()
33
34 @classmethod
35 def setup_clients(cls):
36 super(VirtualInterfacesTestJSON, cls).setup_clients()
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020037 cls.client = cls.servers_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000038
39 @classmethod
40 def resource_setup(cls):
41 super(VirtualInterfacesTestJSON, cls).resource_setup()
David Kranz0fb14292015-02-11 15:55:20 -050042 server = cls.create_test_server(wait_until='ACTIVE')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020043 cls.server_id = server['id']
44
Matthew Treinishc49fcbe2015-02-05 23:37:34 -050045 @decorators.skip_because(bug="1183436",
46 condition=CONF.service_available.neutron)
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053047 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080048 @test.idempotent_id('96c4e2ef-5e4d-4d7f-87f5-fed6dca18016')
Matthew Treinish2df97482014-06-13 15:02:26 -040049 @test.services('network')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020050 def test_list_virtual_interfaces(self):
51 # Positive test:Should be able to GET the virtual interfaces list
52 # for a given server_id
David Kranzae99b9a2015-02-16 13:37:01 -050053 output = self.client.list_virtual_interfaces(self.server_id)
Ionuț Arțăriși7f7d4522013-08-21 11:47:47 +020054 self.assertIsNotNone(output)
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020055 virt_ifaces = output
56 self.assertNotEqual(0, len(virt_ifaces['virtual_interfaces']),
57 'Expected virtual interfaces, got 0 interfaces.')
58 for virt_iface in virt_ifaces['virtual_interfaces']:
59 mac_address = virt_iface['mac_address']
60 self.assertTrue(netaddr.valid_mac(mac_address),
61 "Invalid mac address detected.")