Skip to content

Commit 7da44d1

Browse files
committed
task(ci): more informative bootstrap test
fixes: #468
1 parent 6c681a4 commit 7da44d1

File tree

15 files changed

+365
-101
lines changed

15 files changed

+365
-101
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ jobs:
124124
run: |
125125
mkdir -p target/release/tests
126126
127-
cargo build --release --features=scenario-generators --package=openmina-node-testing --tests
128-
cargo build --release --features=scenario-generators --package=openmina-node-testing --tests --message-format=json > cargo-build-test.json
127+
cargo build --release --tests --package=openmina-node-testing --package=cli
128+
cargo build --release --tests --package=openmina-node-testing --package=cli --message-format=json > cargo-build-test.json
129129
jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
130130
while read NAME FILE; do cp -a $FILE target/release/tests/$NAME; done < tests.tsv
131131
@@ -261,63 +261,52 @@ jobs:
261261
262262
263263
bootstrap-test:
264-
needs: [ k8s-peers, build ]
264+
needs: [ k8s-peers, build, build-tests ]
265265
runs-on: ubuntu-20.04
266266
env:
267-
PEERS: ${{ needs.k8s-peers.outputs.peers }}
267+
PEERS_LIST: ${{ needs.k8s-peers.outputs.peers }}
268+
PEER_LIST_FILE: peer-list.txt
268269
steps:
269270
- name: Download binary
270271
uses: actions/download-artifact@v4
271272
with:
272273
name: bin
273274

274-
- name: Bootstrap node
275+
- name: Download test
276+
uses: actions/download-artifact@v4
277+
with:
278+
pattern: tests*
279+
merge-multiple: true
280+
281+
- name: Fix permissions
275282
run: |
276-
set -eu
277-
chmod +x ./openmina
278-
./openmina node --no-peers-discovery --peers $PEERS 2>&1 | tee run.log &
279-
PID=$!
280-
TIME=10
281-
SLEEP=10
282-
ATTEMPTS=$((TIME * 60 / SLEEP))
283-
284-
healthy() {
285-
curl -fs -m 5 localhost:3000/healthz
286-
}
283+
chmod +x bootstrap openmina
287284
288-
ready() {
289-
curl -fs -m 5 localhost:3000/readyz
290-
}
285+
- name: Peer List File
286+
run: |
287+
for PEER in $PEERS_LIST; do echo $PEER; done > $PEER_LIST_FILE
288+
cat $PEER_LIST_FILE
291289
292-
ready3() {
293-
ready && sleep 10 && ready && sleep 10 && ready
290+
- name: Bootstrap node
291+
env:
292+
OPENMINA_COMMAND: ./openmina
293+
NO_PEER_DISCOVERY: "true"
294+
WORK_DIR: data
295+
OUT_PATH: data/bootstrap_output
296+
RECORD: state-with-input-actions
297+
run: |
298+
mkdir $WORK_DIR
299+
OPENMINA_COMMAND=./openmina NO_PEER_DISCOVERY=true ./bootstrap --nocapture || {
300+
{
301+
echo "::group::Stderr"
302+
cat bootstrap_output.stderr
303+
echo "::endgroup::"
304+
} >>$GITHUB_OUTPUT
294305
}
295306
296-
while ! healthy; do
297-
echo "::notice::The node is not healthy yet"
298-
ATTEMPTS=$((ATTEMPTS-1))
299-
if [ "${ATTEMPTS}" -eq 0 ]; then
300-
echo "::error::Cannot bootsrtap within $TIME minutes"
301-
exit 1
302-
fi
303-
sleep $SLEEP
304-
done
305-
echo "::notice::The node is healthy"
306-
307-
while ! ready3; do
308-
echo "::notice::The node is not bootstrapped yet"
309-
ATTEMPTS=$((ATTEMPTS-1))
310-
if [ "${ATTEMPTS}" -eq 0 ]; then
311-
echo "::error::Cannot bootsrtap within $TIME minutes"
312-
exit 1
313-
fi
314-
sleep $SLEEP
315-
done
316-
echo "::notice::The node is bootstrapped"
317-
318307
- name: Upload run.log
319308
uses: actions/upload-artifact@v4
320309
with:
321-
name: bootstrap-log
322-
path: run.log
310+
name: bootstrap-data
311+
path: work/*
323312
if: ${{ failure() }}

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ vrf = { workspace = true }
2525
console = "0.15.5"
2626
clap = { version = "4.3", features = [ "derive", "env" ] }
2727
time = { version = "0.3", features = ["formatting", "macros", "parsing"] }
28+
anyhow = "1.0.81"
29+
reqwest = "0.11.24"
2830

2931
openmina-core = { path = "../core" }
3032
node = { path = "../node", features = ["replay"] }
@@ -36,6 +38,9 @@ shellexpand = "3.1.0"
3638
dialoguer = "0.10.4"
3739
serde_json = "1.0.107"
3840

41+
[dev-dependencies]
42+
tempfile = "3.8.0"
43+
3944
[features]
4045
default = ["p2p-libp2p"]
4146
unsafe-signal-handlers = []

cli/src/commands/build_info/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use node::BuildEnv;
55
pub struct Command;
66

77
impl Command {
8-
pub fn run(&self) -> Result<(), crate::CommandError> {
8+
pub fn run(&self) -> anyhow::Result<()> {
99
let build_env = BuildEnv::get();
1010
println!(
1111
r#"

cli/src/commands/misc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ use libp2p_identity::PeerId;
22
use node::account::AccountSecretKey;
33
use node::p2p::identity::SecretKey;
44

5-
use crate::CommandError;
6-
75
#[derive(Debug, clap::Args)]
86
pub struct Misc {
97
#[command(subcommand)]
108
command: MiscCommand,
119
}
1210

1311
impl Misc {
14-
pub fn run(self) -> Result<(), CommandError> {
12+
pub fn run(self) -> anyhow::Result<()> {
1513
match self.command {
1614
MiscCommand::P2PKeyPair(command) => command.run(),
1715
MiscCommand::MinaKeyPair(command) => command.run(),
@@ -32,7 +30,7 @@ pub struct P2PKeyPair {
3230
}
3331

3432
impl P2PKeyPair {
35-
pub fn run(self) -> Result<(), CommandError> {
33+
pub fn run(self) -> anyhow::Result<()> {
3634
let secret_key = self.p2p_secret_key.unwrap_or_else(SecretKey::rand);
3735
let public_key = secret_key.public_key();
3836
let peer_id = public_key.peer_id();
@@ -53,7 +51,7 @@ pub struct MinaKeyPair {
5351
}
5452

5553
impl MinaKeyPair {
56-
pub fn run(self) -> Result<(), CommandError> {
54+
pub fn run(self) -> anyhow::Result<()> {
5755
let secret_key = self.secret_key.unwrap_or_else(AccountSecretKey::rand);
5856
let public_key = secret_key.public_key();
5957
println!("secret key: {secret_key}");

cli/src/commands/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ pub mod node;
44
pub mod replay;
55
pub mod snark;
66

7-
pub type CommandError = Box<dyn std::error::Error>;
8-
97
#[derive(Debug, clap::Parser)]
108
#[command(name = "openmina", about = "Openmina Cli")]
119
pub struct OpenminaCli {
@@ -26,7 +24,7 @@ pub enum Command {
2624
}
2725

2826
impl Command {
29-
pub fn run(self) -> Result<(), crate::CommandError> {
27+
pub fn run(self) -> anyhow::Result<()> {
3028
match self {
3129
Self::Snark(v) => v.run(),
3230
Self::Node(v) => v.run(),

0 commit comments

Comments
 (0)