blob: 968ae47e6fd958c78698e957b77be7e37c9c744e [file] [log] [blame]
Rami Vaknin76bc8bd2013-02-17 16:18:27 +02001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 OpenStack Foundation
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020018import netaddr
19
Sean Dague1937d092013-05-17 16:36:38 -040020from tempest.api.compute import base
JordanP68c3f032013-06-25 18:50:49 +020021from tempest import config
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053022from tempest import test
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020023
24
ivan-zhuf2b00502013-10-18 10:06:52 +080025class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010026 _interface = 'json'
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020027
Sean Dague86bd8422013-12-20 09:56:44 -050028 CONF = config.CONF
JordanP68c3f032013-06-25 18:50:49 +020029
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020030 @classmethod
Attila Fazekas19044d52013-02-16 07:35:06 +010031 def setUpClass(cls):
32 super(VirtualInterfacesTestJSON, cls).setUpClass()
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020033 cls.client = cls.servers_client
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090034 resp, server = cls.create_test_server(wait_until='ACTIVE')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020035 cls.server_id = server['id']
36
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053037 @test.skip_because(bug="1183436",
38 condition=CONF.service_available.neutron)
39 @test.attr(type='gate')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020040 def test_list_virtual_interfaces(self):
41 # Positive test:Should be able to GET the virtual interfaces list
42 # for a given server_id
43 resp, output = self.client.list_virtual_interfaces(self.server_id)
44 self.assertEqual(200, resp.status)
Ionuț Arțăriși7f7d4522013-08-21 11:47:47 +020045 self.assertIsNotNone(output)
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020046 virt_ifaces = output
47 self.assertNotEqual(0, len(virt_ifaces['virtual_interfaces']),
48 'Expected virtual interfaces, got 0 interfaces.')
49 for virt_iface in virt_ifaces['virtual_interfaces']:
50 mac_address = virt_iface['mac_address']
51 self.assertTrue(netaddr.valid_mac(mac_address),
52 "Invalid mac address detected.")
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020053
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020054
Attila Fazekas19044d52013-02-16 07:35:06 +010055class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
56 _interface = 'xml'