2016-04-25 11:20:51 +08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
from functional.common import test
|
|
|
|
|
|
|
|
|
|
|
|
class FloatingIpTests(test.TestCase):
|
|
|
|
"""Functional tests for floating ip. """
|
|
|
|
SUBNET_NAME = uuid.uuid4().hex
|
|
|
|
NETWORK_NAME = uuid.uuid4().hex
|
|
|
|
ID = None
|
|
|
|
HEADERS = ['ID']
|
|
|
|
FIELDS = ['id']
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
# Create a network for the floating ip.
|
|
|
|
cls.openstack('network create --external ' + cls.NETWORK_NAME)
|
|
|
|
# Create a subnet for the network.
|
|
|
|
cls.openstack(
|
|
|
|
'subnet create --network ' + cls.NETWORK_NAME +
|
|
|
|
' --subnet-range 10.10.10.0/24 ' +
|
|
|
|
cls.SUBNET_NAME
|
|
|
|
)
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = cls.get_opts(cls.FIELDS)
|
2016-04-25 11:20:51 +08:00
|
|
|
raw_output = cls.openstack(
|
2016-06-17 15:06:40 +08:00
|
|
|
'floating ip create ' + cls.NETWORK_NAME + opts)
|
2016-04-25 11:20:51 +08:00
|
|
|
cls.ID = raw_output.strip('\n')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
2016-06-17 15:06:40 +08:00
|
|
|
raw_output = cls.openstack('floating ip delete ' + cls.ID)
|
2016-04-25 11:20:51 +08:00
|
|
|
cls.assertOutput('', raw_output)
|
|
|
|
raw_output = cls.openstack('subnet delete ' + cls.SUBNET_NAME)
|
|
|
|
cls.assertOutput('', raw_output)
|
|
|
|
raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
|
|
|
|
cls.assertOutput('', raw_output)
|
|
|
|
|
|
|
|
def test_floating_ip_list(self):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(self.HEADERS)
|
2016-06-17 15:06:40 +08:00
|
|
|
raw_output = self.openstack('floating ip list' + opts)
|
2016-04-25 11:20:51 +08:00
|
|
|
self.assertIn(self.ID, raw_output)
|
|
|
|
|
|
|
|
def test_floating_ip_show(self):
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(self.FIELDS)
|
2016-06-17 15:06:40 +08:00
|
|
|
raw_output = self.openstack('floating ip show ' + self.ID + opts)
|
2016-04-25 11:20:51 +08:00
|
|
|
self.assertEqual(self.ID + "\n", raw_output)
|