@@ -55,18 +55,25 @@ run_online_imp_exp_tests() {
55
55
reset_blockstore 0
56
56
reset_blockstore 1
57
57
58
- cat > basic_import_expected << EOE
58
+ cat > basic_import_stats_expected << EOE
59
+ Imported 1198 blocks (468513 bytes)
59
60
Pinned root${tab} bafkqaaa${tab} success
60
61
Pinned root${tab} bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u${tab} success
61
62
Pinned root${tab} bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy${tab} success
62
63
EOE
64
+ # output without the --stats line at the top
65
+ tail -n +2 basic_import_stats_expected > basic_import_expected
63
66
67
+ # Explainer:
68
+ # naked_root_import_json_expected output is produced by dag import of combined_naked_roots_genesis_and_128.car
69
+ # executed when roots are already present in the repo - thus the BlockCount=0
70
+ # (if blocks were not present in the repo, blockstore: block not found would be returned)
64
71
cat > naked_root_import_json_expected << EOE
65
72
{"Root":{"Cid":{"/":"bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u"},"PinErrorMsg":""}}
66
73
{"Root":{"Cid":{"/":"bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy"},"PinErrorMsg":""}}
74
+ {"Stats":{"BlockCount":0,"BlockBytesCount":0}}
67
75
EOE
68
76
69
-
70
77
test_expect_success " basic import" '
71
78
do_import 0 \
72
79
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
79
86
test_cmp_sorted basic_import_expected basic_import_actual
80
87
'
81
88
89
+ test_expect_success " basic import with --stats" '
90
+ do_import 0 --stats \
91
+ ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
92
+ ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car \
93
+ ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car \
94
+ > basic_import_actual
95
+ '
96
+
97
+ test_expect_success " basic import output with --stats as expected" '
98
+ test_cmp_sorted basic_import_stats_expected basic_import_actual
99
+ '
100
+
82
101
test_expect_success " basic fetch+export 1" '
83
102
ipfsi 1 dag export bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy > reexported_testnet_128.car
84
103
'
98
117
'
99
118
100
119
test_expect_success " import/pin naked roots only, relying on local blockstore having all the data" '
101
- ipfsi 1 dag import --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
120
+ ipfsi 1 dag import --stats -- enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
102
121
> naked_import_result_json_actual
103
122
'
104
123
117
136
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet &
118
137
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet &
119
138
120
- do_import 0 \
139
+ do_import 0 --stats \
121
140
pipe_testnet \
122
141
pipe_devnet \
123
142
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
134
153
'
135
154
136
155
test_expect_success " fifo-import output as expected" '
137
- test_cmp_sorted basic_import_expected basic_fifo_import_actual
156
+ test_cmp_sorted basic_import_stats_expected basic_fifo_import_actual
138
157
'
139
158
}
140
159
@@ -168,33 +187,46 @@ test_expect_success "correct error" '
168
187
test_cmp_sorted offline_fetch_error_expected offline_fetch_error_actual
169
188
'
170
189
171
-
172
- cat > multiroot_import_json_expected << EOE
190
+ cat > multiroot_import_json_stats_expected << EOE
173
191
{"Root":{"Cid":{"/":"bafy2bzaceb55n7uxyfaelplulk3ev2xz7gnq6crncf3ahnvu46hqqmpucizcw"},"PinErrorMsg":""}}
174
192
{"Root":{"Cid":{"/":"bafy2bzacebedrc4n2ac6cqdkhs7lmj5e4xiif3gu7nmoborihajxn3fav3vdq"},"PinErrorMsg":""}}
175
193
{"Root":{"Cid":{"/":"bafy2bzacede2hsme6hparlbr4g2x6pylj43olp4uihwjq3plqdjyrdhrv7cp4"},"PinErrorMsg":""}}
194
+ {"Stats":{"BlockCount":2825,"BlockBytesCount":1339709}}
176
195
EOE
177
- test_expect_success " multiroot import works" '
196
+ # output without --stats line
197
+ head -3 multiroot_import_json_stats_expected > multiroot_import_json_expected
198
+
199
+ test_expect_success " multiroot import works (--enc=json)" '
178
200
ipfs dag import --enc=json ../t0054-dag-car-import-export-data/lotus_testnet_export_256_multiroot.car > multiroot_import_json_actual
179
201
'
180
202
test_expect_success " multiroot import expected output" '
181
203
test_cmp_sorted multiroot_import_json_expected multiroot_import_json_actual
182
204
'
183
205
206
+ test_expect_success " multiroot import works with --stats" '
207
+ ipfs dag import --stats --enc=json ../t0054-dag-car-import-export-data/lotus_testnet_export_256_multiroot.car > multiroot_import_json_actual
208
+ '
209
+ test_expect_success " multiroot import expected output" '
210
+ test_cmp_sorted multiroot_import_json_stats_expected multiroot_import_json_actual
211
+ '
212
+
184
213
214
+ cat > pin_import_expected << EOE
215
+ {"Stats":{"BlockCount":1198,"BlockBytesCount":468513}}
216
+ EOE
185
217
test_expect_success " pin-less import works" '
186
- ipfs dag import --enc=json --pin-roots=false \
218
+ ipfs dag import --stats -- enc=json --pin-roots=false \
187
219
../t0054-dag-car-import-export-data/lotus_devnet_genesis.car \
188
220
../t0054-dag-car-import-export-data/lotus_testnet_export_128.car \
189
221
> no-pin_import_actual
190
222
'
191
- test_expect_success " expected silence on --pin-roots=false" '
192
- test_cmp /dev/null no-pin_import_actual
223
+ test_expect_success " expected no pins on --pin-roots=false" '
224
+ test_cmp pin_import_expected no-pin_import_actual
193
225
'
194
226
195
227
196
228
test_expect_success " naked root import works" '
197
- ipfs dag import --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
229
+ ipfs dag import --stats -- enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
198
230
> naked_root_import_json_actual
199
231
'
200
232
test_expect_success " naked root import expected output" '
0 commit comments