Skip to content

Add Cross-team search#906

Merged
agarciamontoro merged 4 commits intomasterfrom
MM-63512
Mar 27, 2026
Merged

Add Cross-team search#906
agarciamontoro merged 4 commits intomasterfrom
MM-63512

Conversation

@JulienTant
Copy link
Copy Markdown
Member

@JulienTant JulienTant commented Apr 15, 2025

Summary

todo

Ticket Link

Jira https://mattermost.atlassian.net/browse/MM-63512

Summary by CodeRabbit

  • New Features

    • Added support for cross-team post search functionality in load testing scenarios. This new action enables testing post searches across all teams simultaneously, complementing the existing single-team search capability.
  • Chores

    • Code refactoring and cleanup to support the new search functionality. Minimum server version requirement: 10.7.0.

@JulienTant JulienTant requested a review from Copilot April 15, 2025 21:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds cross-team search functionality by introducing a new "SearchPostsAllTeams" action across multiple controllers and updating corresponding mappings.

  • Updated frequency and added a new search action in loadtest/control/simulcontroller/controller.go
  • Implemented searchPostsAllTeams in both simulcontroller and action definitions and updated simplecontroller mapping
  • Minor formatting cleanups in loadtest/control/actions.go

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
loadtest/control/simulcontroller/controller.go Added a new "SearchPostsAllTeams" action with updated frequency settings
loadtest/control/simulcontroller/actions.go Added the searchPostsAllTeams implementation; changed loop syntax for word generation
loadtest/control/simplecontroller/controller.go Updated action mapping to include "SearchPostsAllTeams"
loadtest/control/actions.go Added a new SearchPostsAllTeams function and removed extraneous whitespace in error checks
Files not reviewed (1)
  • config/simplecontroller.sample.json: Language not supported

@agarciamontoro
Copy link
Copy Markdown
Member

What's the status of this PR, @JulienTant? Do you want me to take a look already?

@JulienTant JulienTant marked this pull request as ready for review May 7, 2025 17:13
@JulienTant JulienTant added the 2: Dev Review Requires review by a core committer label May 7, 2025
@JulienTant JulienTant requested a review from agarciamontoro May 7, 2025 17:13
@JulienTant
Copy link
Copy Markdown
Member Author

What's the status of this PR, @JulienTant? Do you want me to take a look already?

Go ahead! :)

Copy link
Copy Markdown
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 working on this, @JulienTant, and sorry for the delay in the review! I left some comments below with a couple of things to discuss.

Comment on lines +1247 to +1288
func searchPostsAllTeams(u user.User) control.UserActionResponse {
var words []string
var opts control.PostsSearchOpts
// This is an arbitrary limit on the number of words to search for.
// TODO: possibly use user analytics data to improve this.
count := 1 + rand.Intn(4)

if rand.Float64() < 0.2 {
// We limit the search to 7 days.
t := time.Now().Add(-time.Duration(rand.Intn(7)) * time.Hour * 24)
switch rand.Intn(3) {
case 0:
opts.On = t
case 1:
opts.Before = t
case 2:
opts.After = t
}
}

if rand.Float64() < 0.2 {
opts.Excluded = []string{control.PickRandomWord()}
}

if rand.Float64() < 0.2 {
opts.IsPhrase = true
}

for range count {
words = append(words, control.PickRandomWord())
}

term := control.GeneratePostsSearchTerm(words, opts)

list, err := u.SearchPosts("", term, false)
if err != nil {
return control.UserActionResponse{Err: control.NewUserError(err)}
}

return control.UserActionResponse{Info: fmt.Sprintf("found %d posts in all teams", len(list.Posts))}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we refactor the code in this function and in searchPosts out to an util function? Then searchPosts can call it with the ID of the current team and searchPostsAllTeams with an empty string.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah it's reasonable! on it! :)

@JulienTant
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc3bcc58-9d03-44f5-bef9-2a9c3c323939

📥 Commits

Reviewing files that changed from the base of the PR and between 43de7d6 and cc8f176.

📒 Files selected for processing (5)
  • config/simplecontroller.sample.json
  • loadtest/control/actions.go
  • loadtest/control/simplecontroller/controller.go
  • loadtest/control/simulcontroller/actions.go
  • loadtest/control/simulcontroller/controller.go

📝 Walkthrough

Walkthrough

This pull request adds a new cross-team post search action called SearchPostsAllTeams across the load testing framework. The action allows searching posts across all teams by passing an empty team identifier, with corresponding integrations added to configuration, simple controller, and simulated controller components.

Changes

Cohort / File(s) Summary
Configuration
config/simplecontroller.sample.json
Added new action entry with ActionId set to SearchPostsAllTeams, WaitAfterMs of 1000, and RunPeriod of 1.
Core Action Definition
loadtest/control/actions.go
Added new exported function SearchPostsAllTeams() that performs cross-team post search via u.SearchPosts("", "test search", false). Removed stray blank lines from existing post/channel/reaction creation calls.
Simple Controller Integration
loadtest/control/simplecontroller/controller.go
Extended actionMap with new SearchPostsAllTeams mapping to control.SearchPostsAllTeams. Aligned whitespace across existing action mappings.
Simulated Controller Actions
loadtest/control/simulcontroller/actions.go
Refactored searchPosts() into parameterized searchPostsForTeam() helper, added searchPostsAllTeams() wrapper using empty team ID, updated search call to use team parameter, and conditionally disabled autocomplete for cross-team searches. Modernised loop syntax from indexed to range-based iteration.
Simulated Controller Registration
loadtest/control/simulcontroller/controller.go
Added new action entry SearchPostsAllTeams with frequency 0.0109 and minimum server version constraint of 10.7.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Cross-team search' directly and clearly summarizes the main change—adding a new cross-team search capability across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MM-63512
📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.3)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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.

This makes sense to me, @JulienTant, thank you!

@agarciamontoro agarciamontoro merged commit cc7041b into master Mar 27, 2026
2 checks passed
@agarciamontoro agarciamontoro deleted the MM-63512 branch March 27, 2026 10:45
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants