Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests #369

Merged
merged 4 commits into from
May 3, 2024
Merged

Fix flaky tests #369

merged 4 commits into from
May 3, 2024

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented May 1, 2024

What this PR does / why we need it:
Due to backend.Responses being a map, we end up getting the services/operations in an inconsistent order when we have multiple responses. This makes some of the tests flaky (test 1 and test 2). One fix for that is just sorting the operations and services (done in this pr), though if we think that's too expensive (I don't think we should have that many of them?) we could also try to rework the tests, though considering that one of them involves checking a big json string that could either be a bit complex or just involve not using 2 responses (though that reduces the test coverage).

The other change was to avoid a seg fault in TestProcessTraceListAndTraceSpansResponse, which was happening because the helper that generated the test queries used a map and was unordered. Changed to an array.

Which issue(s) this PR fixes:

Fixes #368

Special notes for your reviewer:

@iwysiu iwysiu changed the title Sort operations and services before adding them to the query model Sort operations when processing service map parameters May 1, 2024
@iwysiu iwysiu changed the title Sort operations when processing service map parameters Fix test failures May 1, 2024
body string
}

func createDataQueriesForTests(tsdbQueries []tsdbQuery) []backend.DataQuery {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively I could create a second helper that takes an array, but the map sort of implies that it should take multiple queries.

"name": "HTTP GET /dispatch",
"startTime": "2023-10-18T07:58:37.818589Z",
"links": [],
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just changed the indents on this to be easier to read.

@iwysiu iwysiu changed the title Fix test failures Fix flaky tests May 1, 2024
@iwysiu iwysiu marked this pull request as ready for review May 1, 2024 20:12
@iwysiu iwysiu requested a review from a team as a code owner May 1, 2024 20:12
@iwysiu iwysiu requested review from sarahzinger and kevinwcyu and removed request for a team May 1, 2024 20:12
operations := make([]string, 0, len(operationMap))
for op := range operationMap {
operations = append(operations, op)
}
slices.Sort(operations)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like if sorting the operations benefitted users in someway it might make sense to do this, but if I understand correctly this is always going to be rendered as a graph where sorting won't really matter. I would vote we try sorting in the test if that's possible?

@iwysiu iwysiu merged commit d753ad7 into main May 3, 2024
4 checks passed
@iwysiu iwysiu deleted the sort-operations branch May 3, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix flaky node graph tests
3 participants