Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: use database for user creation to prevent flake#10992

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
f0ssel merged 5 commits intomainfromf0ssel/flake-test-paginated-users
Dec 4, 2023

Conversation

f0ssel
Copy link
Contributor

@f0sself0ssel commentedDec 1, 2023
edited
Loading

After speaking with@Emyrk I moved the user creation of these tests to use the database directly to speed things up and do less http requests in order to stay under the 50 second timeout.

Closes#10978

@f0ssel
Copy link
ContributorAuthor

Talked with@Emyrk and I'm gonna take a stab at speeding this test up, he had some ideas here.

Emyrk reacted with heart emoji

@f0sself0ssel marked this pull request as draftDecember 1, 2023 17:51
@f0sself0ssel changed the titlefix: prevent flake by increasing context deadlinefix: prevent flake by using database instead of api for user creationDec 1, 2023
@f0sself0ssel changed the titlefix: prevent flake by using database instead of api for user creationfix: use database for user creation to prevent flakeDec 1, 2023
@f0sself0ssel marked this pull request as ready for reviewDecember 1, 2023 19:28
@f0sself0ssel requested a review fromEmyrkDecember 1, 2023 19:29
@f0ssel
Copy link
ContributorAuthor

I looked at the test data in CI and interestingly this test averages very fast, despite the comments in the code saying otherwise.
image

That being said, I still think if we are timing out at 50 seconds something on the CI box is running out of resources, and moving this to the database will still reduce the test startup burden for this test.

Emyrk reacted with thumbs up emoji

Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

This is probably a good amount faster 👍

Comment on lines 1816 to 1818
for i := range allUsers[:limit] {
require.Equalf(t, page.Users[i].Username, allUsers[i].Username, "first page, limit=%d", limit)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think the original comparisons are better since the new comparisons fail at the first instance, and do not show the lists and the list lengths in the failure output. Switching toassert feels like it might be spammy.

Can we just make a test helper func like:

funconlyUsernames[U codersdk.User| database.User](users []U) []string {varout []stringfor_,u:=rangeusers {switchu:= (any(u)).(type) {case codersdk.User:out=append(out,u.Username)case database.User:out=append(out,u.Username)}}returnout}

Then we can bring back the old requires.

require.Equalf(t,onlyUsernames(page.Users),onlyUsernames(allUsers[:limit]),"first page, limit=%d",limit)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sounds good to me, good idea. I have yet to really use generics, this will be fun.

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit of a hack since I cast toany in the function 😄

It just gives type safety on the call arguments.

@f0sself0ssel requested a review fromEmyrkDecember 4, 2023 14:03
@Emyrk
Copy link
Member

I looked at the test data in CI and interestingly this test averages very fast, despite the comments in the code saying otherwise.

This is definitely subjective, but I think >100ms is on the slower side for our tests. Is it something to be concerned about? Idk, probably not.

@f0sself0ssel merged commitccd5e1a intomainDec 4, 2023
@f0sself0ssel deleted the f0ssel/flake-test-paginated-users branchDecember 4, 2023 16:05
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsDec 4, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk approved these changes

Assignees

@f0sself0ssel

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

flake: TestPaginatedUsers
2 participants
@f0ssel@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp