main_su_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package main
  2. import (
  3. "f1-game/tool/client-cli/cli"
  4. "fmt"
  5. "math/rand"
  6. "sync"
  7. "testing"
  8. "time"
  9. cherryTime "github.com/cherry-game/cherry/extend/time"
  10. cherryLogger "github.com/cherry-game/cherry/logger"
  11. )
  12. func TestSU1RegisterDevAccount(t *testing.T) {
  13. var (
  14. url = "http://192.168.1.232:18080"
  15. )
  16. accountList := make(map[string]string)
  17. for i := 1; i <= 10000; i++ {
  18. key := fmt.Sprintf("susu%d", i)
  19. accountList[key] = key
  20. }
  21. cli.RegisterDevAccounts(url, accountList)
  22. }
  23. func TestSU_1_10000_EnterServer(t *testing.T) {
  24. var (
  25. url = "http://dev.f1.chun-pu.com"
  26. addr = "192.168.1.232:30001"
  27. gameNodeID = "3"
  28. testAccounts = make(map[string]string)
  29. pid = "2188001"
  30. maxAccountNum = 1
  31. )
  32. for i := 1; i <= maxAccountNum; i++ {
  33. key := fmt.Sprintf("susu%d", i)
  34. testAccounts[key] = key
  35. cli.RegisterDevAccount(url, key, key)
  36. }
  37. now := cherryTime.Now()
  38. wg := &sync.WaitGroup{}
  39. wg.Add(1)
  40. for userName, password := range testAccounts {
  41. go func(userName, password string) {
  42. time.Sleep(time.Duration(rand.Int31n(2)) * time.Millisecond)
  43. cli.EnterServer(url, pid, userName, password, addr, gameNodeID, false)
  44. wg.Done()
  45. }(userName, password)
  46. }
  47. wg.Wait()
  48. cherryLogger.Infof("elapsedTime = %dms", now.NowDiffMillisecond())
  49. }
  50. func Test_Local_SU_3(t *testing.T) {
  51. var (
  52. url = "http://dev.f1.chun-pu.com/"
  53. addr = "127.0.0.1:30001"
  54. gameNodeID = "3"
  55. userAndPwd = "susux3"
  56. pid = "2188001"
  57. )
  58. cli.RegisterDevAccount(url, userAndPwd, userAndPwd)
  59. //wg := &sync.WaitGroup{}
  60. //wg.Add(1)
  61. robot := cli.EnterServer(url, pid, userAndPwd, userAndPwd, addr, gameNodeID, true)
  62. if robot != nil {
  63. //robot.ChargeCreate()
  64. robot.Time()
  65. }
  66. time.Sleep(30 * time.Second)
  67. //wg.Wait()
  68. }