Skip to content

Commit 9dba843

Browse files
author
Huanxuan Ao
committed
Add functional tests for commands of floating ip
This patch add functinal tests for commands of floating ip Change-Id: I7f29578d0e14884f21183bfb82228d2fe7b7a029
1 parent a0a29df commit 9dba843

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# 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+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class FloatingIpTests(test.TestCase):
19+
"""Functional tests for floating ip. """
20+
SUBNET_NAME = uuid.uuid4().hex
21+
NETWORK_NAME = uuid.uuid4().hex
22+
ID = None
23+
HEADERS = ['ID']
24+
FIELDS = ['id']
25+
26+
@classmethod
27+
def setUpClass(cls):
28+
# Create a network for the floating ip.
29+
cls.openstack('network create --external ' + cls.NETWORK_NAME)
30+
# Create a subnet for the network.
31+
cls.openstack(
32+
'subnet create --network ' + cls.NETWORK_NAME +
33+
' --subnet-range 10.10.10.0/24 ' +
34+
cls.SUBNET_NAME
35+
)
36+
opts = cls.get_show_opts(cls.FIELDS)
37+
raw_output = cls.openstack(
38+
'ip floating create ' + cls.NETWORK_NAME + opts)
39+
cls.ID = raw_output.strip('\n')
40+
41+
@classmethod
42+
def tearDownClass(cls):
43+
raw_output = cls.openstack('ip floating delete ' + cls.ID)
44+
cls.assertOutput('', raw_output)
45+
raw_output = cls.openstack('subnet delete ' + cls.SUBNET_NAME)
46+
cls.assertOutput('', raw_output)
47+
raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
48+
cls.assertOutput('', raw_output)
49+
50+
def test_floating_ip_list(self):
51+
opts = self.get_list_opts(self.HEADERS)
52+
raw_output = self.openstack('ip floating list' + opts)
53+
self.assertIn(self.ID, raw_output)
54+
55+
def test_floating_ip_show(self):
56+
opts = self.get_show_opts(self.FIELDS)
57+
raw_output = self.openstack('ip floating show ' + self.ID + opts)
58+
self.assertEqual(self.ID + "\n", raw_output)

0 commit comments

Comments
 (0)