From f22a9b92a91cb9c001b98b6d699a3dc1696e1b9d Mon Sep 17 00:00:00 2001 From: Luna Date: Fri, 1 Mar 2019 04:39:12 -0300 Subject: [PATCH] remove voice websocket fields from configs - run: remove vws spawn - tests.conftest: rollback to unused_tcp_port fixture --- config.ci.py | 6 ------ config.example.py | 6 ------ run.py | 10 ++-------- tests/conftest.py | 15 ++------------- 4 files changed, 4 insertions(+), 33 deletions(-) diff --git a/config.ci.py b/config.ci.py index 04f1fdd..24d6046 100644 --- a/config.ci.py +++ b/config.ci.py @@ -38,18 +38,12 @@ class Config: # will hit the websocket. # e.g 'gateway.example.com' for reverse proxies. WEBSOCKET_URL = 'localhost:5001' - VOICE_WEBSOCKET_URL = 'localhost:5002' # Where to host the websocket? # (a local address the server will bind to) WS_HOST = 'localhost' WS_PORT = 5001 - #: Where to host the VOICE websocket? - # (a local address the server will bind to) - VWS_HOST = 'localhost' - VWS_PORT = 5003 - # Postgres credentials POSTGRES = {} diff --git a/config.example.py b/config.example.py index ad6de74..e784e8e 100644 --- a/config.example.py +++ b/config.example.py @@ -46,18 +46,12 @@ class Config: # will hit the websocket. # e.g 'gateway.example.com' for reverse proxies. WEBSOCKET_URL = 'localhost:5001' - VOICE_WEBSOCKET_URL = 'localhost:5003' #: Where to host the websocket? # (a local address the server will bind to) WS_HOST = '0.0.0.0' WS_PORT = 5001 - #: Where to host the VOICE websocket? - # (a local address the server will bind to) - VWS_HOST = 'localhost' - VWS_PORT = 5003 - #: Mediaproxy URL on the internet # mediaproxy is made to prevent client IPs being leaked. MEDIA_PROXY = 'localhost:5002' diff --git a/run.py b/run.py index 153e4eb..c467aaa 100644 --- a/run.py +++ b/run.py @@ -72,7 +72,6 @@ from litecord.jobs import JobManager from litecord.voice.manager import VoiceManager from litecord.gateway import websocket_handler -from litecord.voice.websocket_starter import voice_websocket_handler from litecord.utils import LitecordJSONEncoder @@ -323,19 +322,14 @@ async def app_before_serving(): init_app_managers(app) await post_app_start(app) - # start gateway websocket and voice websocket + # start gateway websocket + # voice websocket is handled by the voice server ws_fut = start_websocket( app.config['WS_HOST'], app.config['WS_PORT'], websocket_handler ) - vws_fut = start_websocket( - app.config['VWS_HOST'], app.config['VWS_PORT'], - voice_websocket_handler - ) - await ws_fut - await vws_fut @app.after_serving diff --git a/tests/conftest.py b/tests/conftest.py index 0750091..66c5e6f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,30 +29,19 @@ sys.path.append(os.getcwd()) from run import app as main_app, set_blueprints -# pytest-sanic's unused_tcp_port can't be called twice since -# pytest fixtures etc etc. -def _unused_port(): - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: - sock.bind(('127.0.0.1', 0)) - return sock.getsockname()[1] - @pytest.fixture(name='app') -def _test_app(event_loop): +def _test_app(unused_tcp_port, event_loop): set_blueprints(main_app) main_app.config['_testing'] = True # reassign an unused tcp port for websockets # since the config might give a used one. - ws_port, vws_port = _unused_port(), _unused_port() - print(ws_port, vws_port) + ws_port = unused_tcp_port main_app.config['WS_PORT'] = ws_port main_app.config['WEBSOCKET_URL'] = f'localhost:{ws_port}' - main_app.config['VWS_PORT'] = vws_port - main_app.config['VOICE_WEBSOCKET_URL'] = f'localhost:{vws_port}' - # make sure we're calling the before_serving hooks event_loop.run_until_complete(main_app.startup())