Skip to content

Commit

Permalink
* Update docs on how to run tests
Browse files Browse the repository at this point in the history
* Use Docker to support running functional tests from IDE
  • Loading branch information
c0llab0rat0r committed Jun 29, 2021
1 parent f04ff60 commit 4803539
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 7 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ You can submit bug reports using the

### Setting up a local development environment

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

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

$ tox -e styleck -e typeck

As well as the unit tests:
As well as the tests:

$ tox -e py3 -e py3-httpx

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

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


#### Installing the pre-commit Hook

Expand Down
7 changes: 7 additions & 0 deletions tools/ipfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ipfs/go-ipfs:v0.8.0

RUN sed -i 's/exec ipfs "$@"//' /usr/local/bin/start_ipfs
ADD entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
CMD ["ipfs", "daemon", "--migrate=true", "--enable-namesys-pubsub"]
43 changes: 43 additions & 0 deletions tools/ipfs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

# Running Tests

Tests are primarily run from the command line using a locally installed IPFS server.

Alternatively, you can launch the IPFS daemon with Docker and run tests from your IDE.


## Local IPFS Server Installation

To install it, follow the [official instructions](https://docs.ipfs.io/install/command-line/).

Remaining configuration is applied by [run_tests.py](../../test/run-tests.py) on each run.


## Running Tests Using Local Installation From Command Line

* `tox -e py3`
* `tox -e py3-httpx`


## Running Tests Using Docker from IDE (e.g. PyCharm)

1. Start [daemon.sh](daemon.sh)
2. Run `pytest` tests from your IDE as your normally would

You can keep the Docker container running across multiple
executions of the functional test suite.


## Running Tests Without Live Server

You can run unit tests without a live server; `pytest` will skip
over the functional tests when our fixtures detect the server
isn't running.


## pytest-docker Plugin

While `pytest-docker` supports running functional tests against a
Docker container using Docker Compose, it is not supported on
Windows or Mac with Travis and IPFS.

9 changes: 9 additions & 0 deletions tools/ipfs/daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

tag=py-ipfs-http-client-daemon:latest

docker build -t $tag .
docker run --rm -p 4001:4001 -p 5001:5001 -p 8080:8080 $tag

15 changes: 15 additions & 0 deletions tools/ipfs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

# Only does configuration; doesn't start the daemon
/usr/local/bin/start_ipfs

echo "Enabling experimental features"

ipfs config --json Experimental.FilestoreEnabled true

echo "Enabled experimental features"

# Start the daemon (unless other args provided)
exec "$@"

0 comments on commit 4803539

Please sign in to comment.