예제 #1
0
func BenchmarkUpdateChannel(b *testing.B) {
	var (
		NUM_CHANNELS_RANGE      = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
		CHANNEL_DESCRIPTION_LEN = 50
	)
	team, _, _ := SetupBenchmark()

	channelCreator := NewAutoChannelCreator(Client, team.Id)
	channels, valid := channelCreator.CreateTestChannels(NUM_CHANNELS_RANGE)
	if valid == false {
		b.Fatal("Unable to create test channels")
	}

	for i := range channels {
		channels[i].Description = utils.RandString(CHANNEL_DESCRIPTION_LEN, utils.ALPHANUMERIC)
	}

	// Benchmark Start
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		for j := range channels {
			if _, err := Client.UpdateChannel(channels[j]); err != nil {
				b.Fatal(err)
			}
		}
	}
}
예제 #2
0
func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) {
	var userEmail string
	var userName string
	if cfg.Fuzzy {
		userEmail = utils.RandString(FUZZ_USER_EMAIL_PREFIX_LEN, utils.LOWERCASE) + "-" + utils.FuzzEmail()
		userName = utils.FuzzName()
	} else {
		userEmail = utils.RandomEmail(cfg.EmailLength, cfg.EmailCharset)
		userName = utils.RandomName(cfg.NameLength, cfg.NameCharset)
	}

	user := &model.User{
		TeamId:   cfg.teamID,
		Email:    userEmail,
		Nickname: userName,
		Password: USER_PASSWORD}

	result, err := cfg.client.CreateUser(user, "")
	if err != nil {
		return nil, false
	}
	// We need to cheat to verify the user's email
	store.Must(Srv.Store.User().VerifyEmail(result.Data.(*model.User).Id))
	return result.Data.(*model.User), true
}
예제 #3
0
func BenchmarkUpdatePost(b *testing.B) {
	var (
		NUM_POSTS_RANGE = utils.Range{NUM_POSTS, NUM_POSTS}
		UPDATE_POST_LEN = 100
	)
	_, _, channel := SetupBenchmark()

	testPoster := NewAutoPostCreator(Client, channel.Id)
	posts, valid := testPoster.CreateTestPosts(NUM_POSTS_RANGE)
	if valid == false {
		b.Fatal("Unable to create test posts")
	}

	for i := range posts {
		posts[i].Message = utils.RandString(UPDATE_POST_LEN, utils.ALPHANUMERIC)
	}

	// Benchmark Start
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		for i := range posts {
			if _, err := Client.UpdatePost(posts[i]); err != nil {
				b.Fatal(err)
			}
		}
	}
}
예제 #4
0
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)
			}
		}
	}
}