-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testing] Add a job to test state sync bootstrap of testnet
- Loading branch information
Showing
8 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ self-hosted-runner: | |
- custom-arm64-focal | ||
- custom-arm64-jammy | ||
- net-outage-sim | ||
- avalanche-avalanchego |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: 'Check bootstrap for a network and state sync configuration' | ||
description: 'Checks that bootstrap is possible for the given network and state sync configuration' | ||
|
||
inputs: | ||
network_id: | ||
required: true | ||
state_sync_enabled: | ||
required: true | ||
prometheus_id: | ||
required: true | ||
prometheus_password: | ||
required: true | ||
loki_id: | ||
required: true | ||
loki_password: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Go | ||
uses: ./.github/actions/setup-go-for-project | ||
|
||
- name: Build AvalancheGo Binary | ||
shell: bash | ||
run: ./scripts/build.sh -r | ||
|
||
- name: Check avalanchego version | ||
shell: bash | ||
run: ./build/avalanchego --version | ||
|
||
- name: Run bootstrap for testnet with state-sync | ||
uses: ./.github/actions/run-monitored-tmpnet-cmd | ||
with: | ||
run: go run ./tests/bootstrap --avalanchego-path=./build/avalanchego --network-id=${{ inputs.network_id }} --state-sync-enabled=${{ inputs.state_sync_enabled }} | ||
prometheus_id: ${{ inputs.prometheus_id }} | ||
prometheus_password: ${{ inputs.prometheus_password }} | ||
loki_id: ${{ inputs.loki_id }} | ||
loki_password: ${{ inputs.loki_password }} | ||
|
||
# Skip creation of an artifact in favor of log collection to loki | ||
|
||
- name: Check size of tmpnet path | ||
if: always() | ||
shell: bash | ||
run: | | ||
echo "Checking tmpnet disk usage:" | ||
du -sh ~/.tmpnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: 'Check Bootstrap (testnet,state-sync)' | ||
|
||
on: | ||
# TODO(marun) Add a schedule | ||
workflow_dispatch: | ||
|
||
# TODO(marun) For testing only - remove before merge | ||
pull_request: | ||
|
||
jobs: | ||
check_bootstrap_testnet_state_sync: | ||
name: Check Bootstrap (testnet,state-sync) | ||
runs-on: avalanche-avalanchego | ||
timeout-minutes: 4320 # 3 days | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Check bootstrap (testnet,state-sync) | ||
uses: ./.github/actions/check-bootstrap | ||
with: | ||
network_id: 5 # testnet | ||
state_sync_enabled: true | ||
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }} | ||
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} | ||
loki_id: ${{ secrets.LOKI_ID || '' }} | ||
loki_password: ${{ secrets.LOKI_PASSWORD || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
|
||
"github.com/ava-labs/avalanchego/config" | ||
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet" | ||
"github.com/ava-labs/avalanchego/utils/logging" | ||
) | ||
|
||
// Simple test that starts a single node and waits for it to finish bootstrapping. | ||
|
||
func main() { | ||
avalanchegoPath := flag.String("avalanchego-path", "", "The path to an avalanchego binary") | ||
networkID := flag.Int64("network-id", 0, "The ID of the network to bootstrap from") | ||
stateSyncEnabled := flag.Bool("state-sync-enabled", false, "Whether state syncing should be enabled") | ||
maxDuration := flag.Duration("max-duration", time.Hour*72, "The maximum duration the network should run for") | ||
|
||
flag.Parse() | ||
|
||
if len(*avalanchegoPath) == 0 { | ||
log.Fatal("avalanchego-path is required") | ||
} | ||
if *networkID == 0 { | ||
log.Fatal("network-id is required") | ||
} | ||
if *maxDuration == 0 { | ||
log.Fatal("max-duration is required") | ||
} | ||
|
||
if err := checkBootstrap(*avalanchegoPath, uint32(*networkID), *stateSyncEnabled, *maxDuration); err != nil { | ||
log.Fatalf("Failed to check bootstrap: %v\n", err) | ||
} | ||
} | ||
|
||
func checkBootstrap(avalanchegoPath string, networkID uint32, stateSyncEnabled bool, maxDuration time.Duration) error { | ||
flags := tmpnet.DefaultLocalhostFlags() | ||
flags.SetDefaults(tmpnet.FlagsMap{ | ||
config.HealthCheckFreqKey: "30s", | ||
// Minimize logging overhead | ||
config.LogDisplayLevelKey: logging.Off.String(), | ||
config.LogLevelKey: logging.Info.String(), | ||
}) | ||
|
||
// Create a new single-node network that will bootstrap from the specified network | ||
network := &tmpnet.Network{ | ||
UUID: uuid.NewString(), | ||
NetworkID: networkID, | ||
Owner: "bootstrap-test", | ||
Nodes: tmpnet.NewNodesOrPanic(1), | ||
DefaultFlags: flags, | ||
DefaultRuntimeConfig: tmpnet.NodeRuntimeConfig{ | ||
// TODO(marun) Rename AvalancheGoPath to AvalanchegoPath | ||
AvalancheGoPath: avalanchegoPath, | ||
}, | ||
ChainConfigs: map[string]tmpnet.FlagsMap{ | ||
"C": { | ||
"state-sync-enabled": stateSyncEnabled, | ||
}, | ||
}, | ||
} | ||
|
||
if err := network.Create(""); err != nil { | ||
return fmt.Errorf("failed to create network: %w", err) | ||
} | ||
node := network.Nodes[0] | ||
|
||
log.Printf("Starting node in path %s (UUID: %s)\n", network.Dir, network.UUID) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), tmpnet.DefaultNetworkTimeout) | ||
defer cancel() | ||
if err := network.StartNode(ctx, os.Stdout, node); err != nil { | ||
return fmt.Errorf("failed to start node: %w", err) | ||
} | ||
defer func() { | ||
ctx, cancel := context.WithTimeout(context.Background(), tmpnet.DefaultNetworkTimeout) | ||
defer cancel() | ||
if err := node.Stop(ctx); err != nil { | ||
log.Printf("Failed to stop node: %v\n", err) | ||
} | ||
}() | ||
|
||
log.Printf("Metrics: %s\n", tmpnet.DefaultMetricsLink(network.UUID, time.Now())) | ||
|
||
log.Print("Waiting for node to indicate bootstrap complete by reporting healthy\n") | ||
|
||
// Avoid checking too often to avoid log spam | ||
healthCheckInterval := 1 * time.Minute | ||
|
||
ctx, cancel = context.WithTimeout(context.Background(), maxDuration) | ||
defer cancel() | ||
if err := tmpnet.WaitForHealthyWithInterval(ctx, node, healthCheckInterval); err != nil { | ||
return fmt.Errorf("node failed to become healthy before timeout: %w", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters