Beispiel #1
0
 def test_reserve_same_port_twice(
         self, external_service_ports_manager: ExternalServicePortsManager):
     external_service_ports_manager.reserve_port(
         config.EXTERNAL_SERVICE_PORTS_START)
     with pytest.raises(PortNotAvailableException):
         external_service_ports_manager.reserve_port(
             config.EXTERNAL_SERVICE_PORTS_START)
Beispiel #2
0
def external_service_ports_manager():
    previous_start = config.EXTERNAL_SERVICE_PORTS_START
    previous_end = config.EXTERNAL_SERVICE_PORTS_END
    # Limit the range to only contain a single port
    config.EXTERNAL_SERVICE_PORTS_START = get_free_tcp_port()
    config.EXTERNAL_SERVICE_PORTS_END = config.EXTERNAL_SERVICE_PORTS_START + 1
    yield ExternalServicePortsManager()
    config.EXTERNAL_SERVICE_PORTS_END = previous_end
    config.EXTERNAL_SERVICE_PORTS_START = previous_start
Beispiel #3
0
 def test_reserve_port_all_reserved(
     self, external_service_ports_manager: ExternalServicePortsManager
 ):
     external_service_ports_manager.reserve_port()
     with pytest.raises(PortNotAvailableException):
         external_service_ports_manager.reserve_port()
Beispiel #4
0
 def test_reserve_any_port_within_range(
     self, external_service_ports_manager: ExternalServicePortsManager
 ):
     port = external_service_ports_manager.reserve_port()
     assert port == config.EXTERNAL_SERVICE_PORTS_START