summaryrefslogtreecommitdiffstats
path: root/api/channel_benchmark_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-09-30 11:06:30 -0400
committerGitHub <noreply@github.com>2016-09-30 11:06:30 -0400
commit8a0e649f989a824bb3bbfd1900a5b8e5383b47e1 (patch)
tree4b424929fe13ebec438d2f41a2729e37e5160720 /api/channel_benchmark_test.go
parenta2deeed597dea15d9b7ca237be71988469f58cdd (diff)
downloadchat-8a0e649f989a824bb3bbfd1900a5b8e5383b47e1.tar.gz
chat-8a0e649f989a824bb3bbfd1900a5b8e5383b47e1.tar.bz2
chat-8a0e649f989a824bb3bbfd1900a5b8e5383b47e1.zip
PLT-3105 Files table migration (#4068)
* Implemented initial changes for files table * Removed *_benchmark_test.go files * Re-implemented GetPublicFile and added support for old path * Localization for files table * Moved file system code into utils package * Finished server-side changes and added initial upgrade script * Added getPostFiles api * Re-add Extension and HasPreviewImage fields to FileInfo * Removed unused translation * Fixed merge conflicts left over after permissions changes * Forced FileInfo.extension to be lower case * Changed FileUploadResponse to contain the FileInfos instead of FileIds * Fixed permissions on getFile* calls * Fixed notifications for file uploads * Added initial version of client code for files changes * Permanently added FileIds field to Post object and removed Post.HasFiles * Updated PostStore.Update to be usable in more circumstances * Re-added Filenames field and switched file migration to be entirely lazy-loaded * Increased max listener count for FileStore * Removed unused fileInfoCache * Moved file system code back into api * Removed duplicate test case * Fixed unit test running on ports other than 8065 * Renamed HasPermissionToPostContext to HasPermissionToChannelByPostContext * Refactored handleImages to make it more easily understandable * Renamed getPostFiles to getFileInfosForPost * Re-added pre-FileIds posts to analytics * Changed files to be saved as their ids as opposed to id/filename.ext * Renamed FileInfo.UserId to FileInfo.CreatorId * Fixed detection of language in CodePreview * Fixed switching between threads in the RHS not loading new files * Add serverside protection against a rare bug where the client sends the same file twice for a single post * Refactored the important parts of uploadFile api call into a function that can be called without a web context
Diffstat (limited to 'api/channel_benchmark_test.go')
-rw-r--r--api/channel_benchmark_test.go284
1 files changed, 0 insertions, 284 deletions
diff --git a/api/channel_benchmark_test.go b/api/channel_benchmark_test.go
deleted file mode 100644
index 569c2dcc0..000000000
--- a/api/channel_benchmark_test.go
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package api
-
-import (
- "github.com/mattermost/platform/model"
- "github.com/mattermost/platform/store"
- "github.com/mattermost/platform/utils"
- "testing"
-)
-
-const (
- NUM_CHANNELS = 140
- NUM_USERS = 40
-)
-
-func BenchmarkCreateChannel(b *testing.B) {
- th := Setup().InitBasic()
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- channelCreator.CreateTestChannels(utils.Range{NUM_CHANNELS, NUM_CHANNELS})
- }
-}
-
-func BenchmarkCreateDirectChannel(b *testing.B) {
- th := Setup().InitBasic()
-
- userCreator := NewAutoUserCreator(th.BasicClient, th.BasicTeam)
- users, err := userCreator.CreateTestUsers(utils.Range{NUM_USERS, NUM_USERS})
- if err == false {
- b.Fatal("Could not create users")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := 0; j < NUM_USERS; j++ {
- th.BasicClient.CreateDirectChannel(users[j].Id)
- }
- }
-}
-
-func BenchmarkUpdateChannel(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- CHANNEL_HEADER_LEN = 50
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- for i := range channels {
- channels[i].Header = utils.RandString(CHANNEL_HEADER_LEN, utils.ALPHANUMERIC)
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range channels {
- if _, err := th.BasicClient.UpdateChannel(channels[j]); err != nil {
- b.Fatal(err)
- }
- }
- }
-}
-
-func BenchmarkGetChannels(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- _, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- th.BasicClient.Must(th.BasicClient.GetChannels(""))
- }
-}
-
-func BenchmarkGetMoreChannels(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- _, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- th.BasicClient.Must(th.BasicClient.GetMoreChannels(""))
- }
-}
-
-func BenchmarkJoinChannel(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- // Secondary test user to join channels created by primary test user
- user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "That Guy", Password: "pwd"}
- user = th.BasicClient.Must(th.BasicClient.CreateUser(user, "")).Data.(*model.User)
- LinkUserToTeam(user, th.BasicTeam)
- store.Must(Srv.Store.User().VerifyEmail(user.Id))
- th.BasicClient.Login(user.Email, "pwd")
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range channels {
- th.BasicClient.Must(th.BasicClient.JoinChannel(channels[j].Id))
- }
- }
-}
-
-func BenchmarkDeleteChannel(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range channels {
- th.BasicClient.Must(th.BasicClient.DeleteChannel(channels[j].Id))
- }
- }
-}
-
-func BenchmarkGetChannelExtraInfo(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range channels {
- th.BasicClient.Must(th.BasicClient.GetChannelExtraInfo(channels[j].Id, -1, ""))
- }
- }
-}
-
-func BenchmarkAddChannelMember(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_USERS = 100
- NUM_USERS_RANGE = utils.Range{NUM_USERS, NUM_USERS}
- )
-
- channel := &model.Channel{DisplayName: "Test Channel", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}
- channel = th.BasicClient.Must(th.BasicClient.CreateChannel(channel)).Data.(*model.Channel)
-
- userCreator := NewAutoUserCreator(th.BasicClient, th.BasicTeam)
- users, valid := userCreator.CreateTestUsers(NUM_USERS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test users")
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range users {
- if _, err := th.BasicClient.AddChannelMember(channel.Id, users[j].Id); err != nil {
- b.Fatal(err)
- }
- }
- }
-}
-
-// Is this benchmark failing? Raise your file ulimit! 2048 worked for me.
-func BenchmarkRemoveChannelMember(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_USERS = 140
- NUM_USERS_RANGE = utils.Range{NUM_USERS, NUM_USERS}
- )
-
- channel := &model.Channel{DisplayName: "Test Channel", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}
- channel = th.BasicClient.Must(th.BasicClient.CreateChannel(channel)).Data.(*model.Channel)
-
- userCreator := NewAutoUserCreator(th.BasicClient, th.BasicTeam)
- users, valid := userCreator.CreateTestUsers(NUM_USERS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test users")
- }
-
- for i := range users {
- if _, err := th.BasicClient.AddChannelMember(channel.Id, users[i].Id); err != nil {
- b.Fatal(err)
- }
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range users {
- if _, err := th.BasicClient.RemoveChannelMember(channel.Id, users[j].Id); err != nil {
- b.Fatal(err)
- }
- }
- }
-}
-
-func BenchmarkUpdateNotifyProps(b *testing.B) {
- th := Setup().InitBasic()
-
- var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- )
-
- channelCreator := NewAutoChannelCreator(th.BasicClient, th.BasicTeam)
- channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
- if valid == false {
- b.Fatal("Unable to create test channels")
- }
-
- data := make([]map[string]string, len(channels))
-
- for i := range data {
- newmap := map[string]string{
- "channel_id": channels[i].Id,
- "user_id": th.BasicUser.Id,
- "desktop": model.CHANNEL_NOTIFY_MENTION,
- "mark_unread": model.CHANNEL_MARK_UNREAD_MENTION,
- }
- data[i] = newmap
- }
-
- // Benchmark Start
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range channels {
- th.BasicClient.Must(th.BasicClient.UpdateNotifyProps(data[j]))
- }
- }
-}