diff --git a/.github/check-service.sh b/.github/check-service.sh index e6a05bc1..39e0d83c 100755 --- a/.github/check-service.sh +++ b/.github/check-service.sh @@ -1,20 +1,21 @@ #!/usr/bin/env bash -APP_NAME=$1 -TIMEOUT=${2:-60} # Default timeout is 60 seconds if not provided -INTERVAL=5 +__service=$1 -while [ "${TIMEOUT}" -gt 0 ]; do - STATUS=$(docker-compose ps --services --filter "status=running" | grep "${APP_NAME}") +__containerID=$(docker-compose ps -q "${__service}") - if [ -n "$STATUS" ]; then - echo "$APP_NAME is running." - exit 0 - fi +__initial_restart_count=$(docker inspect --format '{{ .RestartCount }}' "$__containerID") +__is_running=$(docker inspect --format '{{ .State.Running }}' "$__containerID") +sleep 10 +__final_restart_count=$(docker inspect --format '{{ .RestartCount }}' "$__containerID") - sleep "${INTERVAL}" - TIMEOUT=$((TIMEOUT - INTERVAL)) -done - -echo "Timed out waiting for $APP_NAME to start." -exit 1 +if [ "$__is_running" != "true" ] || [ "$__final_restart_count" -gt "$__initial_restart_count" ]; then + echo "$__service is either not running or continuously restarting" + docker-compose ps "${__service}" + docker-compose logs "${__service}" + exit 1 +else + echo "$__service is running" + docker-compose ps "${__service}" + exit 0 +fi diff --git a/.github/test-ethd-config.exp b/.github/test-ethd-config.exp new file mode 100755 index 00000000..2c31808b --- /dev/null +++ b/.github/test-ethd-config.exp @@ -0,0 +1,155 @@ +#!/usr/bin/env expect + +proc accept_default {} { + global spawn_id + send "\t\r" +} + +proc yes {} { + global spawn_id + send "\r" +} + +proc no {} { + global spawn_id + send "\t\r" +} + +proc default-deployment {} { + global spawn_id + expect "Select Network" + accept_default + + expect "Select deployment" + accept_default + + expect "Select consensus" + accept_default + + expect "Select execution" + accept_default +} + +proc all-defaults {} { + global spawn_id + default-deployment + + expect "Checkpoint Sync" + yes + + expect "Configure checkpoint" + accept_default + + expect "MEV Boost" + yes + + expect "Configure MEV" + accept_default + + expect "Grafana" + yes + + expect "Configure rewards" + accept_default + + expect "Configure Graffiti" + accept_default + + expect EOF +} + +proc no-checkpoint {} { + global spawn_id + default-deployment + + expect "Checkpoint Sync" + no + + expect "MEV Boost" + yes + + expect "Configure MEV" + accept_default + + expect "Grafana" + yes + + expect "Configure rewards" + accept_default + + expect "Configure Graffiti" + accept_default + + expect EOF +} + +proc no-mev {} { + global spawn_id + default-deployment + + expect "Checkpoint Sync" + yes + + expect "Configure checkpoint" + accept_default + + expect "MEV Boost" + no + + expect "Grafana" + yes + + expect "Configure rewards" + accept_default + + expect "Configure Graffiti" + accept_default + + expect EOF +} + +proc no-grafana {} { + global spawn_id + default-deployment + + expect "Checkpoint Sync" + yes + + expect "Configure checkpoint" + accept_default + + expect "MEV Boost" + yes + + expect "Configure MEV" + accept_default + + expect "Grafana" + no + + expect "Configure rewards" + accept_default + + expect "Configure Graffiti" + accept_default + + expect EOF +} + +set timeout 5 +spawn ./ethd config + +# Check for the command-line argument +if {$argc > 0} { + set action [lindex $argv 0] + switch -- $action { + "all-defaults" all-defaults + "no-checkpoint" no-checkpoint + "no-mev" no-mev + "no-grafana" no-grafana + default { puts "Unknown action: $action"; exit 1 } + } +} else { + puts "No specific test specified, using all-defaults" + all-defaults +} diff --git a/.github/workflows/test-ethd.yml b/.github/workflows/test-ethd.yml new file mode 100644 index 00000000..5ae578f8 --- /dev/null +++ b/.github/workflows/test-ethd.yml @@ -0,0 +1,36 @@ +name: Test ethd +run-name: Test ethd + +on: + push: + pull_request: + types: [opened, synchronize, labeled, unlabeled] + branches: [main] + +jobs: + test-ethd: + if: | + contains(github.event.pull_request.labels.*.name, 'test-ethd') || + contains(github.event.pull_request.labels.*.name, 'test-all') || + github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Expect + run: sudo apt-get install -y expect whiptail + - name: Test ethd config defaults + run: expect ./.github/test-ethd-config.exp all-defaults + env: + TERM: xterm + - name: Test ethd config no checkpoint + run: expect ./.github/test-ethd-config.exp no-checkpoint + env: + TERM: xterm + - name: Test ethd config no mev + run: expect ./.github/test-ethd-config.exp no-mev + env: + TERM: xterm + - name: Test ethd config no grafana + run: expect ./.github/test-ethd-config.exp no-grafana + env: + TERM: xterm diff --git a/.github/workflows/test-grafana.yml b/.github/workflows/test-grafana.yml index 8550f6b2..71bd2d58 100644 --- a/.github/workflows/test-grafana.yml +++ b/.github/workflows/test-grafana.yml @@ -17,8 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Lighthouse/Geth/Grafana run: | source ./.github/helper.sh @@ -26,35 +25,26 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Lighthouse/Geth/Grafana - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Prometheus - run: | - ./.github/check-service.sh prometheus + run: ./.github/check-service.sh prometheus - name: Test metrics exporter - run: | - ./.github/check-service.sh ethereum-metrics-exporter + run: ./.github/check-service.sh ethereum-metrics-exporter - name: Test node exporter - run: | - ./.github/check-service.sh node-exporter - - name: Test cryptowat exporter - run: | - ./.github/check-service.sh cryptowat-exporter + run: ./.github/check-service.sh node-exporter - name: Test blackbox exporter - run: | - ./.github/check-service.sh blackbox-exporter + run: ./.github/check-service.sh blackbox-exporter - name: Test json exporter - run: | - ./.github/check-service.sh json-exporter + run: ./.github/check-service.sh json-exporter + - name: Test cryptowat exporter + run: ./.github/check-service.sh cryptowat-exporter - name: Test cadvisor - run: | - ./.github/check-service.sh cadvisor + run: ./.github/check-service.sh cadvisor - name: Test promtail - run: | - ./.github/check-service.sh promtail + run: ./.github/check-service.sh promtail - name: Test Loki - run: | - ./.github/check-service.sh loki + run: ./.github/check-service.sh loki - name: Test Grafana - run: | - ./.github/check-service.sh grafana + run: ./.github/check-service.sh grafana diff --git a/.github/workflows/test-lighthouse-reth.yml b/.github/workflows/test-lighthouse-reth.yml index 3163e66c..235808e8 100644 --- a/.github/workflows/test-lighthouse-reth.yml +++ b/.github/workflows/test-lighthouse-reth.yml @@ -18,8 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Lighthouse/Reth run: | source ./.github/helper.sh @@ -30,17 +29,15 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Lighthouse/Reth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Lighthouse CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Lighthouse VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Reth - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Lighthouse/Reth w/ VC run: | source ./.github/helper.sh @@ -48,14 +45,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Lighthouse/Reth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Lighthouse CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Lighthouse VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Reth - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution diff --git a/.github/workflows/test-lodestar-erigon.yml b/.github/workflows/test-lodestar-erigon.yml index 057dc152..14c1f621 100644 --- a/.github/workflows/test-lodestar-erigon.yml +++ b/.github/workflows/test-lodestar-erigon.yml @@ -18,8 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Lodestar/Erigon run: | source ./.github/helper.sh @@ -30,17 +29,15 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Lodestar/Erigon - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Lodestar CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Lodestar VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Geth - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Lodestar/Erigon w/ VC run: | source ./.github/helper.sh @@ -48,14 +45,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Lodestar/Erigon - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Lodestar CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Lodestar VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Erigon - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution diff --git a/.github/workflows/test-nimbus-nethermind.yml b/.github/workflows/test-nimbus-nethermind.yml index 59331c76..f0b15939 100644 --- a/.github/workflows/test-nimbus-nethermind.yml +++ b/.github/workflows/test-nimbus-nethermind.yml @@ -18,8 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Nimbus/Nethermind run: | source ./.github/helper.sh @@ -30,14 +29,13 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Nimbus/Nethermind - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Nimbus - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Nethermind - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Nimbus/Nethermind w/ VC run: | source ./.github/helper.sh @@ -45,14 +43,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Nimbus/Nethermind - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Nimbus CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Nimbus VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Nethermind - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution diff --git a/.github/workflows/test-prysm-geth.yml b/.github/workflows/test-prysm-geth.yml index dbc89c7c..7fe85eb9 100644 --- a/.github/workflows/test-prysm-geth.yml +++ b/.github/workflows/test-prysm-geth.yml @@ -18,8 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Prysm/Geth run: | source ./.github/helper.sh @@ -30,17 +29,15 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Prysm/Geth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Prysm CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Prysm VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Geth - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Prysm/Geth w/ VC run: | source ./.github/helper.sh @@ -48,14 +45,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Prysm/Geth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Prysm CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Prysm VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Geth - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution diff --git a/.github/workflows/test-teku-besu.yml b/.github/workflows/test-teku-besu.yml index d0476019..22da6609 100644 --- a/.github/workflows/test-teku-besu.yml +++ b/.github/workflows/test-teku-besu.yml @@ -18,8 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create .env file - run: | - cp default.env .env + run: cp default.env .env - name: Set Teku/Besu run: | source ./.github/helper.sh @@ -30,14 +29,13 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Teku/Besu - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Teku - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Besu - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Teku/Besu w/ VC run: | source ./.github/helper.sh @@ -45,14 +43,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Teku/Besu - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Teku CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Teku VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Besu - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution