This is an automated email from the ASF dual-hosted git repository. jdanek pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/main by this push: new 6243de5 DISPATCH-857, DISPATCH-945, DISPATCH-2098 Add test for shutdown with websocket (#1289) 6243de5 is described below commit 6243de556cc3b7e1994446298e094314c7d89c27 Author: Jiri Daněk <jda...@redhat.com> AuthorDate: Thu Jul 22 13:33:56 2021 +0200 DISPATCH-857, DISPATCH-945, DISPATCH-2098 Add test for shutdown with websocket (#1289) --- .github/workflows/build.yaml | 8 +++--- README | 5 ++++ tests/CMakeLists.txt | 2 +- tests/system_tests_websockets.py | 62 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 673b89c..e70e692 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -99,7 +99,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.6 architecture: x64 - name: Install Python build dependencies @@ -200,11 +200,11 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.6 architecture: x64 - name: Install Python runtime/test dependencies - run: python -m pip install tox quart selectors h2 grpcio protobuf pytest + run: python -m pip install tox quart selectors h2 grpcio protobuf websockets pytest - name: Install Linux runtime/test dependencies if: ${{ runner.os == 'Linux' }} @@ -398,7 +398,7 @@ jobs: run: env -0 | sort -z | tr '\0' '\n' - name: Install Python runtime/test dependencies - run: python3 -m pip install tox quart selectors h2 protobuf pytest + run: python3 -m pip install tox quart selectors h2 protobuf websockets pytest - name: Install Python runtime/test dependencies (Fedora) if: ${{ matrix.container == 'fedora' }} diff --git a/README b/README index 813159b..fc293a8 100644 --- a/README +++ b/README @@ -68,6 +68,11 @@ The TCP system tests run only if Python selectors is available. To install quart, h2 and selectors - pip3 install --user quart h2 selectors +Websocket system tests use the Python websockets asyncio module. + +To install websckets + - pip3 install --user websockets + The gRPC system tests (tests/system_tests_grpc.py) use grpcio and protobuf modules. To install them use: - pip3 install --user grpcio protobuf diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 41eed2e..a914a9f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -103,7 +103,7 @@ foreach(py_test_module endforeach() if(USE_LIBWEBSOCKETS) - set(SYSTEM_TESTS_HTTP system_tests_http) + set(SYSTEM_TESTS_HTTP system_tests_http system_tests_websockets) endif() if(USE_LIBNGHTTP2) diff --git a/tests/system_tests_websockets.py b/tests/system_tests_websockets.py new file mode 100644 index 0000000..613f9fa --- /dev/null +++ b/tests/system_tests_websockets.py @@ -0,0 +1,62 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 unittest + +from system_test import Qdrouterd +from system_test import main_module, TestCase, Process + + +class WebsocketsConsoleTest(TestCase): + """Run websockets tests connecting to the console""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.http_port = cls.tester.get_port() + + config = [ + ('router', {'mode': 'interior', 'id': 'A'}), + ('listener', {'role': 'normal', 'port': cls.http_port, 'http': True}) + ] + config = Qdrouterd.Config(config) + cls.router: Qdrouterd = cls.tester.qdrouterd('A', config, wait=True, expect=Process.EXIT_OK) + + def test_stopping_broker_while_websocket_is_connected_does_not_crash(self): + """Verify the shutdown sequence works when a client is connected to a websocket port. + + Previously, this was broken in DISPATCH-857, DISPATCH-945, DISPATCH-2098""" + import asyncio + try: + import websockets + except ImportError: + self.skipTest("python test requirement package `websockets` is missing") + + async def run(): + uri = f"ws://localhost:{self.http_port}" + async with websockets.connect(uri, subprotocols=['amqp']) as ws: + self.router.terminate() + self.router.wait() + + asyncio.get_event_loop().run_until_complete(run()) + + +if __name__ == '__main__': + unittest.main(main_module()) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org