github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/command_loadtest_test.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package api
     5  
     6  import (
     7  	"strings"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/mattermost/mattermost-server/model"
    12  )
    13  
    14  func TestLoadTestHelpCommands(t *testing.T) {
    15  	th := Setup().InitBasic()
    16  	defer th.TearDown()
    17  
    18  	Client := th.BasicClient
    19  	channel := th.BasicChannel
    20  
    21  	th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
    22  
    23  	rs := Client.Must(Client.Command(channel.Id, "/test help")).Data.(*model.CommandResponse)
    24  	if !strings.Contains(rs.Text, "Mattermost testing commands to help") {
    25  		t.Fatal(rs.Text)
    26  	}
    27  
    28  	time.Sleep(2 * time.Second)
    29  }
    30  
    31  func TestLoadTestSetupCommands(t *testing.T) {
    32  	th := Setup().InitBasic()
    33  	defer th.TearDown()
    34  
    35  	Client := th.BasicClient
    36  	channel := th.BasicChannel
    37  
    38  	th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
    39  
    40  	rs := Client.Must(Client.Command(channel.Id, "/test setup fuzz 1 1 1")).Data.(*model.CommandResponse)
    41  	if rs.Text != "Created environment" {
    42  		t.Fatal(rs.Text)
    43  	}
    44  
    45  	time.Sleep(2 * time.Second)
    46  }
    47  
    48  func TestLoadTestUsersCommands(t *testing.T) {
    49  	th := Setup().InitBasic()
    50  	defer th.TearDown()
    51  
    52  	Client := th.BasicClient
    53  	channel := th.BasicChannel
    54  
    55  	th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
    56  
    57  	rs := Client.Must(Client.Command(channel.Id, "/test users fuzz 1 2")).Data.(*model.CommandResponse)
    58  	if rs.Text != "Added users" {
    59  		t.Fatal(rs.Text)
    60  	}
    61  
    62  	time.Sleep(2 * time.Second)
    63  }
    64  
    65  func TestLoadTestChannelsCommands(t *testing.T) {
    66  	th := Setup().InitBasic()
    67  	defer th.TearDown()
    68  
    69  	Client := th.BasicClient
    70  	channel := th.BasicChannel
    71  
    72  	th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
    73  
    74  	rs := Client.Must(Client.Command(channel.Id, "/test channels fuzz 1 2")).Data.(*model.CommandResponse)
    75  	if rs.Text != "Added channels" {
    76  		t.Fatal(rs.Text)
    77  	}
    78  
    79  	time.Sleep(2 * time.Second)
    80  }
    81  
    82  func TestLoadTestPostsCommands(t *testing.T) {
    83  	th := Setup().InitBasic()
    84  	defer th.TearDown()
    85  
    86  	Client := th.BasicClient
    87  	channel := th.BasicChannel
    88  
    89  	th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
    90  
    91  	rs := Client.Must(Client.Command(channel.Id, "/test posts fuzz 2 3 2")).Data.(*model.CommandResponse)
    92  	if rs.Text != "Added posts" {
    93  		t.Fatal(rs.Text)
    94  	}
    95  
    96  	time.Sleep(2 * time.Second)
    97  }