Move interop tests out of tests

It is moved to the top level package `tests_interop`, to avoid circular
dependency, with the dependency moved to `tox`.
pull/308/head
mhchia 2019-09-23 22:00:40 +08:00
parent 4a838033ff
commit 006002f687
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A
20 changed files with 50 additions and 11 deletions

View File

@ -18,7 +18,7 @@ matrix:
- export GOPATH=$HOME/go
- export GOROOT=/usr/local/go
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
- ./tests/interop/go_pkgs/install_interop_go_pkgs.sh
- ./tests_interop/go_pkgs/install_interop_go_pkgs.sh
install:
- pip install --upgrade pip

View File

@ -1,4 +1,4 @@
FILES_TO_LINT = libp2p tests examples setup.py
FILES_TO_LINT = libp2p tests tests_interop examples setup.py
PB = libp2p/crypto/pb/crypto.proto libp2p/pubsub/pb/rpc.proto libp2p/security/insecure/pb/plaintext.proto libp2p/security/secio/pb/spipe.proto
PY = $(PB:.proto=_pb2.py)
PYI = $(PB:.proto=_pb2.pyi)

View File

@ -9,8 +9,6 @@ extras_require = {
"pytest>=4.6.3,<5.0.0",
"pytest-asyncio>=0.10.0,<1.0.0",
"pexpect>=4.6,<5",
# FIXME: Master branch. Use PyPI instead after it is released.
"p2pclient @ git+https://git@github.com/mhchia/py-libp2p-daemon-bindings@628266f",
],
"lint": [
"mypy>=0.701,<1.0",

View File

@ -7,13 +7,46 @@ import pexpect
import pytest
from libp2p.io.abc import ReadWriteCloser
from tests.factories import FloodsubFactory, GossipsubFactory, PubsubFactory
from tests.configs import LISTEN_MADDR
from tests.factories import (
FloodsubFactory,
GossipsubFactory,
HostFactory,
PubsubFactory,
)
from tests.pubsub.configs import GOSSIPSUB_PARAMS
from .daemon import Daemon, make_p2pd
from .utils import connect
@pytest.fixture
def is_host_secure():
return False
@pytest.fixture
def num_hosts():
return 3
@pytest.fixture
async def hosts(num_hosts, is_host_secure):
_hosts = HostFactory.create_batch(num_hosts, is_secure=is_host_secure)
await asyncio.gather(
*[_host.get_network().listen(LISTEN_MADDR) for _host in _hosts]
)
try:
yield _hosts
finally:
# TODO: It's possible that `close` raises exceptions currently,
# due to the connection reset things. Though we don't care much about that when
# cleaning up the tasks, it is probably better to handle the exceptions properly.
await asyncio.gather(
*[_host.close() for _host in _hosts], return_exceptions=True
)
@pytest.fixture
def proc_factory():
procs = []

20
tox.ini
View File

@ -27,11 +27,10 @@ skip_glob=
[testenv]
deps =
passenv = CI TRAVIS TRAVIS_* GOPATH
passenv = CI TRAVIS TRAVIS_*
extras = test
commands =
test: py.test --ignore=tests/interop
interop: py.test tests/interop
test: py.test tests/ -v
basepython =
py37: python3.7
@ -40,6 +39,15 @@ basepython = python3
extras = dev
commands =
mypy -p libp2p -p examples --config-file {toxinidir}/mypy.ini
black --check libp2p tests examples setup.py
isort --recursive --check-only libp2p tests examples setup.py
flake8 libp2p tests examples setup.py
black --check libp2p tests tests_interop examples setup.py
isort --recursive --check-only libp2p tests tests_interop examples setup.py
flake8 libp2p tests tests_interop examples setup.py
[testenv:py37-interop]
deps = p2pclient
passenv = CI TRAVIS TRAVIS_* GOPATH
extras = test
commands =
test: py.test tests_interop/ -v
basepython =
py37: python3.7