Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions crates/apollo_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,3 @@ metrics.workspace = true
mockall.workspace = true
rstest.workspace = true
starknet_proof_verifier.workspace = true

[[bin]]
name = "integration_test_proof_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_proof_flow.rs"

[[bin]]
name = "integration_test_positive_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_positive_flow.rs"

[[bin]]
name = "integration_test_restart_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs"

[[bin]]
name = "integration_test_restart_service_multiple_nodes_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_service_multiple_nodes_flow.rs"

[[bin]]
name = "integration_test_restart_service_single_node_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_service_single_node_flow.rs"

[[bin]]
name = "integration_test_revert_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_revert_flow.rs"

[[bin]]
name = "integration_test_central_and_p2p_sync_flow"
path = "src/bin/sequencer_node_end_to_end_integration_tests/integration_test_central_and_p2p_sync_flow.rs"
38 changes: 38 additions & 0 deletions crates/apollo_integration_tests/src/bin/integration_test_runner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use apollo_integration_tests::flows;
use clap::{Parser, ValueEnum};

#[derive(Parser)]
#[command(name = "integration_test_runner", about = "Run one sequencer integration-test flow.")]
struct Args {
/// The integration-test flow to run.
flow: Flow,
}

#[derive(Clone, ValueEnum)]
#[value(rename_all = "snake_case")]
enum Flow {
Positive,
Proof,
Restart,
RestartMultipleNodes,
RestartSingleNode,
Revert,
Sync,
}

#[tokio::main]
async fn main() {
// The match is exhaustive by design: adding a `Flow` variant without wiring its module is a
// compile error, so the enum is the single source of truth for the set of flows. clap parses
// the flow name, rejects unknown names with the valid list, and exits non-zero on bad usage
// (distinct from a flow failing, which panics).
match Args::parse().flow {
Flow::Positive => flows::positive::run().await,
Flow::Proof => flows::proof::run().await,
Flow::Restart => flows::restart::run().await,
Flow::RestartMultipleNodes => flows::restart_multiple_nodes::run().await,
Flow::RestartSingleNode => flows::restart_single_node::run().await,
Flow::Revert => flows::revert::run().await,
Flow::Sync => flows::sync::run().await,
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

44 changes: 22 additions & 22 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@
# Sequencer node binary name.
SEQUENCER_BINARY_NAME: str = "apollo_node"

# List of sequencer node integration test binary names. Stored as a list to maintain order.
SEQUENCER_INTEGRATION_TEST_NAMES: List[str] = [
"integration_test_restart_flow",
"integration_test_positive_flow",
"integration_test_restart_service_multiple_nodes_flow",
"integration_test_revert_flow",
"integration_test_proof_flow",
# Binary that runs a sequencer integration-test flow given the flow name as its argument.
RUNNER_BINARY_NAME: str = "integration_test_runner"

# List of sequencer node integration test flow names. Stored as a list to maintain order.
SEQUENCER_INTEGRATION_TEST_FLOWS: List[str] = [
"restart",
"positive",
"restart_multiple_nodes",
"revert",
"proof",
]
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_NAMES: List[str] = [
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_FLOWS: List[str] = [
# TODO(AndrewL): Try adding these tests to CI as well
"integration_test_restart_service_single_node_flow",
"integration_test_central_and_p2p_sync_flow",
"restart_single_node",
"sync",
]
# Timeout per single integration test
INTEGRATION_TEST_TIMEOUT: str = "10m"
Expand Down Expand Up @@ -86,8 +89,8 @@ def cmds(self, crates: Set[str], is_nightly: bool) -> List[List[str]]:
print(f"Skipping sequencer integration tests.")
return []

integration_test_names_to_run = SEQUENCER_INTEGRATION_TEST_NAMES + (
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_NAMES if is_nightly else []
integration_test_flows_to_run = SEQUENCER_INTEGRATION_TEST_FLOWS + (
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_FLOWS if is_nightly else []
)

print(f"Composing sequencer integration test commands.")
Expand All @@ -97,25 +100,22 @@ def build_cmds(with_feature: bool) -> List[List[str]]:
# Commands to build the node and all the test binaries.
build_cmds = [
["cargo", "build", "--bin", binary_name] + feature_flag
for binary_name in [SEQUENCER_BINARY_NAME] + integration_test_names_to_run
for binary_name in [SEQUENCER_BINARY_NAME, RUNNER_BINARY_NAME]
]
return build_cmds

def make_silent_test_cmd(test_binary_name: str) -> List[str]:
"""Runs a test binary, only showing output on failure or timeout."""
def make_silent_test_cmd(flow_name: str) -> List[str]:
"""Runs one integration-test flow, only showing output on failure or timeout."""
return [
"sh",
"-c",
f"timeout {INTEGRATION_TEST_TIMEOUT} ./target/debug/{test_binary_name} "
f"> /tmp/{test_binary_name}_output.txt 2>&1 || "
f"(cat /tmp/{test_binary_name}_output.txt; exit 1)",
f"timeout {INTEGRATION_TEST_TIMEOUT} ./target/debug/{RUNNER_BINARY_NAME} {flow_name} "
f"> /tmp/integration_test_{flow_name}_output.txt 2>&1 || "
f"(cat /tmp/integration_test_{flow_name}_output.txt; exit 1)",
]

# Commands to run the test binaries.
run_cmds = [
make_silent_test_cmd(test_binary_name)
for test_binary_name in integration_test_names_to_run
]
run_cmds = [make_silent_test_cmd(flow_name) for flow_name in integration_test_flows_to_run]

cmds_no_feat = build_cmds(with_feature=False) + run_cmds

Expand Down
86 changes: 31 additions & 55 deletions scripts/sequencer_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,48 @@
# scripts/sequencer_integration_test.sh
#
# Usage:
# ./scripts/sequencer_integration_test.sh [test]
# ./scripts/sequencer_integration_test.sh [flow]
#
# If no argument is provided, the default test "positive" is run.
# You can also pass:
# - "positive" to run the positive flow test,
# - "restart" to run the restart flow test,
# - "restart_multiple_nodes" to run the restart flow test with multiple nodes,
# - "restart_single_node" to run the restart flow test with a single node,
# - "revert" to run the revert flow test,
# - "sync" to run the central and p2p sync flow test,
# - "all" to run all tests.
#
# Note: Make sure the binaries exist in
# crates/apollo_integration_tests/src/bin/sequencer_node_integration_tests/
# with names such as positive_flow.rs, revert_flow.rs, restart_flow.rs, sync_flow.rs

# TODO(noamsp): find a way to get this mapping automatically instead of hardcoding
declare -A TEST_ALIASES=(
[positive]="integration_test_positive_flow"
[restart]="integration_test_restart_flow"
[restart_multiple_nodes]="integration_test_restart_service_multiple_nodes_flow"
[restart_single_node]="integration_test_restart_service_single_node_flow"
[revert]="integration_test_revert_flow"
[sync]="integration_test_central_and_p2p_sync_flow"
[proof]="integration_test_proof_flow"
)

# Set default test if none provided
TEST="${1:-positive}"
# Runs one end-to-end sequencer integration-test flow via the integration_test_runner binary,
# or all flows in sequence with "all". Defaults to "positive". An unknown flow name lists the
# valid flows (including "all") and exits without building.

echo "Running integration test alias: $TEST"
# Keep in sync with the Flow enum in
# crates/apollo_integration_tests/src/bin/integration_test_runner.rs.
FLOWS=(positive proof restart restart_multiple_nodes restart_single_node revert sync)

SEQUENCER_BINARY="apollo_node"
RUNNER_BINARY="integration_test_runner"

# Build the main node binary (if required)
cargo build --bin "$SEQUENCER_BINARY"
FLOW="${1:-positive}"

# Reject an unknown flow before the (minutes-long) node build, so bad input fails fast.
if [ "$FLOW" != "all" ] && [[ ! " ${FLOWS[*]} " == *" $FLOW "* ]]; then
echo "Unknown flow: '$FLOW'"
echo "Valid flows: all ${FLOWS[*]}"
exit 1
fi

# Helper function to build a test binary
build_test() {
local tname="$1"
echo "==> Building test: $tname"
cargo build --bin "$tname" || { echo "Build for $tname failed"; exit 1; }
build_binary() {
local binary_name="$1"
echo "==> Building: $binary_name"
cargo build --bin "$binary_name" || { echo "Build for $binary_name failed"; exit 1; }
}

# Helper function to run a test binary
run_test() {
local tname="$1"
echo "==> Running test: $tname"
"./target/debug/$tname" || { echo "Test $tname failed"; exit 1; }
run_flow() {
local flow_name="$1"
echo "==> Running flow: $flow_name"
"./target/debug/$RUNNER_BINARY" "$flow_name" || { echo "Flow $flow_name failed"; exit 1; }
}

if [ "$TEST" = "all" ]; then
for alias in "${!TEST_ALIASES[@]}"; do
build_test "${TEST_ALIASES[$alias]}"
done
for alias in "${!TEST_ALIASES[@]}"; do
run_test "${TEST_ALIASES[$alias]}"
build_binary "$SEQUENCER_BINARY"
build_binary "$RUNNER_BINARY"

if [ "$FLOW" = "all" ]; then
for flow_name in "${FLOWS[@]}"; do
run_flow "$flow_name"
done
exit 0
fi

if [ -z "${TEST_ALIASES[$TEST]}" ]; then
echo "Invalid alias: '$TEST'"
echo "Valid aliases are: all,$(IFS=,; echo "${!TEST_ALIASES[*]}")"
exit 1
fi

build_test "${TEST_ALIASES[$TEST]}"
run_test "${TEST_ALIASES[$TEST]}"
run_flow "$FLOW"
Loading