3939# ```
4040#
4141
42- import sys , time , requests , os
42+ import sys , time , requests , logging
43+ from subprocess import check_output
4344from queue import Queue
4445
4546sys .path .append ('lib' )
4647
4748from cluster import init_cluster , spin_up_node , load_config
4849from populate import genesis_populate_all , copy_genesis
50+ from utils import LogTracker
51+
52+ logging .basicConfig (format = '%(asctime)s %(message)s' , level = logging .DEBUG )
4953
5054if len (sys .argv ) >= 2 :
5155 genesis_data = sys .argv [1 ]
5660config = load_config ()
5761near_root , node_dirs = init_cluster (
5862 1 , 2 , 1 , config ,
59- [["min_gas_price" , 0 ], ["max_inflation_rate" , [0 , 1 ]], ["epoch_length" , 20 ],
63+ [["min_gas_price" , 0 ], ["max_inflation_rate" , [0 , 1 ]], ["epoch_length" , 300 ],
6064 ["block_producer_kickout_threshold" , 80 ]], {1 : {
6165 "tracked_shards" : [0 ]
6266 }, 2 : {
6367 "tracked_shards" : [0 ]
6468 }})
6569
66- print ("Populating genesis" )
70+ logging . info ("Populating genesis" )
6771
6872if genesis_data is None :
6973 genesis_populate_all (near_root , additional_accounts , node_dirs )
7074else :
7175 for node_dir in node_dirs :
7276 copy_genesis (genesis_data , node_dir )
7377
74- print ("Genesis generated" )
78+ logging .info ("Genesis generated" )
79+
80+ for node_dir in node_dirs :
81+ result = check_output (['ls' , '-la' , node_dir ]).decode ()
82+ logging .info (f'Node directory: { node_dir } ' )
83+ for line in result .split ('\n ' ):
84+ logging .info (line )
7585
76- SMALL_HEIGHT = 40
77- LARGE_HEIGHT = 100
78- TIMEOUT = 300 + SMALL_HEIGHT + LARGE_HEIGHT
86+ SMALL_HEIGHT = 600
87+ LARGE_HEIGHT = 660
88+ TIMEOUT = 1450
7989start = time .time ()
8090
8191boot_node = spin_up_node (config , near_root , node_dirs [0 ], 0 , None , None )
@@ -90,12 +100,12 @@ def wait_for_height(target_height, rpc_node, sleep_time=2, bps_threshold=-1):
90100
91101 # Check current height
92102 try :
93- status = rpc_node .get_status ()
103+ status = rpc_node .get_status (False )
94104 new_height = status ['sync_info' ]['latest_block_height' ]
95- print (f"Height: { latest_height } => { new_height } " )
105+ logging . info (f"Height: { latest_height } => { new_height } " )
96106 latest_height = new_height
97107 except requests .ReadTimeout :
98- print ("Timeout Error" )
108+ logging . info ("Timeout Error" )
99109
100110 # Computing bps
101111 cur_time = time .time ()
@@ -112,17 +122,21 @@ def wait_for_height(target_height, rpc_node, sleep_time=2, bps_threshold=-1):
112122 bps = (head [1 ] - tail [1 ]) / (head [0 ] - tail [0 ])
113123
114124
115- print (f"bps: { bps } queue length: { len (queue )} " )
125+ logging . info (f"bps: { bps } queue length: { len (queue )} " )
116126 time .sleep (sleep_time )
117127 assert bps is None or bps >= bps_threshold
118128
119129
120130wait_for_height (SMALL_HEIGHT , boot_node )
121131
122132observer = spin_up_node (config , near_root , node_dirs [2 ], 2 , boot_node .node_key .pk , boot_node .addr ())
133+ tracker = LogTracker (observer )
123134
124135# Check that bps is not degraded
125136wait_for_height (LARGE_HEIGHT , boot_node )
126137
127138# Make sure observer2 is able to sync
128139wait_for_height (SMALL_HEIGHT , observer )
140+
141+ tracker .reset ()
142+ assert tracker .check ("transition to State Sync" )
0 commit comments