-
Notifications
You must be signed in to change notification settings - Fork 41
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
base: master
Are you sure you want to change the base?
[MM-46554] Add load test functionality for global drafts #527
Conversation
@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 😄 |
Hey, @mylonsuren, anything else we can help with to get this ready for review? |
@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 |
There was a problem hiding this comment.
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
numFiles := len(fileIds) | ||
for i := 0; i < numFiles; i++ { | ||
draft.FileIds = append(draft.FileIds, <-fileIds) | ||
} | ||
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as earlier
{ | ||
run: c.upsertDraft, | ||
frequency: 0.615, | ||
}, | ||
{ | ||
run: c.getDrafts, | ||
frequency: 0.555, | ||
}, | ||
{ | ||
run: c.deleteDraft, | ||
frequency: 1.5, | ||
}, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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{} |
There was a problem hiding this comment.
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.
{ | ||
run: c.upsertDraft, | ||
frequency: 0.615, | ||
}, | ||
{ | ||
run: c.getDrafts, | ||
frequency: 0.555, | ||
}, | ||
{ | ||
run: c.deleteDraft, | ||
frequency: 1.5, | ||
}, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
draftId, err := s.RandomDraftForTeam(teamId) | ||
require.NoError(t, err) | ||
require.Equal(t, draft.ChannelId, draftId) |
There was a problem hiding this comment.
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]
draftId2, err := s.RandomDraftForTeam(teamId2) | ||
require.NoError(t, err) | ||
require.Equal(t, draft2.RootId, draftId2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
draftId, err := s.RandomDraftForTeam(teamId) | ||
require.NoError(t, err) | ||
require.Equal(t, draft.ChannelId, draftId) |
There was a problem hiding this comment.
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.
draftId2, err := s.RandomDraftForTeam(teamId2) | ||
require.NoError(t, err) | ||
require.Equal(t, draft2.RootId, draftId2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same here.
{ | ||
run: c.upsertDraft, | ||
frequency: 0.615, | ||
}, | ||
{ | ||
run: c.getDrafts, | ||
frequency: 0.555, | ||
}, | ||
{ | ||
run: c.deleteDraft, | ||
frequency: 1.5, | ||
}, |
There was a problem hiding this comment.
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.
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
:( I will address all comments here so we can merge this PR. |
Ah this is indeed unfortunate, hopefully you'll have the time to get this merged. No rush, this is not a priority. |
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! |
Summary
Adds load test coverage for drafts.
Ticket Link
https://mattermost.atlassian.net/browse/MM-46554