Skip to content

Commit a535b5b

Browse files
Fix[Storagetool] Set search all records by default for both Journal and CSL modes (#838)
Signed-off-by: Aleksandr Ivanov <aivanov71@bloomberg.net>
1 parent ca9982f commit a535b5b

5 files changed

Lines changed: 60 additions & 20 deletions

File tree

src/applications/bmqstoragetool/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Usage: bmqstoragetool [-r|record-type <record type>]*
5353
[-h|help]
5454
Where:
5555
-r | --record-type <record type>
56-
record type to search {<message>|queue-op|journal-op} (default: message)
56+
record type to search {<all>|<message|queue-op|journal-op} (default: all record types)
5757
--csl-record-type <csl record type>
58-
CSL record type to search {<snapshot>|update|commit|ack} (default: all record types)
58+
CSL record type to search {<all>|snapshot|update|commit|ack} (default: all record types)
5959
--journal-path <pattern>
6060
'*'-ended file path pattern, where the tool will try to find journal
6161
and data files

src/applications/bmqstoragetool/bmqstoragetool.m.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ static bool parseArgs(CommandLineArguments& arguments,
4242
balcl::OptionInfo specTable[] = {
4343
{"r|record-type",
4444
"record type",
45-
"record type to search {<message>|queue-op|journal-op}",
45+
"record type to search {<all>|message|queue-op|journal-op}",
4646
balcl::TypeInfo(&arguments.d_recordType,
4747
CommandLineArguments::isValidRecordType),
4848
balcl::OccurrenceInfo::e_OPTIONAL},
4949
{"csl-record-type",
5050
"csl record type",
51-
"CSL record type to search {<snapshot>|update|commit|ack}",
51+
"CSL record type to search {<all>|snapshot|update|commit|ack}",
5252
balcl::TypeInfo(&arguments.d_cslRecordType,
5353
CommandLineArguments::isValidCslRecordType),
5454
balcl::OccurrenceInfo::e_OPTIONAL},

src/applications/bmqstoragetool/integration-tests/test_journalfile.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def test_short_result(storagetool, journal_file, expected_short_result):
3333
- checks GUID searching.
3434
"""
3535
res = subprocess.run(
36-
[storagetool, "--journal-file", journal_file], capture_output=True, check=True
36+
[storagetool, "--journal-file", journal_file, "-r=message"],
37+
capture_output=True,
38+
check=True,
3739
)
3840
assert res.returncode == EX_OK
3941
assert res.stdout == expected_short_result
@@ -43,6 +45,7 @@ def test_short_result(storagetool, journal_file, expected_short_result):
4345
storagetool,
4446
"--journal-file",
4547
journal_file,
48+
"-r=message",
4649
"--guid",
4750
TEST_GUID_1,
4851
],
@@ -61,7 +64,13 @@ def test_short_json(storagetool, journal_file):
6164
"""
6265
for mode in ["pretty", "line"]:
6366
res = subprocess.run(
64-
[storagetool, "--journal-file", journal_file, f"--print-mode=json-{mode}"],
67+
[
68+
storagetool,
69+
"--journal-file",
70+
journal_file,
71+
"-r=message",
72+
f"--print-mode=json-{mode}",
73+
],
6574
capture_output=True,
6675
check=True,
6776
)
@@ -79,7 +88,7 @@ def test_detail_result(storagetool, journal_file, csl_file, expected_detail_resu
7988
- checks that storage tool can process journal and csl files and output details with queue names.
8089
"""
8190
res = subprocess.run(
82-
[storagetool, "--journal-file", journal_file, "--details"],
91+
[storagetool, "--journal-file", journal_file, "-r=message", "--details"],
8392
capture_output=True,
8493
check=True,
8594
)
@@ -121,6 +130,7 @@ def test_detail_json(storagetool, journal_file, csl_file):
121130
journal_file,
122131
"--csl-file",
123132
csl_file,
133+
"-r=message",
124134
"--details",
125135
f"--print-mode=json-{mode}",
126136
],
@@ -148,6 +158,7 @@ def test_payload_dump(
148158
journal_file,
149159
"--data-file",
150160
data_file,
161+
"-r=message",
151162
"--dump-payload",
152163
],
153164
capture_output=True,
@@ -157,7 +168,7 @@ def test_payload_dump(
157168
assert res.stdout == expected_payload_dump
158169

159170
res = subprocess.run(
160-
[storagetool, "--journal-path", journal_path, "--dump-payload"],
171+
[storagetool, "--journal-path", journal_path, "-r=message", "--dump-payload"],
161172
capture_output=True,
162173
check=True,
163174
)
@@ -169,6 +180,7 @@ def test_payload_dump(
169180
storagetool,
170181
"--journal-path",
171182
journal_path,
183+
"-r=message",
172184
"--dump-payload",
173185
"--dump-limit=5",
174186
],
@@ -190,6 +202,7 @@ def test_summary_result(storagetool, journal_path, csl_file, expected_summary_re
190202
journal_path,
191203
"--csl-file",
192204
csl_file,
205+
"-r=message",
193206
"--summary",
194207
],
195208
capture_output=True,
@@ -212,6 +225,7 @@ def test_summary_result_with_queue_info(
212225
journal_path,
213226
"--csl-file",
214227
csl_file,
228+
"-r=message",
215229
"--summary",
216230
"--min-records-per-queue",
217231
"1",
@@ -235,6 +249,7 @@ def test_summary_with_queue_info_json(storagetool, journal_path, csl_file):
235249
journal_path,
236250
"--csl-file",
237251
csl_file,
252+
"-r=message",
238253
"--summary",
239254
"--min-records-per-queue",
240255
"1",
@@ -266,7 +281,7 @@ def test_confirmed_outstanding_result(storagetool, journal_file):
266281
- checks that storage tool can search outstanding messages and output short result (message GUIDs).
267282
"""
268283
res = subprocess.run(
269-
[storagetool, "--journal-file", journal_file, "--confirmed"],
284+
[storagetool, "--journal-file", journal_file, "-r=message", "--confirmed"],
270285
capture_output=True,
271286
check=True,
272287
)
@@ -275,7 +290,7 @@ def test_confirmed_outstanding_result(storagetool, journal_file):
275290
assert re.search(TEST_GUID_1, res.stdout) is None
276291

277292
res = subprocess.run(
278-
[storagetool, "--journal-file", journal_file, "--outstanding"],
293+
[storagetool, "--journal-file", journal_file, "-r=message", "--outstanding"],
279294
capture_output=True,
280295
check=True,
281296
)

src/applications/bmqstoragetool/m_bmqstoragetool_parameters.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const char* CommandLineArguments::k_ALL_TYPE = "all";
9191
const char* CommandLineArguments::k_MESSAGE_TYPE = "message";
9292
const char* CommandLineArguments::k_QUEUEOP_TYPE = "queue-op";
9393
const char* CommandLineArguments::k_JOURNALOP_TYPE = "journal-op";
94+
const char* CommandLineArguments::k_CSL_ALL_TYPE = "all";
9495
const char* CommandLineArguments::k_CSL_SNAPSHOT_TYPE = "snapshot";
9596
const char* CommandLineArguments::k_CSL_UPDATE_TYPE = "update";
9697
const char* CommandLineArguments::k_CSL_COMMIT_TYPE = "commit";
@@ -476,7 +477,8 @@ bool CommandLineArguments::isValidCslRecordType(
476477
const bsl::string* cslRecordType,
477478
bsl::ostream& stream)
478479
{
479-
if (*cslRecordType != k_CSL_SNAPSHOT_TYPE &&
480+
if (*cslRecordType != k_CSL_ALL_TYPE &&
481+
*cslRecordType != k_CSL_SNAPSHOT_TYPE &&
480482
*cslRecordType != k_CSL_UPDATE_TYPE &&
481483
*cslRecordType != k_CSL_COMMIT_TYPE &&
482484
*cslRecordType != k_CSL_ACK_TYPE) {
@@ -532,6 +534,13 @@ Parameters::ProcessRecordTypes::ProcessRecordTypes()
532534
// NOTHING
533535
}
534536

537+
void Parameters::ProcessRecordTypes::setAll()
538+
{
539+
d_message = true;
540+
d_queueOp = true;
541+
d_journalOp = true;
542+
}
543+
535544
bool Parameters::ProcessRecordTypes::operator==(
536545
ProcessRecordTypes const& other) const
537546
{
@@ -548,6 +557,14 @@ Parameters::ProcessCslRecordTypes::ProcessCslRecordTypes()
548557
// NOTHING
549558
}
550559

560+
void Parameters::ProcessCslRecordTypes::setAll()
561+
{
562+
d_snapshot = true;
563+
d_update = true;
564+
d_commit = true;
565+
d_ack = true;
566+
}
567+
551568
bool Parameters::ProcessCslRecordTypes::operator==(
552569
ProcessCslRecordTypes const& other) const
553570
{
@@ -598,17 +615,17 @@ Parameters::Parameters(const CommandLineArguments& arguments,
598615
if (d_cslMode) {
599616
if (arguments.d_cslRecordType.empty()) {
600617
// Set all CSL record types to process by default.
601-
d_processCslRecordTypes.d_snapshot = true;
602-
d_processCslRecordTypes.d_update = true;
603-
d_processCslRecordTypes.d_commit = true;
604-
d_processCslRecordTypes.d_ack = true;
618+
d_processCslRecordTypes.setAll();
605619
}
606620
else {
607621
for (bsl::vector<bsl::string>::const_iterator cit =
608622
arguments.d_cslRecordType.begin();
609623
cit != arguments.d_cslRecordType.end();
610624
++cit) {
611-
if (*cit == CommandLineArguments::k_CSL_SNAPSHOT_TYPE) {
625+
if (*cit == CommandLineArguments::k_CSL_ALL_TYPE) {
626+
d_processCslRecordTypes.setAll();
627+
}
628+
else if (*cit == CommandLineArguments::k_CSL_SNAPSHOT_TYPE) {
612629
d_processCslRecordTypes.d_snapshot = true;
613630
}
614631
else if (*cit == CommandLineArguments::k_CSL_UPDATE_TYPE) {
@@ -628,17 +645,16 @@ Parameters::Parameters(const CommandLineArguments& arguments,
628645
}
629646
else {
630647
if (arguments.d_recordType.empty()) {
631-
d_processRecordTypes.d_message = true;
648+
// Set all journal record types to process by default.
649+
d_processRecordTypes.setAll();
632650
}
633651
else {
634652
for (bsl::vector<bsl::string>::const_iterator cit =
635653
arguments.d_recordType.begin();
636654
cit != arguments.d_recordType.end();
637655
++cit) {
638656
if (*cit == CommandLineArguments::k_ALL_TYPE) {
639-
d_processRecordTypes.d_message = true;
640-
d_processRecordTypes.d_queueOp = true;
641-
d_processRecordTypes.d_journalOp = true;
657+
d_processRecordTypes.setAll();
642658
break; // BREAK
643659
}
644660
else if (*cit == CommandLineArguments::k_MESSAGE_TYPE) {

src/applications/bmqstoragetool/m_bmqstoragetool_parameters.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class CommandLineArguments {
6363
static const char* k_MESSAGE_TYPE;
6464
static const char* k_QUEUEOP_TYPE;
6565
static const char* k_JOURNALOP_TYPE;
66+
static const char* k_CSL_ALL_TYPE;
6667
static const char* k_CSL_SNAPSHOT_TYPE;
6768
static const char* k_CSL_UPDATE_TYPE;
6869
static const char* k_CSL_COMMIT_TYPE;
@@ -225,6 +226,10 @@ struct Parameters {
225226
// CREATORS
226227
explicit ProcessRecordTypes();
227228

229+
// MANIPULATORS
230+
/// Set all record types to process
231+
void setAll();
232+
228233
bool operator==(ProcessRecordTypes const& other) const;
229234
};
230235

@@ -244,6 +249,10 @@ struct Parameters {
244249
// CREATORS
245250
explicit ProcessCslRecordTypes();
246251

252+
// MANIPULATORS
253+
/// Set all CSL record types to process
254+
void setAll();
255+
247256
bool operator==(ProcessCslRecordTypes const& other) const;
248257
};
249258

0 commit comments

Comments
 (0)