Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run blackbox tests within a container. #389

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rndhouse
Copy link
Contributor

@rndhouse rndhouse commented Apr 20, 2022

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: #390 . Going with version 1.58 for now.

@rndhouse
Copy link
Contributor Author

rndhouse commented Apr 21, 2022

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?

@rndhouse rndhouse changed the title WIP: Run integration/blackbox tests within a container. Run blackbox tests within a container. Apr 21, 2022
@darosior
Copy link
Member

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
Copy link
Contributor Author

rndhouse commented Apr 21, 2022

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
Copy link
Member

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.

darosior added a commit that referenced this pull request May 9, 2022
3766f99 Skip tests if postgres has not been setup. (rndhouse)

Pull request description:

  This is a cherry-pick of the first commit of #389.

  This bug was also reported by @Zshan0 on IRC. Thanks @rndhouse for the fix!

ACKs for top commit:
  darosior:
    ACK 3766f99

Tree-SHA512: a8372e37234b0556316c134593e12b041c1076f39e9ebbb74a58f5eea702368c48565d2a91bb39349d6c45d918598acde8b01dfd3cec9c35b62b391337b833dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants