blob: 48af0849d1971254a3a3ca9ee32bc37616c2d254 [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
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
JordanP68c3f032013-06-25 18:50:49 +020019from tempest import config
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053020from tempest import test
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020021
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000022CONF = config.CONF
23
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020024
ivan-zhuf2b00502013-10-18 10:06:52 +080025class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020026
27 @classmethod
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010028 def resource_setup(cls):
Salvatore Orlando5a337242014-01-15 22:49:22 +000029 # This test needs a network and a subnet
30 cls.set_network_resources(network=True, subnet=True)
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010031 super(VirtualInterfacesTestJSON, cls).resource_setup()
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020032 cls.client = cls.servers_client
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090033 resp, server = cls.create_test_server(wait_until='ACTIVE')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020034 cls.server_id = server['id']
35
Hoisaleshwara Madan V Sf009df42013-12-04 12:48:02 +053036 @test.skip_because(bug="1183436",
37 condition=CONF.service_available.neutron)
38 @test.attr(type='gate')
Matthew Treinish2df97482014-06-13 15:02:26 -040039 @test.services('network')
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.")