This is an automated email from the ASF dual-hosted git repository. ddanielr pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new f3bd1b8dff Fixes shell pagination (#5251) f3bd1b8dff is described below commit f3bd1b8dffff7fda53741ab3145b56f0213edc9c Author: Daniel Roberts <ddani...@gmail.com> AuthorDate: Tue Jan 14 07:50:54 2025 -0500 Fixes shell pagination (#5251) * Remove -np from all tests * Check conditions for pagination Adds a boolean to track if the shell is able to paginate and adds specific conditions that invalidate pagination * Removes unneeded check and mockshell terminal size Removes the terminal size from MockShell so pagination does not occur. --- .../main/java/org/apache/accumulo/shell/Shell.java | 5 +- .../org/apache/accumulo/test/shell/MockShell.java | 2 - .../apache/accumulo/test/shell/ShellServerIT.java | 65 +++++++++++----------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java index eafe3d69e1..71e9d278b8 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java +++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java @@ -229,6 +229,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { protected String execCommand = null; protected boolean verbose = true; + private boolean canPaginate = false; private boolean tabCompletion; private boolean disableAuthTimeout; private long authTimeout; @@ -383,6 +384,8 @@ public class Shell extends ShellOptions implements KeywordExecutable { } } + canPaginate = terminal.getSize().getRows() > 0; + // decide whether to execute commands from a file and quit if (options.getExecFile() != null) { execFile = options.getExecFile(); @@ -1066,7 +1069,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { if (out == null) { if (peek != null) { writer.println(peek); - if (paginate) { + if (canPaginate && paginate) { linesPrinted += peek.isEmpty() ? 0 : Math.ceil(peek.length() * 1.0 / termWidth); // check if displaying the next line would result in diff --git a/test/src/main/java/org/apache/accumulo/test/shell/MockShell.java b/test/src/main/java/org/apache/accumulo/test/shell/MockShell.java index a8ffc850d3..965be08ddf 100644 --- a/test/src/main/java/org/apache/accumulo/test/shell/MockShell.java +++ b/test/src/main/java/org/apache/accumulo/test/shell/MockShell.java @@ -30,7 +30,6 @@ import org.apache.accumulo.core.clientImpl.ClientInfo; import org.apache.accumulo.shell.Shell; import org.jline.reader.LineReader; import org.jline.reader.LineReaderBuilder; -import org.jline.terminal.Size; import org.jline.terminal.Terminal; import org.jline.terminal.impl.DumbTerminal; import org.slf4j.Logger; @@ -53,7 +52,6 @@ public class MockShell { output = new TestOutputStream(); input = new StringInputStream(); terminal = new DumbTerminal(input, output); - terminal.setSize(new Size(80, 24)); reader = LineReaderBuilder.builder().terminal(terminal).build(); shell = new Shell(reader); shell.setLogErrorsToConsole(); diff --git a/test/src/main/java/org/apache/accumulo/test/shell/ShellServerIT.java b/test/src/main/java/org/apache/accumulo/test/shell/ShellServerIT.java index 59805e5118..c275558186 100644 --- a/test/src/main/java/org/apache/accumulo/test/shell/ShellServerIT.java +++ b/test/src/main/java/org/apache/accumulo/test/shell/ShellServerIT.java @@ -223,7 +223,7 @@ public class ShellServerIT extends SharedMiniClusterBase { } Thread.sleep(20); ts.exec("importtable " + table2 + " " + import_, true); - ts.exec("config -t " + table2 + " -np", true, "345M", true); + ts.exec("config -t " + table2, true, "345M", true); ts.exec("getsplits -t " + table2, true, "row5", true); ts.exec("constraint --list -t " + table2, true, "VisibilityConstraint=2", true); ts.exec("online " + table, true); @@ -249,14 +249,14 @@ public class ShellServerIT extends SharedMiniClusterBase { for (int i = 0; i < 50; i++) { String expected = (100 + i) + "M"; ts.exec("config -t " + table + " -s table.split.threshold=" + expected, true); - ts.exec("config -t " + table + " -np -f table.split.threshold", true, expected, true); + ts.exec("config -t " + table + " -f table.split.threshold", true, expected, true); ts.exec("config -t " + table + " -s table.scan.max.memory=" + expected, true); - ts.exec("config -t " + table + " -np -f table.scan.max.memory", true, expected, true); + ts.exec("config -t " + table + " -f table.scan.max.memory", true, expected, true); String bExpected = ((i % 2) == 0) ? "true" : "false"; ts.exec("config -t " + table + " -s table.bloom.enabled=" + bExpected, true); - ts.exec("config -t " + table + " -np -f table.bloom.enabled", true, bExpected, true); + ts.exec("config -t " + table + " -f table.bloom.enabled", true, bExpected, true); } } } @@ -688,7 +688,7 @@ public class ShellServerIT extends SharedMiniClusterBase { ts.exec("table " + clone); ts.exec("scan", true, "value", true); ts.exec("constraint --list -t " + clone, true, "VisibilityConstraint=2", true); - ts.exec("config -t " + clone + " -np", true, "123M", true); + ts.exec("config -t " + clone, true, "123M", true); ts.exec("getsplits -t " + clone, true, "a\nb\nc\n"); ts.exec("deletetable -f " + table); ts.exec("deletetable -f " + clone); @@ -717,7 +717,7 @@ public class ShellServerIT extends SharedMiniClusterBase { ts.exec("table " + clone); ts.exec("scan", false, "TableOfflineException", true); ts.exec("constraint --list -t " + clone, true, "VisibilityConstraint=2", true); - ts.exec("config -t " + clone + " -np", true, "123M", true); + ts.exec("config -t " + clone, true, "123M", true); ts.exec("getsplits -t " + clone, true, "a\nb\nc\n"); ts.exec("deletetable -f " + table); ts.exec("deletetable -f " + clone); @@ -1080,7 +1080,7 @@ public class ShellServerIT extends SharedMiniClusterBase { assertEquals(10, countkeys(table)); ts.exec("deletemany -f -b row8"); assertEquals(8, countkeys(table)); - ts.exec("scan -t " + table + " -np", true, "row8", false); + ts.exec("scan -t " + table, true, "row8", false); make10(); ts.exec("deletemany -f -b row4 -e row5"); assertEquals(8, countkeys(table)); @@ -1165,7 +1165,7 @@ public class ShellServerIT extends SharedMiniClusterBase { expectedDefault.add("row2 cf1:cq []\t2468ace"); ArrayList<String> actualDefault = new ArrayList<>(4); boolean isFirst = true; - for (String s : ts.exec("scan -np", true).split("[\n\r]+")) { + for (String s : ts.exec("scan", true).split("[\n\r]+")) { if (isFirst) { isFirst = false; } else { @@ -1181,7 +1181,7 @@ public class ShellServerIT extends SharedMiniClusterBase { ts.exec("formatter -t formatter_test -f " + HexFormatter.class.getName(), true); ArrayList<String> actualFormatted = new ArrayList<>(4); isFirst = true; - for (String s : ts.exec("scan -np", true).split("[\n\r]+")) { + for (String s : ts.exec("scan", true).split("[\n\r]+")) { if (isFirst) { isFirst = false; } else { @@ -1292,7 +1292,7 @@ public class ShellServerIT extends SharedMiniClusterBase { @Test public void help() throws Exception { - ts.exec("help -np", true, "Help Commands", true); + ts.exec("help", true, "Help Commands", true); ts.exec("?", true, "Help Commands", true); for (String c : ("bye exit quit about help info ? " + "deleteiter deletescaniter listiter setiter setscaniter " @@ -1376,7 +1376,7 @@ public class ShellServerIT extends SharedMiniClusterBase { ts.exec("createtable " + table, true); ts.exec("notable", true); ts.exec("importdirectory -t " + table + " -i " + importDir + " true", true); - ts.exec("scan -t " + table + " -np -b 0 -e 2", true, "0-->" + nonce, true); + ts.exec("scan -t " + table + " -b 0 -e 2", true, "0-->" + nonce, true); ts.exec("scan -t " + table + " -b 00000098 -e 00000100", true, "99-->" + nonce, true); // Attempt to re-import without -i option, error should occur ts.exec("importdirectory -t " + table + " " + importDir + " true", false); @@ -1661,7 +1661,7 @@ public class ShellServerIT extends SharedMiniClusterBase { sleepUninterruptibly(250, TimeUnit.MILLISECONDS); - ts.exec("scan -np", true, "foo", false); + ts.exec("scan ", true, "foo", false); ts.exec("constraint -a FooConstraint", true); @@ -1771,7 +1771,7 @@ public class ShellServerIT extends SharedMiniClusterBase { } private int countkeys(String table) { - ts.exec("scan -np -t " + table); + ts.exec("scan -t " + table); return ts.output.get().split("\n").length - 1; } @@ -1779,17 +1779,17 @@ public class ShellServerIT extends SharedMiniClusterBase { public void scans() throws Exception { ts.exec("createtable t"); make10(); - String result = ts.exec("scan -np -b row1 -e row1"); + String result = ts.exec("scan -b row1 -e row1"); assertEquals(2, result.split("\n").length); - result = ts.exec("scan -np -b row3 -e row5"); + result = ts.exec("scan -b row3 -e row5"); assertEquals(4, result.split("\n").length); - result = ts.exec("scan -np -r row3"); + result = ts.exec("scan -r row3"); assertEquals(2, result.split("\n").length); - result = ts.exec("scan -np -b row:"); + result = ts.exec("scan -b row:"); assertEquals(1, result.split("\n").length); - result = ts.exec("scan -np -b row"); + result = ts.exec("scan -b row"); assertEquals(11, result.split("\n").length); - result = ts.exec("scan -np -e row:"); + result = ts.exec("scan -e row:"); assertEquals(11, result.split("\n").length); ts.exec("deletetable -f t"); } @@ -1836,21 +1836,21 @@ public class ShellServerIT extends SharedMiniClusterBase { // The implementation of ValueReversingIterator in the FAKE context does nothing, the value is // not reversed. - result = ts.exec("scan -pn baz -np -b row1 -e row1"); + result = ts.exec("scan -pn baz -b row1 -e row1"); assertEquals(2, result.split("\n").length); assertTrue(result.contains("value")); - result = ts.exec("scan -pn baz -np -b row3 -e row5"); + result = ts.exec("scan -pn baz -b row3 -e row5"); assertEquals(4, result.split("\n").length); assertTrue(result.contains("value")); - result = ts.exec("scan -pn baz -np -r row3"); + result = ts.exec("scan -pn baz -r row3"); assertEquals(2, result.split("\n").length); assertTrue(result.contains("value")); - result = ts.exec("scan -pn baz -np -b row:"); + result = ts.exec("scan -pn baz -b row:"); assertEquals(1, result.split("\n").length); - result = ts.exec("scan -pn baz -np -b row"); + result = ts.exec("scan -pn baz -b row"); assertEquals(11, result.split("\n").length); assertTrue(result.contains("value")); - result = ts.exec("scan -pn baz -np -e row:"); + result = ts.exec("scan -pn baz -e row:"); assertEquals(11, result.split("\n").length); assertTrue(result.contains("value")); @@ -1862,25 +1862,25 @@ public class ShellServerIT extends SharedMiniClusterBase { + REAL_CONTEXT + "=" + REAL_CONTEXT_CLASSPATH + "\n", result); // Override the table classloader context with the REAL implementation of // ValueReversingIterator, which does reverse the value. - result = ts.exec("scan -pn baz -np -b row1 -e row1 -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -b row1 -e row1 -cc " + REAL_CONTEXT); assertEquals(2, result.split("\n").length); assertTrue(result.contains("eulav")); assertFalse(result.contains("value")); - result = ts.exec("scan -pn baz -np -b row3 -e row5 -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -b row3 -e row5 -cc " + REAL_CONTEXT); assertEquals(4, result.split("\n").length); assertTrue(result.contains("eulav")); assertFalse(result.contains("value")); - result = ts.exec("scan -pn baz -np -r row3 -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -r row3 -cc " + REAL_CONTEXT); assertEquals(2, result.split("\n").length); assertTrue(result.contains("eulav")); assertFalse(result.contains("value")); - result = ts.exec("scan -pn baz -np -b row: -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -b row: -cc " + REAL_CONTEXT); assertEquals(1, result.split("\n").length); - result = ts.exec("scan -pn baz -np -b row -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -b row -cc " + REAL_CONTEXT); assertEquals(11, result.split("\n").length); assertTrue(result.contains("eulav")); assertFalse(result.contains("value")); - result = ts.exec("scan -pn baz -np -e row: -cc " + REAL_CONTEXT); + result = ts.exec("scan -pn baz -e row: -cc " + REAL_CONTEXT); assertEquals(11, result.split("\n").length); assertTrue(result.contains("eulav")); assertFalse(result.contains("value")); @@ -2046,8 +2046,7 @@ public class ShellServerIT extends SharedMiniClusterBase { private List<String> getFiles(String tableId) { ts.output.clear(); - ts.exec( - "scan -t " + MetadataTable.NAME + " -np -c file -b " + tableId + " -e " + tableId + "~"); + ts.exec("scan -t " + MetadataTable.NAME + " -c file -b " + tableId + " -e " + tableId + "~"); log.debug("countFiles(): {}", ts.output.get());