@@ -175,6 +175,30 @@ class SSTDumpToolTest : public testing::Test {
175175
176176 protected:
177177 constexpr static int kNumKey = 1024 ;
178+
179+ void SSTDumpToolTestCase (Options& opts, bool filter, int wide_column_one_in,
180+ const char * cmd_arg) {
181+ opts.env = env ();
182+ BlockBasedTableOptions table_opts;
183+ if (filter) {
184+ table_opts.filter_policy .reset (
185+ ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 ));
186+ }
187+ opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
188+ std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
189+ createSST (opts, file_path, wide_column_one_in);
190+
191+ char * usage[3 ];
192+ PopulateCommandArgs (file_path, cmd_arg, usage);
193+
194+ ROCKSDB_NAMESPACE ::SSTDumpTool tool;
195+ ASSERT_TRUE (!tool.Run (3 , usage, opts));
196+
197+ cleanup (opts, file_path);
198+ for (int i = 0 ; i < 3 ; i++) {
199+ delete[] usage[i];
200+ }
201+ }
178202};
179203
180204
@@ -194,156 +218,52 @@ TEST_F(SSTDumpToolTest, HelpAndVersion) {
194218
195219TEST_F (SSTDumpToolTest, EmptyFilter) {
196220 Options opts;
197- opts.env = env ();
198- std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
199- createSST (opts, file_path, 10 );
200-
201- char * usage[3 ];
202- PopulateCommandArgs (file_path, " --command=raw" , usage);
203-
204- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
205- ASSERT_TRUE (!tool.Run (3 , usage, opts));
206-
207- cleanup (opts, file_path);
208- for (int i = 0 ; i < 3 ; i++) {
209- delete[] usage[i];
210- }
221+ SSTDumpToolTestCase (opts, /* filter=*/ false , /* wide_column_one_in=*/ 10 ,
222+ " --command=raw" );
211223}
212224
213225TEST_F (SSTDumpToolTest, SstDumpReverseBytewiseComparator) {
214226 Options opts;
215- opts.env = env ();
216227 opts.comparator = ReverseBytewiseComparator ();
217- BlockBasedTableOptions table_opts;
218- table_opts.filter_policy .reset (
219- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , false ));
220- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
221- std::string file_path =
222- MakeFilePath (" rocksdb_sst_reverse_bytewise_comparator.sst" );
223- createSST (opts, file_path);
224-
225- char * usage[3 ];
226- PopulateCommandArgs (file_path, " --command=raw" , usage);
227-
228- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
229- ASSERT_TRUE (!tool.Run (3 , usage, opts));
230-
231- cleanup (opts, file_path);
232- for (int i = 0 ; i < 3 ; i++) {
233- delete[] usage[i];
234- }
228+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 10 ,
229+ " --command=raw" );
235230}
236231
237232TEST_F (SSTDumpToolTest, SstDumpComparatorWithU64Ts) {
238233 Options opts;
239- opts.env = env ();
240234 opts.comparator = test::BytewiseComparatorWithU64TsWrapper ();
241- BlockBasedTableOptions table_opts;
242- table_opts.filter_policy .reset (
243- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , false ));
244- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
245- std::string file_path =
246- MakeFilePath (" rocksdb_sst_comparator_with_u64_ts.sst" );
247- createSST (opts, file_path, 10 );
248-
249- char * usage[3 ];
250- PopulateCommandArgs (file_path, " --command=raw" , usage);
251-
252- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
253- ASSERT_TRUE (!tool.Run (3 , usage, opts));
254-
255- cleanup (opts, file_path);
256- for (int i = 0 ; i < 3 ; i++) {
257- delete[] usage[i];
258- }
235+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 10 ,
236+ " --command=raw" );
259237}
260238
261- TEST_F (SSTDumpToolTest, FilterBlock ) {
239+ TEST_F (SSTDumpToolTest, FilterBlockWideColumn ) {
262240 Options opts;
263- opts.env = env ();
264- BlockBasedTableOptions table_opts;
265- table_opts.filter_policy .reset (
266- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , true ));
267- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
268- std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
269- createSST (opts, file_path, 10 );
270-
271- char * usage[3 ];
272- PopulateCommandArgs (file_path, " --command=raw" , usage);
273-
274- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
275- ASSERT_TRUE (!tool.Run (3 , usage, opts));
276-
277- cleanup (opts, file_path);
278- for (int i = 0 ; i < 3 ; i++) {
279- delete[] usage[i];
280- }
241+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 10 ,
242+ " --command=raw" );
281243}
282244
283- TEST_F (SSTDumpToolTest, FullFilterBlock ) {
245+ TEST_F (SSTDumpToolTest, FilterBlock ) {
284246 Options opts;
285- opts.env = env ();
286- BlockBasedTableOptions table_opts;
287- table_opts.filter_policy .reset (
288- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , false ));
289- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
290- std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
291- createSST (opts, file_path);
292-
293- char * usage[3 ];
294- PopulateCommandArgs (file_path, " --command=raw" , usage);
295-
296- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
297- ASSERT_TRUE (!tool.Run (3 , usage, opts));
298-
299- cleanup (opts, file_path);
300- for (int i = 0 ; i < 3 ; i++) {
301- delete[] usage[i];
302- }
247+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 0 ,
248+ " --command=raw" );
303249}
304250
305251TEST_F (SSTDumpToolTest, GetProperties) {
306252 Options opts;
307- opts.env = env ();
308- BlockBasedTableOptions table_opts;
309- table_opts.filter_policy .reset (
310- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , false ));
311- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
312- std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
313- createSST (opts, file_path);
314-
315- char * usage[3 ];
316- PopulateCommandArgs (file_path, " --show_properties" , usage);
317-
318- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
319- ASSERT_TRUE (!tool.Run (3 , usage, opts));
320-
321- cleanup (opts, file_path);
322- for (int i = 0 ; i < 3 ; i++) {
323- delete[] usage[i];
324- }
253+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 0 ,
254+ " --show_properties" );
325255}
326256
327257TEST_F (SSTDumpToolTest, CompressedSizes) {
328258 Options opts;
329- opts.env = env ();
330- BlockBasedTableOptions table_opts;
331- table_opts.filter_policy .reset (
332- ROCKSDB_NAMESPACE::NewBloomFilterPolicy (10 , false ));
333- opts.table_factory .reset (new BlockBasedTableFactory (table_opts));
334- std::string file_path = MakeFilePath (" rocksdb_sst_test.sst" );
335- createSST (opts, file_path, 10 );
336-
337- char * usage[3 ];
338- PopulateCommandArgs (file_path, " --command=recompress" , usage);
339-
340- ROCKSDB_NAMESPACE ::SSTDumpTool tool;
341- ASSERT_TRUE (!tool.Run (3 , usage, opts));
259+ SSTDumpToolTestCase (opts, /* filter=*/ true , /* wide_column_one_in=*/ 10 ,
260+ " --command=recompress" );
261+ }
342262
343- cleanup (opts, file_path);
344- for ( int i = 0 ; i < 3 ; i++) {
345- delete[] usage[i];
346- }
263+ TEST_F (SSTDumpToolTest, ListMetaBlocks) {
264+ Options opts;
265+ SSTDumpToolTestCase (opts, /* filter= */ true , /* wide_column_one_in= */ 0 ,
266+ " --list_meta_blocks " );
347267}
348268
349269namespace {
@@ -455,8 +375,8 @@ TEST_F(SSTDumpToolTest, ReadaheadSize) {
455375
456376 // The file is approximately 10MB. Readahead is 4MB.
457377 // We usually need 3 reads + one metadata read.
458- // One extra read is needed before opening the file for metadata.
459- ASSERT_EQ (5 , num_reads);
378+ // Three extra read is needed before opening the file for metadata.
379+ ASSERT_EQ (7 , num_reads);
460380
461381 SyncPoint::GetInstance ()->ClearAllCallBacks ();
462382 SyncPoint::GetInstance ()->DisableProcessing ();
0 commit comments