Skip to content

Commit

Permalink
test: fix test performance flaky test (#3316)
Browse files Browse the repository at this point in the history
Test performance writing to file was checking for the score, even though some tests are based on current machine's measurements. We have excluded testing measurements for a single test, but not for the overall score.

category: test
ticket: none
  • Loading branch information
KaloyanTanev authored and pinebit committed Oct 18, 2024
1 parent 7812920 commit b0046c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/testpeers_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,15 @@ func testWriteFile(t *testing.T, expectedRes testCategoryResult, path string) {
require.NoError(t, err)

require.Equal(t, expectedRes.CategoryName, res.CategoryName)
require.Equal(t, expectedRes.Score, res.Score)
require.Equal(t, len(expectedRes.Targets), len(res.Targets))
checkFinalScore := true
for targetName, testResults := range res.Targets {
for idx, testRes := range testResults {
// do not test verdicts based on measurements
if expectedRes.Targets[targetName][idx].Verdict == testVerdictOk || expectedRes.Targets[targetName][idx].Verdict == testVerdictFail {
require.Equal(t, expectedRes.Targets[targetName][idx].Verdict, testRes.Verdict)
} else {
checkFinalScore = false
}
require.Equal(t, expectedRes.Targets[targetName][idx].IsAcceptable, testRes.IsAcceptable)
if expectedRes.Targets[targetName][idx].Error.error != nil {
Expand All @@ -402,6 +404,10 @@ func testWriteFile(t *testing.T, expectedRes testCategoryResult, path string) {
require.Equal(t, expectedRes.Targets[targetName][idx].Suggestion, testRes.Suggestion)
}
}
// check final score only if there are no tests based on actual measurement
if checkFinalScore {
require.Equal(t, expectedRes.Score, res.Score)
}
}

func startPeer(t *testing.T, conf testPeersConfig, peerPrivKey *k1.PrivateKey) enr.Record {
Expand Down

0 comments on commit b0046c7

Please sign in to comment.