blob: 35f0fc0a5feb850ab765cacd028b2a3dab7bce11 [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
JordanP68c3f032013-06-25 18:50:49 +020019import testtools
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020020
Sean Dague1937d092013-05-17 16:36:38 -040021from tempest.api.compute import base
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020022from tempest.common.utils.data_utils import rand_name
JordanP68c3f032013-06-25 18:50:49 +020023from tempest import config
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020024from tempest import exceptions
25from tempest.test import attr
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020026
27
Attila Fazekas19044d52013-02-16 07:35:06 +010028class VirtualInterfacesTestJSON(base.BaseComputeTest):
29 _interface = 'json'
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020030
JordanP68c3f032013-06-25 18:50:49 +020031 CONF = config.TempestConfig()
32
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020033 @classmethod
Attila Fazekas19044d52013-02-16 07:35:06 +010034 def setUpClass(cls):
35 super(VirtualInterfacesTestJSON, cls).setUpClass()
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020036 cls.client = cls.servers_client
Mauro S. M. Rodrigues0a1bdff2013-03-11 11:41:18 -040037 resp, server = cls.create_server(wait_until='ACTIVE')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020038 cls.server_id = server['id']
39
Mark McClainf2982e82013-07-06 17:48:03 -040040 @testtools.skipIf(CONF.network.neutron_available, "This feature is not " +
41 "implemented by Neutron. See bug: #1183436")
Giulio Fidenteba3985a2013-05-29 01:46:36 +020042 @attr(type='gate')
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020043 def test_list_virtual_interfaces(self):
44 # Positive test:Should be able to GET the virtual interfaces list
45 # for a given server_id
46 resp, output = self.client.list_virtual_interfaces(self.server_id)
47 self.assertEqual(200, resp.status)
48 self.assertNotEqual(output, None)
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020049 virt_ifaces = output
50 self.assertNotEqual(0, len(virt_ifaces['virtual_interfaces']),
51 'Expected virtual interfaces, got 0 interfaces.')
52 for virt_iface in virt_ifaces['virtual_interfaces']:
53 mac_address = virt_iface['mac_address']
54 self.assertTrue(netaddr.valid_mac(mac_address),
55 "Invalid mac address detected.")
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020056
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040057 @attr(type=['negative', 'gate'])
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020058 def test_list_virtual_interfaces_invalid_server_id(self):
59 # Negative test: Should not be able to GET virtual interfaces
60 # for an invalid server_id
Rami Vaknin7b9f36b2013-02-20 00:09:07 +020061 invalid_server_id = rand_name('!@#$%^&*()')
62 self.assertRaises(exceptions.NotFound,
63 self.client.list_virtual_interfaces,
64 invalid_server_id)
Rami Vaknin76bc8bd2013-02-17 16:18:27 +020065
66
Attila Fazekas19044d52013-02-16 07:35:06 +010067class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
68 _interface = 'xml'