diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..5dd1e42 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +build: false + +platform: + - x64 + +environment: + matrix: + - PYTHON_VERSION: 3.5 + MINICONDA_DIRNAME: C:\Miniconda3-x64 + +matrix: + fast_finish: false + +init: + - ECHO %PYTHON_VERSION% %MINICONDA_DIRNAME% + +install: + - cmd: set "PATH=%MINICONDA_DIRNAME%;%MINICONDA_DIRNAME%\\Scripts;%PATH%" + - cmd: conda config --set always_yes true + - cmd: conda update --quiet conda + - cmd: conda info --all + - cmd: conda create --quiet --name conda-env-%PYTHON_VERSION% python=%PYTHON_VERSION% + - cmd: activate conda-env-%PYTHON_VERSION% + - cmd: pip install --disable-pip-version-check --user --upgrade pip + - cmd: pip install -e . + - cmd: pip install pytest pytest-xdist + +test_script: + - cmd: pytest -n 8 -sv diff --git a/docs/source/about.rst b/docs/source/about.rst index c675f3f..438b3a2 100644 --- a/docs/source/about.rst +++ b/docs/source/about.rst @@ -112,7 +112,8 @@ always take this into account: #. osBrain uses `pickle `_ for serialization by default, which means that the system performance may as well depend on this package. Serialization is configurable, though. -#. osBrain default transport is IPC by default, but :ref:`it can be changed +#. osBrain default transport is IPC for operating systems that provide UNIX + domain sockets, and TCP for the rest. :ref:`It can be changed globally or configured specifically for each bind `. Note, however, that when using TCP, the network may have a great impact on performance. diff --git a/docs/source/transport_protocol.rst b/docs/source/transport_protocol.rst index d14cd23..320f391 100644 --- a/docs/source/transport_protocol.rst +++ b/docs/source/transport_protocol.rst @@ -12,7 +12,8 @@ Transport protocol Available transports ==================== -Althought the default transport protocol is IPC, there are other transport +Althought the default transport protocol is IPC for operating systems that +provide UNIX domain sockets and TCP for the rest, there are other transport protocols that can be used in osBrain: - ``tcp``: common `TCP `_. Can always be used, and must be used to communicate agents running in diff --git a/osbrain/tests/test_agent_transport.py b/osbrain/tests/test_agent_transport.py index a2eb249..751af2c 100644 --- a/osbrain/tests/test_agent_transport.py +++ b/osbrain/tests/test_agent_transport.py @@ -6,6 +6,7 @@ from shutil import rmtree from tempfile import mkdtemp from uuid import uuid4 +import pytest import osbrain from osbrain import Agent @@ -24,46 +25,71 @@ def test_agent_bind_transport_global(nsproxy): # Default transport agent = run_agent('a0') address = agent.bind('PUSH') - assert address.transport == 'ipc' + assert address.transport == osbrain.config['TRANSPORT'] + - # Changing default global transport +def test_agent_bind_transport_global_tcp(nsproxy): + """ + Test global transport TCP. + """ osbrain.config['TRANSPORT'] = 'tcp' - agent = run_agent('a1') + agent = run_agent('a0') address = agent.bind('PUSH') assert address.transport == 'tcp' + +@pytest.mark.skipif(os.name != 'posix', reason='IPC transport not available') +def test_agent_bind_transport_global_ipc(nsproxy): + """ + Test global transport IPC. + """ osbrain.config['TRANSPORT'] = 'ipc' - agent = run_agent('a2') + agent = run_agent('a0') address = agent.bind('PUSH') assert address.transport == 'ipc' -def test_agent_bind_transport_agent(nsproxy): +def test_agent_bind_transport_agent_tcp(nsproxy): """ - Test agent default transport. + Test agent TCP transport. """ agent = run_agent('a0', transport='tcp') address = agent.bind('PUSH') assert address.transport == 'tcp' + +@pytest.mark.skipif(os.name != 'posix', reason='IPC transport not available') +def test_agent_bind_transport_agent_ipc(nsproxy): + """ + Test agent IPC transport. + """ agent = run_agent('a1', transport='ipc') address = agent.bind('PUSH') assert address.transport == 'ipc' -def test_agent_bind_transport_bind(nsproxy): +def test_agent_bind_transport_tcp(nsproxy): """ - Test bind transport. + Test TCP bind transport. """ agent = run_agent('a0') address = agent.bind('PUSH', transport='tcp') assert address.transport == 'tcp' + +@pytest.mark.skipif(os.name != 'posix', reason='IPC transport not available') +def test_agent_bind_transport_inproc(nsproxy): + """ + Test inproc bind transport. + """ + agent = run_agent('a0') + address = agent.bind('PUSH', transport='inproc') assert address.transport == 'inproc' +@pytest.mark.skipif(os.name != 'posix', reason='IPC transport not available') def test_agent_bind_given_address(nsproxy): """ Test agent binding to an specified address using TCP and IPC transport @@ -90,6 +116,7 @@ def test_agent_bind_given_address(nsproxy): assert address.address == tcp_addr +@pytest.mark.skipif(os.name != 'posix', reason='IPC transport not available') def test_agent_ipc_from_different_folders(nsproxy): """ IPC should work well even when agents are run from different folders.