Use PortOpt for port options
oslo.config provides PortOpt to validate the range of port [1]. [1] https://github.com/openstack/oslo.config/blob/2.6.0/oslo_config/cfg.py#L1114 Change-Id: Ia624b926994b5a049c9eabaf2496e793b4eb18c6
This commit is contained in:
parent
2f6432ffd5
commit
ed8e779013
|
@ -34,9 +34,9 @@ test_service_opts = [
|
|||
help="Manager for testing"),
|
||||
cfg.StrOpt("test_service_listen",
|
||||
help="Host to bind test service to"),
|
||||
cfg.IntOpt("test_service_listen_port",
|
||||
default=0,
|
||||
help="Port number to bind test service to"), ]
|
||||
cfg.PortOpt("test_service_listen_port",
|
||||
default=8799,
|
||||
help="Port number to bind test service to"), ]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(test_service_opts)
|
||||
|
@ -241,7 +241,7 @@ class TestWSGIService(base.TestCase):
|
|||
@mock.patch('oslo_service.wsgi.Loader')
|
||||
def test_service_random_port(self, mock_loader):
|
||||
test_service = service.WSGIService("test_service")
|
||||
self.assertEqual(0, test_service.port)
|
||||
self.assertEqual(8799, test_service.port)
|
||||
test_service.start()
|
||||
self.assertNotEqual(0, test_service.port)
|
||||
test_service.stop()
|
||||
|
|
Loading…
Reference in New Issue