Skip to content

Commit a8c793d

Browse files
committed
* Update docs on how to run tests
* Use Docker to support running functional tests from IDE
1 parent e02a95f commit a8c793d

File tree

5 files changed

+80
-7
lines changed

5 files changed

+80
-7
lines changed

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ You can submit bug reports using the
208208

209209
### Setting up a local development environment
210210

211-
1. Follow the instructions in the IPFS documentation to install go-IPFS into your `${PATH}`:
212-
https://docs.ipfs.io/install/command-line/
213-
2. Follow the instructions in the (Python) tox documentation to install the `tox` Python environment runner:
214-
https://tox.readthedocs.io/en/latest/install.html
211+
1. [Install tox](https://tox.readthedocs.io/en/latest/install.html)
212+
2. [Install a local IPFS server](tools/ipfs/README.md):
215213
3. Clone the GIT repository if you haven't already:
216214
`git clone https://github.com/ipfs-shipyard/py-ipfs-http-client.git`
217215

@@ -235,15 +233,16 @@ make sure that your code passes both the
235233

236234
$ tox -e styleck -e typeck
237235

238-
As well as the unit tests:
236+
As well as the tests:
239237

240238
$ tox -e py3 -e py3-httpx
241239

242240
If you are unsure, don't hesitate to just submit your code, and a human will
243241
take a look. 🙂
244242

245-
If you can, Please make sure to include new unit tests for new features or
246-
changes in behavior. We aim to bring coverage to 100% at some point.
243+
Please make sure to include new unit tests for new features or
244+
changes in behavior.
245+
247246

248247
#### Installing the pre-commit Hook
249248

tools/ipfs/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ipfs/go-ipfs:v0.8.0
2+
3+
RUN sed -i 's/exec ipfs "$@"//' /usr/local/bin/start_ipfs
4+
ADD entrypoint.sh /
5+
6+
ENTRYPOINT ["/entrypoint.sh"]
7+
CMD ["ipfs", "daemon", "--migrate=true", "--enable-namesys-pubsub"]

tools/ipfs/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Running Tests
3+
4+
Tests are primarily run from the command line using a locally installed IPFS server.
5+
6+
Alternatively, you can launch the IPFS daemon with Docker and run tests from your IDE.
7+
8+
9+
## Local IPFS Server Installation
10+
11+
To install it, follow the [official instructions](https://docs.ipfs.io/install/command-line/).
12+
13+
Remaining configuration is applied by [run_tests.py](../../test/run-tests.py) on each run.
14+
15+
16+
## Running Tests Using Local Installation From Command Line
17+
18+
* `tox -e py3`
19+
* `tox -e py3-httpx`
20+
21+
22+
## Running Tests Using Docker from IDE (e.g. PyCharm)
23+
24+
1. Start [daemon.sh](daemon.sh)
25+
2. Run `pytest` tests from your IDE as your normally would
26+
27+
You can keep the Docker container running across multiple
28+
executions of the functional test suite.
29+
30+
31+
## Running Tests Without Live Server
32+
33+
You can run unit tests without a live server; `pytest` will skip
34+
over the functional tests when our fixtures detect the server
35+
isn't running.
36+
37+
38+
## pytest-docker Plugin
39+
40+
While `pytest-docker` supports running functional tests against a
41+
Docker container using Docker Compose, it is not supported on
42+
Windows or Mac with Travis and IPFS.
43+

tools/ipfs/daemon.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
tag=py-ipfs-http-client-daemon:latest
6+
7+
docker build -t $tag .
8+
docker run --rm -p 4001:4001 -p 5001:5001 -p 8080:8080 $tag
9+

tools/ipfs/entrypoint.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Only does configuration; doesn't start the daemon
6+
/usr/local/bin/start_ipfs
7+
8+
echo "Enabling experimental features"
9+
10+
ipfs config --json Experimental.FilestoreEnabled true
11+
12+
echo "Enabled experimental features"
13+
14+
# Start the daemon (unless other args provided)
15+
exec "$@"

0 commit comments

Comments
 (0)