revault / revaultd

The "wallet" daemon for participants under the Revault architecture
BSD 3-Clause "New" or "Revised" License
49 stars 21 forks source link

Run blackbox tests within a container. #389

Open rndhouse opened 2 years ago

rndhouse commented 2 years ago

I'm having trouble running the blackbox tests. So I figured I'd run them in a container so that I can share my environment.

Contrary to README, minimum supported Rust version is probably not 1.43, see: https://github.com/revault/revaultd/issues/390 . Going with version 1.58 for now.

rndhouse commented 2 years ago

I'm getting "bitcoind now synced" errors when running server tests:

...
FAILED tests/test_spend.py::test_spends_conflicting - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_spend.py::test_spend_threshold - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_spend.py::test_large_spends - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_spend.py::test_not_announceable_spend - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_spend.py::test_revaulted_spend - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_spend.py::test_coordinator_broadcast - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_watchtowers.py::test_wt_share_revocation_txs - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
FAILED tests/test_watchtowers.py::test_wt_policy - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
ERROR tests/servers/miradord/tests/test_chain.py
ERROR tests/servers/miradord/tests/test_conn.py
ERROR tests/servers/miradord/tests/test_plugins.py
ERROR tests/test_misc.py::test_largewallets - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
ERROR tests/test_rpc.py::test_getinfo - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.
ERROR tests/test_rpc.py::test_listvaults - TimeoutError: Unable to find "[re.compile('bitcoind now synced')]" in logs.

Does bitcoind need to be fully synced before running the server tests?

darosior commented 2 years ago

Thank you for getting together a repro. Before i dive deeper into it, did you try running essentially what the CI does?

For instance here is a simple Dockerfile from the CI config that you can run with:

docker build . -t revaultd_tests_repro && docker run revaultd_tests_repro

And that will setup Postgre and run the tests.

FROM rust:latest

# Install the deps
RUN apt update && apt install -y postgresql python3 python3-venv

# Clone a fresh version of the master branch, for repro
RUN git clone https://github.com/revault/revaultd /srv/revaultd

# Compile the daemon and the servers
RUN cd /srv/revaultd && cargo build --release && \
    git submodule update --init && \
    cd tests/servers && \
    cd miradord && cargo build && \
    cd ../coordinatord && cargo build && \
    cd ../cosignerd && cargo build
ENV REVAULTD_PATH=/srv/revaultd/target/release/revaultd
ENV MIRADORD_PATH=/srv/revaultd/tests/servers/miradord/target/debug/miradord
ENV COORDINATORD_PATH=/srv/revaultd/tests/servers/coordinatord/target/debug/coordinatord
ENV COSIGNERD_PATH=/srv/revaultd/tests/servers/cosignerd/target/debug/cosignerd

# Download the bitcoind binary
ENV BITCOIND_VERSION=22.0
ENV BITCOIND_DIR_NAME="bitcoin-$BITCOIND_VERSION"
ENV ARCHIVE_NAME="$BITCOIND_DIR_NAME.tar.gz"
RUN curl https://bitcoincore.org/bin/bitcoin-core-$BITCOIND_VERSION/bitcoin-$BITCOIND_VERSION-x86_64-linux-gnu.tar.gz -o $ARCHIVE_NAME && \
    tar -xzf $ARCHIVE_NAME && \
    mv $BITCOIND_DIR_NAME /srv
ENV BITCOIND_PATH=/srv/$BITCOIND_DIR_NAME/bin/bitcoind

# Setup the postgres instance for the servers, then run the functional tests.
CMD pg_ctlcluster 13 main start && \
    su -c "psql -c \"CREATE ROLE test CREATEDB LOGIN PASSWORD 'test'\"" - postgres && \
    cd /srv/revaultd && \
    python3 -m venv venv && \
    . venv/bin/activate && \
    pip install -r tests/requirements.txt && \
    POSTGRES_USER=test POSTGRES_PASS=test pytest -vvv -n 8

I'm getting "bitcoind now synced" errors when running server tests:

What version of bitcoind are you running? We need at least 22.0. You should be able to check the failure in the log file under /tmp/revaultd-tests<random name>/<test name>/revaultd-stk0/log (or something close to this).

Does bitcoind need to be fully synced before running the server tests?

We use bitcoind in regtest mode (no chain but the genesis block), no network (whether it'd be mainnet or testnet) need to be synced.

rndhouse commented 2 years ago

For instance here is a simple Dockerfile from the CI config that you can run with

I hadn't seen that Dockerfile before now. Where is it hosted? I thought this was the CI config.

What version of bitcoind are you running? We need at least 22.0.

The Containerfile I wrote uses 22.0, see here.

You should be able to check the failure in the log file

I'll take a look.

darosior commented 2 years ago

I hadn't seen that Dockerfile before now. Where is it hosted? I thought this was the CI config.

No. I wrote and tested it just now so you can run a working config in no time.