Fixes random failures of org.apache.elasticsearch.test.rest.RestIT
RestTable: ignores right padding for the last cell of a column.
This commit is contained in:
parent
d866906612
commit
23aeaa88b2
|
@ -79,8 +79,9 @@ public class RestTable {
|
|||
if (verbose) {
|
||||
for (int col = 0; col < headers.size(); col++) {
|
||||
DisplayHeader header = headers.get(col);
|
||||
pad(new Table.Cell(header.display, table.findHeaderByName(header.name)), width[col], request, out);
|
||||
if (col != lastHeader) {
|
||||
boolean isLastColumn = col == lastHeader;
|
||||
pad(new Table.Cell(header.display, table.findHeaderByName(header.name)), width[col], request, out, isLastColumn);
|
||||
if (!isLastColumn) {
|
||||
out.append(" ");
|
||||
}
|
||||
}
|
||||
|
@ -89,8 +90,9 @@ public class RestTable {
|
|||
for (int row = 0; row < table.getRows().size(); row++) {
|
||||
for (int col = 0; col < headers.size(); col++) {
|
||||
DisplayHeader header = headers.get(col);
|
||||
pad(table.getAsMap().get(header.name).get(row), width[col], request, out);
|
||||
if (col != lastHeader) {
|
||||
boolean isLastColumn = col == lastHeader;
|
||||
pad(table.getAsMap().get(header.name).get(row), width[col], request, out, isLastColumn);
|
||||
if (!isLastColumn) {
|
||||
out.append(" ");
|
||||
}
|
||||
}
|
||||
|
@ -240,6 +242,10 @@ public class RestTable {
|
|||
}
|
||||
|
||||
public static void pad(Table.Cell cell, int width, RestRequest request, UTF8StreamWriter out) throws IOException {
|
||||
pad(cell, width, request, out, false);
|
||||
}
|
||||
|
||||
public static void pad(Table.Cell cell, int width, RestRequest request, UTF8StreamWriter out, boolean isLast) throws IOException {
|
||||
String sValue = renderValue(request, cell.value);
|
||||
int length = sValue == null ? 0 : sValue.length();
|
||||
byte leftOver = (byte) (width - length);
|
||||
|
@ -258,8 +264,11 @@ public class RestTable {
|
|||
if (sValue != null) {
|
||||
out.append(sValue);
|
||||
}
|
||||
for (byte i = 0; i < leftOver; i++) {
|
||||
out.append(" ");
|
||||
// Ignores the leftover spaces if the cell is the last of the column.
|
||||
if (!isLast) {
|
||||
for (byte i = 0; i < leftOver; i++) {
|
||||
out.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,6 @@
|
|||
- match:
|
||||
$body: |
|
||||
/^
|
||||
index \s+ alias \s+ \n
|
||||
index \s+ alias \n
|
||||
test \s+ test_1 \n
|
||||
$/
|
||||
|
|
|
@ -156,7 +156,7 @@
|
|||
disk.percent \s+
|
||||
host \s+
|
||||
ip \s+
|
||||
node \s+
|
||||
node
|
||||
\n
|
||||
|
||||
( \s* #allow leading spaces to account for right-justified text
|
||||
|
@ -199,7 +199,7 @@
|
|||
$body: |
|
||||
/^
|
||||
disk.percent \s+
|
||||
node \s+
|
||||
node
|
||||
\n
|
||||
(
|
||||
\s+\d* \s+
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
- match:
|
||||
$body: |
|
||||
/# epoch timestamp count
|
||||
^ \d+ \s \d{2}:\d{2}:\d{2} \s 0 \n $/
|
||||
^ \d+ \s \d{2}:\d{2}:\d{2} \s 0 \n$/
|
||||
|
||||
- do:
|
||||
index:
|
||||
|
@ -72,5 +72,4 @@
|
|||
- match:
|
||||
$body: |
|
||||
/^ epoch \s+ timestamp \s+ count \n
|
||||
\d+ \s+ \d{2}:\d{2}:\d{2} \s+ \d+ \s+ \n $/
|
||||
|
||||
\d+ \s+ \d{2}:\d{2}:\d{2} \s+ \d+ \n $/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/^ host \s+ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load \s+ node\.role \s+ master \s+ name \s+ \n
|
||||
/^ host \s+ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load \s+ node\.role \s+ master \s+ name \n
|
||||
(\S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ \d* \s+ (-)?\d*(\.\d+)? \s+ [-dc] \s+ [-*mx] \s+ (\S+\s?)+ \n)+ $/
|
||||
|
||||
- do:
|
||||
|
|
Loading…
Reference in New Issue