Skip to content

Commit

Permalink
Merge pull request #1217 from michelle192837/truncate
Browse files Browse the repository at this point in the history
Remove empty results from truncation column.
  • Loading branch information
google-oss-prow[bot] authored Jun 1, 2023
2 parents 6fdbeb5 + 0fc77aa commit 9d3ceba
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,9 @@ func truncateLastColumn(grid []InflatedColumn, orig, max int, entity string) {
delete(grid[last].Cells, truncatedRowName)
continue
}
if cell.Result == statuspb.TestStatus_NO_RESULT {
continue
}
cell.Result = statuspb.TestStatus_UNKNOWN
cell.Message = fmt.Sprintf("%d %s grid exceeds maximum size of %d %ss", orig, entity, max, entity)
cell.Icon = "..." // Overwritten by the UI
Expand Down
81 changes: 81 additions & 0 deletions pkg/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,87 @@ func Test_ShrinkGridInline(t *testing.T) {
return constructGridFromGroupConfig(logger, tg, expect, issues)
},
},
{
name: "truncate sparse column data",
tg: &configpb.TestGroup{},
cols: []InflatedColumn{
{
Column: &statepb.Column{
Name: "one",
Build: "one",
},
Cells: map[string]Cell{
"row-0": {
Result: statuspb.TestStatus_FAIL,
},
"row-1": {
Result: statuspb.TestStatus_NO_RESULT,
},
"row-2": {
Result: statuspb.TestStatus_NO_RESULT,
},
},
},
{
Column: &statepb.Column{
Name: "two",
Build: "two",
},
Cells: func() map[string]Cell {
cells := map[string]Cell{}

for i := 0; i < 100; i++ {
cells[fmt.Sprintf("row-%d", i)] = Cell{
Result: statuspb.TestStatus_FAIL,
}
}
return cells
}(),
},
{
Column: &statepb.Column{
Name: "three",
Build: "three",
},
Cells: map[string]Cell{
"row-0": {
Result: statuspb.TestStatus_FAIL,
},
"row-1": {
Result: statuspb.TestStatus_FAIL,
},
"row-2": {
Result: statuspb.TestStatus_FAIL,
},
},
},
},
ceiling: 200,
want: func(tg *configpb.TestGroup, cols []InflatedColumn, issues map[string][]string) *statepb.Grid {
expect := []InflatedColumn{
// Drop the rows that are empty after trimming (e.g. row-1 and row-2).
{
Column: &statepb.Column{
Name: "one",
Build: "one",
},
Cells: map[string]Cell{
"row-0": {
Result: statuspb.TestStatus_FAIL,
},
},
},
}
logger := logrus.New()
grid := constructGridFromGroupConfig(logger, tg, cols, issues)
buf, _ := gcs.MarshalGrid(grid)
orig := len(buf)

truncateLastColumn(expect, orig, 200, "byte")

return constructGridFromGroupConfig(logger, tg, expect, issues)
},
},
{
name: "delete most column data",
tg: &configpb.TestGroup{},
Expand Down

0 comments on commit 9d3ceba

Please sign in to comment.