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