From 64a11e5bf3a4f5cd11ac9a172f51c5e93f010678 Mon Sep 17 00:00:00 2001 From: tejaskriya Date: Tue, 3 Dec 2024 14:10:10 +0530 Subject: [PATCH 1/3] HDDS-11782. ozone debug ldb --with-keys defaults to false instead of true --- .../dist/src/main/smoketest/debug/ozone-debug-ldb.robot | 8 ++++++++ .../java/org/apache/hadoop/ozone/debug/DBScanner.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot index 7157c232d1a9..898b703eaaef 100644 --- a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot +++ b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot @@ -55,6 +55,14 @@ Test ozone debug ldb scan Should contain ${output} testfile1 Should contain ${output} testfile2 Should contain ${output} testfile3 + # test key is included with --with-keys + ${output1} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + ${output2} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + Should contain ${output1} testfile1 + Should Be Equal ${output1} ${output2} + # test key is ommitted with --with-keys set to false + ${output} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys=false | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + Should contain ${output} Cannot index array with string # test startkey option ${output} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --startkey="/cli-debug-volume/cli-debug-bucket/testfile2" Should not contain ${output} testfile1 diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBScanner.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBScanner.java index bd5b1ed6c1c5..d3348ba19bef 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBScanner.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBScanner.java @@ -107,7 +107,7 @@ public class DBScanner implements Callable, SubcommandWithParent { @CommandLine.Option(names = {"--with-keys"}, description = "Print a JSON object of key->value pairs (default)" + " instead of a JSON array of only values.", - defaultValue = "true") + defaultValue = "true", fallbackValue = "true") private boolean withKey; @CommandLine.Option(names = {"--length", "--limit", "-l"}, From 437deccf1b0e2e7efa7d3d04a63c252142038b90 Mon Sep 17 00:00:00 2001 From: tejaskriya Date: Tue, 3 Dec 2024 14:13:59 +0530 Subject: [PATCH 2/3] Remove error handling in test --- .../dist/src/main/smoketest/debug/ozone-debug-ldb.robot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot index 898b703eaaef..70b108316033 100644 --- a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot +++ b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot @@ -56,8 +56,8 @@ Test ozone debug ldb scan Should contain ${output} testfile2 Should contain ${output} testfile3 # test key is included with --with-keys - ${output1} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' - ${output2} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + ${output1} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + ${output2} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' Should contain ${output1} testfile1 Should Be Equal ${output1} ${output2} # test key is ommitted with --with-keys set to false From a155fd13f850b11d77db8c3ae9efed46d85f7c60 Mon Sep 17 00:00:00 2001 From: tejaskriya Date: Wed, 4 Dec 2024 11:11:22 +0530 Subject: [PATCH 3/3] extend acceptance test --- .../dist/src/main/smoketest/debug/ozone-debug-ldb.robot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot index 70b108316033..0fa43dee6c0b 100644 --- a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot +++ b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot @@ -58,8 +58,10 @@ Test ozone debug ldb scan # test key is included with --with-keys ${output1} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' ${output2} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' + ${output3} = Execute ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys=true | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' Should contain ${output1} testfile1 Should Be Equal ${output1} ${output2} + Should Be Equal ${output1} ${output3} # test key is ommitted with --with-keys set to false ${output} = Execute and Ignore Error ozone debug ldb --db=/data/metadata/om.db scan --cf=keyTable --with-keys=false | jq '."\/cli-debug-volume\/cli-debug-bucket\/testfile1"' Should contain ${output} Cannot index array with string