Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 50efa71

Browse files
committed
Testing container
1 parent 5748cc4 commit 50efa71

8 files changed

Lines changed: 136 additions & 1 deletion

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
target
33
Cargo.lock
44
devenv/*
5+
!devenv/tests/docker/entrypoint
56
coverage
67
romeo/testing/
78
romeo/asset-contract/.test
89
romeo/asset-contract/.coverage
9-

devenv/tests/bin/build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker compose -f docker-compose.yml build

devenv/tests/bin/down

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
if [ -z "$2" ]; then
4+
echo "Use: down <full-node-compose.yml> <project_name>"
5+
exit 1
6+
fi
7+
8+
docker compose -f $1 -p $2 down

devenv/tests/bin/test

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -ueo >/dev/null
3+
4+
project_name() {
5+
local input="$1"
6+
local filter="${input//[![:alnum:]]/_}"
7+
echo "$filter"
8+
}
9+
10+
filters=("package(romeo)" "test(deposit_parse)" "test(deposit_output)")
11+
filter_union=""
12+
ids=()
13+
projects=()
14+
15+
for filter in "${filters[@]}"; do
16+
project=$(project_name $filter)
17+
echo Working project: $project
18+
projects+=($project)
19+
20+
./tests/bin/down docker-compose.yml $project
21+
./tests/bin/up docker-compose.yml $project
22+
23+
network=${project}_default
24+
id=$(docker run -td --network $network -e PROJECT_NAME=$project testbed "$filter")
25+
ids+=($id)
26+
echo with container id: $id
27+
28+
if [ -z "$filter_union" ]; then
29+
filter_union=$filter
30+
else
31+
filter_union="$filter_union | $filter"
32+
fi
33+
34+
done
35+
36+
project="remainder--"
37+
echo Working project: $project
38+
projects+=($project)
39+
40+
./tests/bin/down docker-compose.yml $project
41+
./tests/bin/up docker-compose.yml $project
42+
43+
network=${project}_default
44+
id=($(docker run -td --network $network -e PROJECT_NAME=$project testbed "not ($filter_union)"))
45+
ids+=($id)
46+
echo with container id: $id
47+
48+
for id in ${ids[@]}; do
49+
exit_code=$(docker wait $id)
50+
echo Runner: $id exited with err_no: $exit_code
51+
if [ $exit_code -ne 0 ]; then
52+
docker logs -f $id
53+
exit $exit_code
54+
fi
55+
done
56+
57+
for project in ${projects[@]}; do
58+
./tests/bin/down docker-compose.yml $project
59+
done

devenv/tests/bin/up

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
if [ -z "$2" ]; then
4+
echo "Use: up <full-node-compose.yml> <project_name>"
5+
exit 1
6+
fi
7+
8+
docker compose -f $1 -p $2 up -d --remove-orphans

devenv/tests/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.2'
2+
3+
networks:
4+
devenv_default:
5+
external: true
6+
7+
services:
8+
testbed:
9+
image: testbed:latest
10+
build:
11+
dockerfile: devenv/tests/docker/Dockerfile
12+
context: ./../../
13+
networks:
14+
- devenv_default

devenv/tests/docker/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM rust:alpine
2+
3+
RUN apk add --no-cache g++ musl-dev git openssl-dev clang-dev libsecp256k1-dev
4+
5+
RUN rustup component add rustfmt
6+
7+
ENV RUSTFLAGS "-C target-feature=-crt-static"
8+
9+
RUN cargo install cargo-nextest --locked
10+
11+
COPY . .
12+
13+
RUN cargo nextest list
14+
15+
RUN apk --no-cache add curl jq
16+
17+
COPY ./devenv/tests/docker/entrypoint /bin/entrypoint
18+
19+
ENTRYPOINT [ "entrypoint" ]

devenv/tests/docker/entrypoint

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env sh
2+
set -ueo >/dev/null
3+
4+
STACKS=$PROJECT_NAME-stacks-1
5+
API_URL=http://$STACKS:20443/v2/info
6+
7+
# makes sure the node is ready before proceeding
8+
# stacks node get info
9+
echo "Waiting on Stacks API"
10+
while ! curl -s $API_URL >/dev/null; do
11+
sleep 1
12+
done
13+
14+
DEV_READY_HEIGHT=205
15+
16+
# bitcoind get info
17+
echo "Waiting on burn block height $DEV_READY_HEIGHT"
18+
while [ "$(curl -s $API_URL | jq '.burn_block_height')" -lt $DEV_READY_HEIGHT ]; do
19+
sleep 2
20+
done
21+
# any other service checks
22+
23+
echo with filter: "'$@'"
24+
cargo nextest run -E "$@"

0 commit comments

Comments
 (0)