main_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package main
  2. import (
  3. "f1-game/tool/client-cli/cli"
  4. "fmt"
  5. "math/rand"
  6. "sync"
  7. "testing"
  8. "time"
  9. cherryHttp "github.com/cherry-game/cherry/extend/http"
  10. )
  11. func TestRegisterDevAccount(t *testing.T) {
  12. var (
  13. url = "http://172.16.124.91"
  14. )
  15. accountList := make(map[string]string)
  16. for i := 1; i <= 10000; i++ {
  17. key := fmt.Sprintf("susu%d", i)
  18. accountList[key] = key
  19. }
  20. cli.RegisterDevAccounts(url, accountList)
  21. }
  22. func TestConnect(t *testing.T) {
  23. var (
  24. url = "http://172.16.124.91"
  25. addr = "172.16.124.91:21000"
  26. pid = "2188001"
  27. )
  28. wg := sync.WaitGroup{}
  29. wg.Add(1)
  30. maxAccountNum := 100000
  31. accountList := make(map[string]string)
  32. for i := 1; i <= maxAccountNum; i++ {
  33. key := fmt.Sprintf("test%d", i)
  34. accountList[key] = key
  35. }
  36. for userName, password := range accountList {
  37. time.Sleep(time.Duration(rand.Int31n(5)) * time.Millisecond)
  38. go cli.RunRobotConnect(url, pid, userName, password, addr)
  39. }
  40. wg.Wait()
  41. }
  42. func BenchmarkCenterPing(b *testing.B) {
  43. reqURL := "http://127.0.0.1/test/ping-center"
  44. for i := 0; i < b.N; i++ {
  45. cherryHttp.GET(reqURL)
  46. }
  47. }