libp2p/py-libp2p

No mention of Golang installation needed for (local) testing

ShadowJonathan opened this issue · 4 comments

What was wrong?

pytest command fails with "keyerror GOPATH", nowhere in any testing manual is described how to set up the full testing environment, only one command is given, no mention of Go is made, or any specific golang installation version requirements.

Code Command that produced the error

(full path replaced with ... till project root)

(venv) ...\py-libp2p>pytest --numprocesses=4 --looponfail --maxfail=1

Full error output

ImportError while loading conftest '...\py-libp2p\tests_interop\conftest.py'.
tests_interop\conftest.py:17: in <module>
    from libp2p.tools.interop.daemon import Daemon, make_p2pd
libp2p\tools\interop\daemon.py:14: in <module>
    from .envs import GO_BIN_PATH
libp2p\tools\interop\envs.py:4: in <module>
    GO_BIN_PATH = pathlib.Path(os.environ["GOPATH"]) / "bin"
C:\Python38\lib\os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'GOPATH'

Environment

# run this:
(venv) ...\py-libp2p>python -m eth_utils
...\py-libp2p\venv\Scripts\python.exe: No module named eth_utils

(one quick pip installation later)

Output:

Python version:
3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]

Operating System: Windows-10-10.0.18362-SP0

pip freeze result:
apipkg==1.5
appdirs==1.4.3
asn1crypto==1.2.0
atomicwrites==1.3.0
attrs==19.3.0
base58==1.0.3
black==19.3b0
bleach==3.1.0
bumpversion==0.5.3
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
Click==7.0
coincurve==10.0.0
colorama==0.4.3
cytoolz==0.10.1
docformatter==1.3.1
docutils==0.15.2
entrypoints==0.3
eth-hash==0.2.0
eth-typing==2.2.1
eth-utils==1.8.4
execnet==1.7.1
factory-boy==2.12.0
Faker==3.0.0
-e git+https://github.com/shadowjonathan/fastecdsa-any@51164b711e955e81bdbc8a7b49aa81239b38ad78#egg=fastecdsa
filelock==3.0.12
flake8==3.7.9
flake8-bugbear==19.8.0
idna==2.8
isort==4.3.21
keyring==20.0.0
-e git+https://github.com/libp2p/py-libp2p@cac7e3909ae5a7d8c22b28c8595c5fa03ef729db#egg=libp2p
lru-dict==1.1.6
mccabe==0.6.1
more-itertools==8.0.2
multiaddr==0.0.8
mypy==0.750
mypy-extensions==0.4.3
mypy-protobuf==1.15
netaddr==0.7.19
p2pclient==0.1.2
packaging==19.2
pexpect==4.7.0
pkginfo==1.5.0.1
pluggy==0.13.1
protobuf==3.11.1
ptyprocess==0.6.0
py==1.8.0
pycodestyle==2.5.0
pycparser==2.19
pycryptodome==3.9.4
pyflakes==2.1.1
Pygments==2.5.2
pymultihash==0.8.2
PyNaCl==1.3.0
pyparsing==2.4.5
pytest==4.6.7
pytest-asyncio==0.10.0
pytest-forked==1.1.3
pytest-xdist==1.30.0
python-dateutil==2.8.1
pywin32-ctypes==0.2.0
readme-renderer==24.0
requests==2.22.0
requests-toolbelt==0.9.1
rpcudp==3.0.0
six==1.13.0
text-unidecode==1.3
toml==0.10.0
toolz==0.10.0
tox==3.14.2
tqdm==4.40.2
twine==3.1.1
typed-ast==1.4.0
typing-extensions==3.7.4.1
u-msgpack-python==2.5.2
untokenize==0.1.1
urllib3==1.25.7
varint==1.0.2
virtualenv==16.7.9
wcwidth==0.1.7
webencodings==0.5.1

(Disclaimer: You may notice the deviant fastecdsa installation, this is because I am installing and testing an experimental integration with a windows-buildable fastecdsa wheel (alongside general windows integration), this problem is also mentioned in #363)
(You also may notice python 3.8, this is for the testing environment as well)

How can it be fixed?

Have it be mentioned in README.md (or any other appropriate file that readme points to) that for testing, a golang installation is needed, and have it specify which version of golang.

Looking further, I see that the library uses tox, while the readme mentions only pytest.

As evident from the errors above, pytest follows tests that're subject/setup by tox, while there is no mention of this.

Furthermore, I can also see there are more "managers" and environment settings files around that're all not mentioned nor documented anywhere in the readme, nor in any document that the readme explicitly defines for this.

This appears to be because pytest runs all tests that're structurized to tox, where this test appears to be a part of py37-interop

You're right we should add in the README.md that running tests_interop requires go and go-libp2p-daemon installed.

Closing as the test suite is based on tox, and golang interop testing is mostly for the CI suite.