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

[MM-46554] Add load test functionality for global drafts #527

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mylonsuren
Copy link

@mylonsuren mylonsuren commented Dec 2, 2022

Summary

Adds load test coverage for drafts.

Ticket Link

https://mattermost.atlassian.net/browse/MM-46554

@mylonsuren mylonsuren added the Work In Progress Not yet ready for review label Dec 2, 2022
@mylonsuren mylonsuren self-assigned this Dec 2, 2022
@agnivade
Copy link
Member

agnivade commented Dec 6, 2022

@mylonsuren - just checking on the status for this. What else is pending here?

@mylonsuren
Copy link
Author

@mylonsuren - just checking on the status for this. What else is pending here?

@agnivade Not much, I just need to add coverage for deleting drafts and update the frequencies. Currently have some other high priority tasks in front of this, will update this PR in the coming days and get some reviews then 😄

@agarciamontoro
Copy link
Member

Hey, @mylonsuren, anything else we can help with to get this ready for review?

@mylonsuren mylonsuren marked this pull request as ready for review January 30, 2023 16:09
@mylonsuren mylonsuren added 2: Dev Review Requires review by a core committer and removed Work In Progress Not yet ready for review labels Jan 30, 2023
@mylonsuren
Copy link
Author

@agarciamontoro @agnivade Sorry for the delay on this, I think it's at a point now where it can get some reviews 😄

@@ -17,6 +17,7 @@ WorkingDirectory=/opt/mattermost
User=ubuntu
Group=ubuntu
LimitNOFILE=49152
Environment=MM_FEATUREFLAGS_GlobalDrafts
Copy link
Member

Choose a reason for hiding this comment

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

We need to append =true at the end

Comment on lines +810 to +814
numFiles := len(fileIds)
for i := 0; i < numFiles; i++ {
draft.FileIds = append(draft.FileIds, <-fileIds)
}

Copy link
Member

Choose a reason for hiding this comment

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

This is a complicated way to achieve this. We can just have a slice of fileIds and let each goroutine set the fileId at separate indices of that slice. That's perfectly valid and not a race condition. And then just append that slice to draft.FileIds

userId := u.Store().Id()

team, err := u.Store().CurrentTeam()
if errors.Is(err, memstore.ErrTeamStoreEmpty) {
Copy link
Member

Choose a reason for hiding this comment

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

This is only returned from Store().RandomTeam(), so no need to check it here

Message: message,
ChannelId: channel.Id,
RootId: rootId,
CreateAt: time.Now().Unix() * 1000,
Copy link
Member

Choose a reason for hiding this comment

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

Use model.GetMillis

var rootId = ""

// 33% of the time draft will be a thread reply
if rand.Float64() < 0.33 {
Copy link
Member

Choose a reason for hiding this comment

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

How was this derived?

}

team, err := u.Store().CurrentTeam()
if errors.Is(err, memstore.ErrTeamStoreEmpty) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as earlier

Comment on lines +237 to +248
{
run: c.upsertDraft,
frequency: 0.615,
},
{
run: c.getDrafts,
frequency: 0.555,
},
{
run: c.deleteDraft,
frequency: 1.5,
},
Copy link
Member

Choose a reason for hiding this comment

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

Are all of these calculated from community metrics?

Copy link
Member

Choose a reason for hiding this comment

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

As per data from last week, the frequencies should be something more like:

upsertDrafts: 1.5 * 0.622 = 0.933
getDrafts:    1.5 * 0.376 = 0.564
deleteDraft:  1.5 * 1.17  = 1.755

Copy link
Member

Choose a reason for hiding this comment

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

Also, can we use the minServerVersion field in these actions? We should add that from now on to all new actions, and I want to start adding them to the current ones as well.

Copy link
Member

@agarciamontoro agarciamontoro left a comment

Choose a reason for hiding this comment

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

Thank you for this, @mylonsuren, it's great :) I left some comments to tackle, but the approach is flawless, thank you!

s.lock.Lock()
defer s.lock.Unlock()

s.drafts[teamId] = map[string]*model.Draft{}
Copy link
Member

Choose a reason for hiding this comment

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

Here we override the whole team drafts every time. Is that intended? If so, we should specify it in the function documentation.

Comment on lines +237 to +248
{
run: c.upsertDraft,
frequency: 0.615,
},
{
run: c.getDrafts,
frequency: 0.555,
},
{
run: c.deleteDraft,
frequency: 1.5,
},
Copy link
Member

Choose a reason for hiding this comment

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

As per data from last week, the frequencies should be something more like:

upsertDrafts: 1.5 * 0.622 = 0.933
getDrafts:    1.5 * 0.376 = 0.564
deleteDraft:  1.5 * 1.17  = 1.755

return control.UserActionResponse{Info: fmt.Sprintf("no drafts found in team %v", team.Id)}
}

err = u.DeleteDraft(channel.Id, draftId)
Copy link
Member

Choose a reason for hiding this comment

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

Here, channel.Id and draftId` may be the same ID if the draft is a root post, right? I understand that is correct, but I wanted to double-check, this rootid-channelid for drafts was a bit confusing for me at first.

Comment on lines +797 to +799
draftId, err := s.RandomDraftForTeam(teamId)
require.NoError(t, err)
require.Equal(t, draft.ChannelId, draftId)
Copy link
Member

Choose a reason for hiding this comment

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

We can actually check the store directly, with s.drafts[teamId]

Comment on lines +811 to +813
draftId2, err := s.RandomDraftForTeam(teamId2)
require.NoError(t, err)
require.Equal(t, draft2.RootId, draftId2)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

Comment on lines +837 to +839
draftId, err := s.RandomDraftForTeam(teamId)
require.NoError(t, err)
require.Equal(t, draft.ChannelId, draftId)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment. And here it'd actually let you to add more than one draft to check that the whole set is added.

Comment on lines +851 to +853
draftId2, err := s.RandomDraftForTeam(teamId2)
require.NoError(t, err)
require.Equal(t, draft2.RootId, draftId2)
Copy link
Member

Choose a reason for hiding this comment

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

And same here.

Comment on lines +237 to +248
{
run: c.upsertDraft,
frequency: 0.615,
},
{
run: c.getDrafts,
frequency: 0.555,
},
{
run: c.deleteDraft,
frequency: 1.5,
},
Copy link
Member

Choose a reason for hiding this comment

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

Also, can we use the minServerVersion field in these actions? We should add that from now on to all new actions, and I want to start adding them to the current ones as well.

@mattermost-build
Copy link

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@agarciamontoro
Copy link
Member

:( I will address all comments here so we can merge this PR.

@agnivade
Copy link
Member

Ah this is indeed unfortunate, hopefully you'll have the time to get this merged. No rush, this is not a priority.

@agnivade
Copy link
Member

agnivade commented Mar 8, 2024

Sad that it's been lying for a year. Let's see if I can find some time to clean this up.

@agarciamontoro
Copy link
Member

agarciamontoro commented Mar 8, 2024

Sad that it's been lying for a year. Let's see if I can find some time to clean this up.

I've been wanting to get this merged since last year, but there was always something more urgent in the queue. Very glad if you want to tackle it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer Lifecycle/1:stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants