@@ -42,7 +42,7 @@ use crate::{
42
42
} ,
43
43
util:: { block_on, get_nns_node} ,
44
44
} ;
45
- use ic_backup:: backup_helper:: ls_path;
45
+ use ic_backup:: backup_helper:: { last_checkpoint , ls_path} ;
46
46
use ic_backup:: config:: { ColdStorage , Config , SubnetConfig } ;
47
47
use ic_backup:: util:: sleep_secs;
48
48
use ic_base_types:: SubnetId ;
@@ -77,7 +77,7 @@ pub fn config(env: TestEnv) {
77
77
pub fn test ( env : TestEnv ) {
78
78
let log = env. logger ( ) ;
79
79
80
- // Create all directories
80
+ info ! ( log , " Create all directories" ) ;
81
81
let root_dir = tempfile:: TempDir :: new ( )
82
82
. expect ( "failed to create a temporary directory" )
83
83
. path ( )
@@ -91,6 +91,7 @@ pub fn test(env: TestEnv) {
91
91
. path ( )
92
92
. to_path_buf ( ) ;
93
93
94
+ info ! ( log, "Fetch the replica version" ) ;
94
95
let nns_node = get_nns_node ( & env. topology_snapshot ( ) ) ;
95
96
let node_ip: IpAddr = nns_node. get_ip_addr ( ) ;
96
97
let subnet_id = env. topology_snapshot ( ) . root_subnet_id ( ) ;
@@ -99,6 +100,10 @@ pub fn test(env: TestEnv) {
99
100
let initial_replica_version = ReplicaVersion :: try_from ( replica_version. clone ( ) )
100
101
. expect ( "Assigned replica version should be valid" ) ;
101
102
103
+ info ! (
104
+ log,
105
+ "Copy the binaries needed for replay of the current version"
106
+ ) ;
102
107
let backup_binaries_dir = backup_dir. join ( "binaries" ) . join ( & replica_version) ;
103
108
fs:: create_dir_all ( & backup_binaries_dir) . expect ( "failure creating backup binaries directory" ) ;
104
109
@@ -109,6 +114,10 @@ pub fn test(env: TestEnv) {
109
114
copy_file ( & binaries_path, & backup_binaries_dir, "sandbox_launcher" ) ;
110
115
copy_file ( & binaries_path, & backup_binaries_dir, "canister_sandbox" ) ;
111
116
117
+ info ! (
118
+ log,
119
+ "Download the binaries needed for replay of the mainnet version"
120
+ ) ;
112
121
let mainnet_version = env
113
122
. read_dependency_to_string ( "testnet/mainnet_nns_revision.txt" )
114
123
. expect ( "could not read mainnet version!" ) ;
@@ -130,6 +139,7 @@ pub fn test(env: TestEnv) {
130
139
. expect ( "chmod command failed" ) ;
131
140
chmod. wait_with_output ( ) . expect ( "chmod execution failed" ) ;
132
141
142
+ info ! ( log, "Run ECDSA signature test" ) ;
133
143
let nns_node = env. get_first_healthy_nns_node_snapshot ( ) ;
134
144
let agent = nns_node. build_default_agent ( ) ;
135
145
let nns_canister = block_on ( MessageCanister :: new (
@@ -146,6 +156,7 @@ pub fn test(env: TestEnv) {
146
156
) ;
147
157
run_ecdsa_signature_test ( & nns_canister, & log, key) ;
148
158
159
+ info ! ( log, "Install universal canister" ) ;
149
160
let log2 = log. clone ( ) ;
150
161
let id = nns_node. effective_canister_id ( ) ;
151
162
let canister_id_hex: String = block_on ( {
@@ -155,13 +166,13 @@ pub fn test(env: TestEnv) {
155
166
}
156
167
} ) ;
157
168
158
- // Update the registry with the backup key
169
+ info ! ( log , " Update the registry with the backup key" ) ;
159
170
let payload = get_updatesubnetpayload_with_keys ( subnet_id, None , Some ( vec ! [ backup_public_key] ) ) ;
160
171
block_on ( update_subnet_record ( nns_node. get_public_url ( ) , payload) ) ;
161
172
let backup_mean = AuthMean :: PrivateKey ( backup_private_key) ;
162
173
wait_until_authentication_is_granted ( & node_ip, "backup" , & backup_mean) ;
163
174
164
- // Fetch NNS public key
175
+ info ! ( log , " Fetch NNS public key" ) ;
165
176
let nns_public_key = env
166
177
. prep_dir ( "" )
167
178
. expect ( "missing NNS public key" )
@@ -229,6 +240,7 @@ pub fn test(env: TestEnv) {
229
240
& log,
230
241
) ) ;
231
242
243
+ info ! ( log, "Wait for archived checkpoint" ) ;
232
244
let archive_dir = backup_dir. join ( "archive" ) . join ( subnet_id. to_string ( ) ) ;
233
245
// make sure we have some archive of the old version before upgrading to the new one
234
246
loop {
@@ -305,6 +317,7 @@ pub fn test(env: TestEnv) {
305
317
info ! ( log, "Modify memory file: {:?}" , memory_artifact_path) ;
306
318
modify_byte_in_file ( memory_artifact_path) . expect ( "Modifying a byte failed" ) ;
307
319
320
+ info ! ( log, "Start again the backup process in a separate thread" ) ;
308
321
let mut command = Command :: new ( & ic_backup_path) ;
309
322
command
310
323
. arg ( "--config-file" )
@@ -317,10 +330,12 @@ pub fn test(env: TestEnv) {
317
330
. expect ( "Failed to start backup process" ) ;
318
331
info ! ( log, "Started process: {}" , child. id( ) ) ;
319
332
320
- assert ! ( cold_storage_exists(
321
- & log,
322
- cold_storage_dir. join( subnet_id. to_string( ) )
323
- ) ) ;
333
+ if !cold_storage_exists ( & log, cold_storage_dir. join ( subnet_id. to_string ( ) ) ) {
334
+ info ! ( log, "Kill child process" ) ;
335
+ child. kill ( ) . expect ( "Error killing backup process" ) ;
336
+ panic ! ( "No cold storage" ) ;
337
+ }
338
+
324
339
info ! ( log, "Artifacts and states are moved to cold storage" ) ;
325
340
326
341
let mut hash_mismatch = false ;
@@ -365,17 +380,15 @@ fn some_checkpoint_dir(backup_dir: &Path, subnet_id: &SubnetId) -> Option<PathBu
365
380
let dir = backup_dir
366
381
. join ( "data" )
367
382
. join ( subnet_id. to_string ( ) )
368
- . join ( "ic_state" )
369
- . join ( "checkpoints" ) ;
383
+ . join ( "ic_state" ) ;
370
384
if !dir. exists ( ) {
371
385
return None ;
372
386
}
373
- if let Ok ( mut cps) = fs:: read_dir ( dir) {
374
- if let Some ( Ok ( cp) ) = cps. next ( ) {
375
- return Some ( cp. path ( ) ) ;
376
- }
387
+ let lcp = last_checkpoint ( & dir) ;
388
+ if lcp == 0 {
389
+ return None ;
377
390
}
378
- None
391
+ Some ( dir . join ( format ! ( "checkpoints/{:016x}" , lcp ) ) )
379
392
}
380
393
381
394
fn modify_byte_in_file ( file_path : PathBuf ) -> std:: io:: Result < ( ) > {
0 commit comments