area/ysqlhelp wantedkind/enhancementpriority/mediumstatus/awaiting-triage
描述
Jira Link: DB-18417
Description
side-by-side diff logic (which prints a side-by-side diff of regress test expected/actual output into the test log) does not take alternate expectfiles into account. It just takes the non-alternate expectfile, even if it may not give the best diff. This makes reading the side-by-side diff unreliable for use.
PgRegressRunner.java:
LOG.warn("Failed tests: {}", sortedFailedTests);
for (String testName : sortedFailedTests) {
File expectedFile = new File(new File(pgRegressOutputDir, "expected"), testName + ".out");
File resultFile = new File(new File(pgRegressOutputDir, "results"), testName + ".out");
if (!expectedFile.exists()) {
LOG.warn("Expected test output file {} not found.", expectedFile);
continue;
}
if (!resultFile.exists()) {
LOG.warn("Actual test output file {} not found.", resultFile);
continue;
}
LOG.warn("Side-by-side diff between expected output and actual output of {}:\n{}",
testName, SideBySideDiff.generate(expectedFile, resultFile));
}
On the other hand, PG's logic does take it into account.
pg_regress.c:
if (l < best_line_count)
{
/* This diff was a better match than the last one */
best_line_count = l;
strlcpy(best_expect_file, alt_expectfile, sizeof(best_expect_file));
}
If you are hitting this case, looking at the unified diff above the side-by-side diff is recommended.
Discovered this by looking at failures for test ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressInsertOnConflict#schedule', which is unfortunately flaky right now.
Issue Type
kind/enhancement
Warning: Please confirm that this issue does not contain any sensitive information
- I confirm this issue does not contain any sensitive information.