Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | from tempest.api.baremetal import base |
| 16 | from tempest.common.utils import data_utils |
| 17 | from tempest import exceptions as exc |
| 18 | from tempest import test |
| 19 | |
| 20 | |
| 21 | class TestPorts(base.BaseBaremetalTest): |
| 22 | """Tests for ports.""" |
| 23 | |
| 24 | def setUp(self): |
| 25 | super(TestPorts, self).setUp() |
| 26 | |
| 27 | chassis = self.create_chassis()['chassis'] |
| 28 | self.node = self.create_node(chassis['uuid'])['node'] |
| 29 | |
| 30 | @test.attr(type='smoke') |
| 31 | def test_create_port(self): |
| 32 | node_id = self.node['uuid'] |
| 33 | address = data_utils.rand_mac_address() |
| 34 | |
| 35 | port = self.create_port(node_id=node_id, address=address)['port'] |
| 36 | |
| 37 | self.assertEqual(port['address'], address) |
| 38 | self.assertEqual(port['node_uuid'], node_id) |
| 39 | |
| 40 | @test.attr(type='smoke') |
| 41 | def test_delete_port(self): |
| 42 | node_id = self.node['uuid'] |
| 43 | port_id = self.create_port(node_id=node_id)['port']['uuid'] |
| 44 | |
| 45 | resp = self.delete_port(port_id) |
| 46 | |
| 47 | self.assertEqual(resp['status'], '204') |
| 48 | self.assertRaises(exc.NotFound, self.client.show_port, port_id) |
| 49 | |
| 50 | @test.attr(type='smoke') |
| 51 | def test_show_port(self): |
| 52 | node_id = self.node['uuid'] |
| 53 | address = data_utils.rand_mac_address() |
| 54 | |
| 55 | port_id = self.create_port(node_id=node_id, |
| 56 | address=address)['port']['uuid'] |
| 57 | |
| 58 | resp, port = self.client.show_port(port_id) |
| 59 | |
| 60 | self.assertEqual(port['uuid'], port_id) |
| 61 | self.assertEqual(port['address'], address) |
| 62 | |
| 63 | @test.attr(type='smoke') |
| 64 | def test_list_ports(self): |
| 65 | node_id = self.node['uuid'] |
| 66 | |
| 67 | uuids = [self.create_port(node_id=node_id)['port']['uuid'] |
| 68 | for i in range(0, 5)] |
| 69 | |
| 70 | resp, body = self.client.list_ports() |
| 71 | loaded_uuids = [p['uuid'] for p in body['ports']] |
| 72 | |
| 73 | for u in uuids: |
| 74 | self.assertIn(u, loaded_uuids) |
| 75 | |
| 76 | @test.attr(type='smoke') |
| 77 | def test_update_port(self): |
| 78 | node_id = self.node['uuid'] |
| 79 | port_id = self.create_port(node_id=node_id)['port']['uuid'] |
| 80 | |
| 81 | new_address = data_utils.rand_mac_address() |
| 82 | self.client.update_port(port_id, address=new_address) |
| 83 | |
| 84 | resp, body = self.client.show_port(port_id) |
| 85 | self.assertEqual(body['address'], new_address) |