Remove invalid test methods for config option port_range

Config option port_range with parameter regex="\d+:\d+",
which means if the port_range's value doesn't match this,
a ValueError will be raised when get port_rang's value.
So simply the code and remove invalid test cases.

Change-Id: I904f81de822dbfa9d3b8c1332a81738f650216f9
Related-Bug: #1517839
This commit is contained in:
ChangBo Guo(gcb) 2016-06-09 13:56:01 +08:00
parent dc0c8710e0
commit 0a471bb06d
2 changed files with 6 additions and 19 deletions

View File

@ -67,14 +67,13 @@ def release_port(host, port):
def _get_port_range():
config_range = CONF.serial_console.port_range
try:
start, stop = map(int, config_range.split(':'))
if start >= stop:
raise ValueError
except ValueError:
start, stop = map(int, config_range.split(':'))
if start >= stop:
default_port_range = nova.conf.serial_console.DEFAULT_PORT_RANGE
LOG.warning(_LW("serial_console.port_range should be <num>:<num>. "
"Given value %(port_range)s could not be parsed. "
LOG.warning(_LW("serial_console.port_range should be in the "
"format <start>:<stop> and start < stop, "
"Given value %(port_range)s is invalid. "
"Taking the default port range %(default)s."),
{'port_range': config_range,
'default': default_port_range})

View File

@ -46,18 +46,6 @@ class SerialTestCase(test.NoDBTestCase):
self.assertEqual(10000, start)
self.assertEqual(20000, stop)
def test_get_port_range_not_numeric(self):
self.flags(port_range='xxx:yyy', group='serial_console')
start, stop = serial._get_port_range()
self.assertEqual(10000, start)
self.assertEqual(20000, stop)
def test_get_port_range_invalid_syntax(self):
self.flags(port_range='10:20:30', group='serial_console')
start, stop = serial._get_port_range()
self.assertEqual(10000, start)
self.assertEqual(20000, stop)
@mock.patch('socket.socket')
def test_verify_port(self, fake_socket):
s = mock.MagicMock()