forked from algorand/go-algorand
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added algod client health check to prevent node shutdown due to timeout in healthy node.
- Loading branch information
1 parent
5a074a2
commit b509cad
Showing
9 changed files
with
413 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Algoh Expect Utility Package | ||
namespace eval ::Algoh { | ||
|
||
# Export Procedures | ||
|
||
namespace export Abort | ||
namespace export Info | ||
namespace export CreateNetwork | ||
|
||
namespace export StopNode | ||
namespace export StartNode | ||
|
||
|
||
# My Variables | ||
set version 1.0 | ||
set description "Algodh Expect Package" | ||
|
||
# Variable for the path of the script | ||
variable home [file join [pwd] [file dirname [info script]]] | ||
} | ||
|
||
# Definition of the procedure MyProcedure | ||
proc ::Algoh::Info {} { | ||
puts Algoh::description | ||
} | ||
|
||
proc ::Algoh::Abort { ERROR } { | ||
puts "Aborting with error: $ERROR" | ||
exit 1 | ||
} | ||
|
||
package provide Algoh $Algoh::version | ||
package require Tcl 8.0 | ||
|
||
|
||
# Start the network | ||
proc ::Algoh::CreateNetwork { NETWORK_NAME NETWORK_TEMPLATE TEST_ROOT_DIR } { | ||
|
||
# Running on ARM64, it seems that network creation is pretty slow. | ||
# 30 second won't be enough here, so I'm changing this to 90 seconds. | ||
set timeout 90 | ||
|
||
if { [catch { | ||
# Create network | ||
puts "network create $NETWORK_NAME" | ||
spawn goal network create --network $NETWORK_NAME --template $NETWORK_TEMPLATE --rootdir $TEST_ROOT_DIR | ||
expect { | ||
timeout { close; ::Algoh::Abort "Timed out creating network" } | ||
"^Network $NETWORK_NAME created under.*" { puts "Network $NETWORK_NAME created" ; close } | ||
eof { catch wait result; if { [lindex $result 3] != 0 } { puts "Unable to create network"; Algoh::Abort } } | ||
} | ||
} EXCEPTION ] } { | ||
::AlgorandGoal::Abort "ERROR in CreateNetwork: $EXCEPTION" | ||
} | ||
} | ||
|
||
proc ::Algoh::StartNode { TEST_ALGO_DIR } { | ||
|
||
puts "Primary node start" | ||
# Start node | ||
if { [catch { | ||
spawn goal node start -d $TEST_ALGO_DIR | ||
expect { | ||
timeout { close; ::Algoh::Abort "Timed out starting relay node" } | ||
"^Algorand node successfully started!* { puts "Primary relay node started"; close } | ||
eof { catch wait result; if { [lindex $result 3] != 0 } { puts "Unable to start node"; Algoh::Abort } } | ||
} | ||
} EXCEPTION ] } { | ||
::Algoh::Abort "ERROR in StartNode: $EXCEPTION" | ||
} | ||
} | ||
|
||
proc ::Algoh::StopNode { TEST_ALGO_DIR } { | ||
set timeout 15 | ||
|
||
if { [catch { | ||
puts "node stop with $TEST_ALGO_DIR" | ||
spawn goal node stop -d $TEST_ALGO_DIR | ||
expect { | ||
timeout { close; ::Algoh::Abort "Did not recieve appropriate message during node stop"} | ||
"*The node was successfully stopped.*" {puts "Node stopped successfully"; close} | ||
eof { catch wait result; if { [lindex $result 3] != 0 } { puts "Unable to stop node"; Algoh::Abort } } | ||
|
||
} | ||
} EXCEPTION] } { | ||
::Algoh::Abort "ERROR in StopNode: $EXCEPTION" | ||
} | ||
} | ||
|
||
# Stop the network | ||
proc ::Algoh::StopNetwork { NETWORK_NAME TEST_ROOT_DIR } { | ||
set timeout 60 | ||
set NETWORK_STOP_MESSAGE "" | ||
puts "Stopping network: $NETWORK_NAME" | ||
spawn goal network stop -r $TEST_ROOT_DIR | ||
expect { | ||
timeout { | ||
close | ||
puts "Timed out shutting down network" | ||
puts "TEST_ROOT_DIR $::TEST_ROOT_DIR" | ||
puts "NETWORK_NAME $::NETWORK_NAME" | ||
exit 1 | ||
} | ||
"Network Stopped under.*" {set NETWORK_STOP_MESSAGE $expect_out(buffer); close} | ||
eof { catch wait result; if { [lindex $result 3] != 0 } { puts "Unable to stop network"; Algoh::Abort } } | ||
|
||
} | ||
puts $NETWORK_STOP_MESSAGE | ||
} |
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,87 @@ | ||
#!/usr/bin/expect -f | ||
set err 0 | ||
log_user 1 | ||
|
||
|
||
|
||
if { [catch { | ||
source algohExpectCommon.exp | ||
|
||
set TEST_ALGO_DIR [lindex $argv 0] | ||
set TEST_DATA_DIR [lindex $argv 1] | ||
|
||
exec mkdir -p $TEST_ALGO_DIR | ||
|
||
set TIME_STAMP [clock seconds] | ||
set timeout 5 | ||
|
||
set TEST_ROOT_DIR $TEST_ALGO_DIR/root | ||
set TEST_PRIMARY_NODE_DIR $TEST_ROOT_DIR/Primary | ||
set TEST_NODE_DIR $TEST_ROOT_DIR/Node | ||
set NETWORK_NAME test_net_expect_$TIME_STAMP | ||
set NETWORK_TEMPLATE "$TEST_DATA_DIR/nettemplates/TwoNodes50Each.json" | ||
puts "TEST_ALGO_DIR: $TEST_ALGO_DIR" | ||
|
||
|
||
::Algoh::CreateNetwork $NETWORK_NAME $NETWORK_TEMPLATE $TEST_ROOT_DIR | ||
|
||
::Algoh::StartNode $TEST_PRIMARY_NODE_DIR | ||
|
||
exec cat ./disabled_profiler_config.json > $TEST_NODE_DIR/config.json | ||
exec cat ./host-config.json > $TEST_NODE_DIR/host-config.json | ||
|
||
set PRIMARY_ADDR "" | ||
spawn cat $TEST_ROOT_DIR/Primary/algod-listen.net | ||
expect { | ||
-regexp {http://[0-9\.]+:[0-9]+} { regexp -- {[0-9.]+:[0-9]+} $expect_out(0,string) PRIMARY_ADDR; close;} | ||
timeout {puts "missed our case"; close; exit 1} | ||
} | ||
|
||
puts "regex match: $PRIMARY_ADDR" | ||
|
||
#start hosted node in the background | ||
spawn $env(GOPATH)/bin/algoh -d $TEST_NODE_DIR -p $PRIMARY_ADDR | ||
expect { | ||
"^Logging to: *" {puts "algoh startup successful"} | ||
timeout {puts "algoh failed to start"; close; exit 1} | ||
} | ||
|
||
#allow algoh time to put files in Node dir | ||
spawn sleep 5 | ||
set timeout 5 | ||
expect { | ||
timeout {puts "algod should be fully running"; close} | ||
} | ||
|
||
#wait until Node approves blocks to the network | ||
set timeout 60 | ||
spawn $env(GOPATH)/bin/goal node wait -d $TEST_NODE_DIR -w 61 | ||
expect { | ||
eof {puts "successfully communicating with relay node"} | ||
"Timed out waiting for node to make progress" {puts "timed out waiting for connection to relay node"; close; exit 1} | ||
timeout {puts "should not reached this case"; close; exit 1} | ||
} | ||
|
||
|
||
::Algoh::StopNode $TEST_PRIMARY_NODE_DIR | ||
|
||
|
||
set timeout 201 | ||
spawn $env(GOPATH)/bin/goal node wait -d $TEST_NODE_DIR -w 200 | ||
expect { | ||
"^Cannot contact Algorand node: open $TEST_NODE_DIR/algod.net: no such file or directory." {puts "ERROR: node shutdown"; close; exit 1} | ||
"^Timed out waiting for node to make progress" {puts "node correctly continued running despite relay shutdown"; close} | ||
timeout {puts "should not reached this case", close; exit 1} | ||
} | ||
|
||
::Algoh::StopNetwork $NETWORK_NAME $TEST_ROOT_DIR | ||
|
||
exec rm -d -r -f $TEST_ALGO_DIR | ||
puts "Basic Algoh Test Successful" | ||
exit 0 | ||
} EXCEPTION ] } { | ||
puts "ERROR in algoh test: $EXCEPTION" | ||
|
||
exec rm -d -r -f $TEST_ALGO_DIR | ||
exit 1 | ||
} |
Oops, something went wrong.